aboutsummaryrefslogtreecommitdiff
path: root/llvm_tools/modify_a_tryjob_unittest.py
diff options
context:
space:
mode:
Diffstat (limited to 'llvm_tools/modify_a_tryjob_unittest.py')
-rwxr-xr-xllvm_tools/modify_a_tryjob_unittest.py73
1 files changed, 36 insertions, 37 deletions
diff --git a/llvm_tools/modify_a_tryjob_unittest.py b/llvm_tools/modify_a_tryjob_unittest.py
index e3c62972..2b492f1d 100755
--- a/llvm_tools/modify_a_tryjob_unittest.py
+++ b/llvm_tools/modify_a_tryjob_unittest.py
@@ -12,11 +12,10 @@ import json
import unittest
import unittest.mock as mock
-import get_llvm_hash
+from test_helpers import ArgsOutputTest
+from test_helpers import CreateTemporaryJsonFile
+from test_helpers import WritePrettyJsonFile
import modify_a_tryjob
-import test_helpers
-import update_packages_and_run_tests
-import update_tryjob_status
class ModifyATryjobTest(unittest.TestCase):
@@ -27,13 +26,13 @@ class ModifyATryjobTest(unittest.TestCase):
# Create a temporary .JSON file to simulate a .JSON file that has bisection
# contents.
- with test_helpers.CreateTemporaryJsonFile() as temp_json_file:
+ with CreateTemporaryJsonFile() as temp_json_file:
with open(temp_json_file, 'w') as f:
- test_helpers.WritePrettyJsonFile(bisect_test_contents, f)
+ WritePrettyJsonFile(bisect_test_contents, f)
revision_to_modify = 369411
- args_output = test_helpers.ArgsOutputTest()
+ args_output = ArgsOutputTest()
args_output.builders = None
args_output.options = None
@@ -49,7 +48,7 @@ class ModifyATryjobTest(unittest.TestCase):
# Simulate the behavior of `FindTryjobIndex()` when the index of the tryjob
# was not found.
- @mock.patch.object(update_tryjob_status, 'FindTryjobIndex', return_value=None)
+ @mock.patch.object(modify_a_tryjob, 'FindTryjobIndex', return_value=None)
def testNoTryjobIndexFound(self, mock_find_tryjob_index):
bisect_test_contents = {
'start': 369410,
@@ -63,13 +62,13 @@ class ModifyATryjobTest(unittest.TestCase):
# Create a temporary .JSON file to simulate a .JSON file that has bisection
# contents.
- with test_helpers.CreateTemporaryJsonFile() as temp_json_file:
+ with CreateTemporaryJsonFile() as temp_json_file:
with open(temp_json_file, 'w') as f:
- test_helpers.WritePrettyJsonFile(bisect_test_contents, f)
+ WritePrettyJsonFile(bisect_test_contents, f)
revision_to_modify = 369412
- args_output = test_helpers.ArgsOutputTest()
+ args_output = ArgsOutputTest()
args_output.builders = None
args_output.options = None
@@ -89,7 +88,7 @@ class ModifyATryjobTest(unittest.TestCase):
# Simulate the behavior of `FindTryjobIndex()` when the index of the tryjob
# was found.
- @mock.patch.object(update_tryjob_status, 'FindTryjobIndex', return_value=0)
+ @mock.patch.object(modify_a_tryjob, 'FindTryjobIndex', return_value=0)
def testSuccessfullyRemovedTryjobInStatusFile(self, mock_find_tryjob_index):
bisect_test_contents = {
'start': 369410,
@@ -103,13 +102,13 @@ class ModifyATryjobTest(unittest.TestCase):
# Create a temporary .JSON file to simulate a .JSON file that has bisection
# contents.
- with test_helpers.CreateTemporaryJsonFile() as temp_json_file:
+ with CreateTemporaryJsonFile() as temp_json_file:
with open(temp_json_file, 'w') as f:
- test_helpers.WritePrettyJsonFile(bisect_test_contents, f)
+ WritePrettyJsonFile(bisect_test_contents, f)
revision_to_modify = 369414
- args_output = test_helpers.ArgsOutputTest()
+ args_output = ArgsOutputTest()
args_output.builders = None
args_output.options = None
@@ -130,10 +129,10 @@ class ModifyATryjobTest(unittest.TestCase):
# Simulate the behavior of `RunTryJobs()` when successfully submitted a
# tryjob.
- @mock.patch.object(update_packages_and_run_tests, 'RunTryJobs')
+ @mock.patch.object(modify_a_tryjob, 'RunTryJobs')
# Simulate the behavior of `FindTryjobIndex()` when the index of the tryjob
# was found.
- @mock.patch.object(update_tryjob_status, 'FindTryjobIndex', return_value=0)
+ @mock.patch.object(modify_a_tryjob, 'FindTryjobIndex', return_value=0)
def testSuccessfullyRelaunchedTryjob(self, mock_find_tryjob_index,
mock_run_tryjob):
@@ -163,13 +162,13 @@ class ModifyATryjobTest(unittest.TestCase):
# Create a temporary .JSON file to simulate a .JSON file that has bisection
# contents.
- with test_helpers.CreateTemporaryJsonFile() as temp_json_file:
+ with CreateTemporaryJsonFile() as temp_json_file:
with open(temp_json_file, 'w') as f:
- test_helpers.WritePrettyJsonFile(bisect_test_contents, f)
+ WritePrettyJsonFile(bisect_test_contents, f)
revision_to_modify = 369411
- args_output = test_helpers.ArgsOutputTest()
+ args_output = ArgsOutputTest()
args_output.builders = None
args_output.options = None
@@ -208,7 +207,7 @@ class ModifyATryjobTest(unittest.TestCase):
# Simulate the behavior of `FindTryjobIndex()` when the index of the tryjob
# was found.
- @mock.patch.object(update_tryjob_status, 'FindTryjobIndex', return_value=0)
+ @mock.patch.object(modify_a_tryjob, 'FindTryjobIndex', return_value=0)
def testAddingTryjobThatAlreadyExists(self, mock_find_tryjob_index):
bisect_test_contents = {
'start': 369410,
@@ -222,16 +221,16 @@ class ModifyATryjobTest(unittest.TestCase):
# Create a temporary .JSON file to simulate a .JSON file that has bisection
# contents.
- with test_helpers.CreateTemporaryJsonFile() as temp_json_file:
+ with CreateTemporaryJsonFile() as temp_json_file:
with open(temp_json_file, 'w') as f:
- test_helpers.WritePrettyJsonFile(bisect_test_contents, f)
+ WritePrettyJsonFile(bisect_test_contents, f)
revision_to_add = 369411
# Index of the tryjob in 'jobs' list.
tryjob_index = 0
- args_output = test_helpers.ArgsOutputTest()
+ args_output = ArgsOutputTest()
args_output.options = None
# Verify the exception is raised when the tryjob that is going to added
@@ -249,7 +248,7 @@ class ModifyATryjobTest(unittest.TestCase):
mock_find_tryjob_index.assert_called_once()
# Simulate the behavior of `FindTryjobIndex()` when the tryjob was not found.
- @mock.patch.object(update_tryjob_status, 'FindTryjobIndex', return_value=None)
+ @mock.patch.object(modify_a_tryjob, 'FindTryjobIndex', return_value=None)
def testSuccessfullyDidNotAddTryjobOutsideOfBisectionBounds(
self, mock_find_tryjob_index):
@@ -264,14 +263,14 @@ class ModifyATryjobTest(unittest.TestCase):
# Create a temporary .JSON file to simulate a .JSON file that has bisection
# contents.
- with test_helpers.CreateTemporaryJsonFile() as temp_json_file:
+ with CreateTemporaryJsonFile() as temp_json_file:
with open(temp_json_file, 'w') as f:
- test_helpers.WritePrettyJsonFile(bisect_test_contents, f)
+ WritePrettyJsonFile(bisect_test_contents, f)
# Add a revision that is outside of 'start' and 'end'.
revision_to_add = 369450
- args_output = test_helpers.ArgsOutputTest()
+ args_output = ArgsOutputTest()
args_output.options = None
# Verify the exception is raised when adding a tryjob that does not exist
@@ -293,11 +292,11 @@ class ModifyATryjobTest(unittest.TestCase):
# Simulate the behavior of `GetLLVMHashAndVersionFromSVNOption()` when
# successfully retrieved the git hash of the revision to launch a tryjob for.
@mock.patch.object(
- get_llvm_hash,
+ modify_a_tryjob,
'GetLLVMHashAndVersionFromSVNOption',
return_value=('a123testhash1', 369418))
# Simulate the behavior of `FindTryjobIndex()` when the tryjob was not found.
- @mock.patch.object(update_tryjob_status, 'FindTryjobIndex', return_value=None)
+ @mock.patch.object(modify_a_tryjob, 'FindTryjobIndex', return_value=None)
def testSuccessfullyAddedTryjob(self, mock_find_tryjob_index,
mock_get_llvm_hash, mock_add_tryjob):
@@ -312,14 +311,14 @@ class ModifyATryjobTest(unittest.TestCase):
# Create a temporary .JSON file to simulate a .JSON file that has bisection
# contents.
- with test_helpers.CreateTemporaryJsonFile() as temp_json_file:
+ with CreateTemporaryJsonFile() as temp_json_file:
with open(temp_json_file, 'w') as f:
- test_helpers.WritePrettyJsonFile(bisect_test_contents, f)
+ WritePrettyJsonFile(bisect_test_contents, f)
# Add a revision that is outside of 'start' and 'end'.
revision_to_add = 369418
- args_output = test_helpers.ArgsOutputTest()
+ args_output = ArgsOutputTest()
args_output.options = None
new_tryjob_info = {
@@ -359,7 +358,7 @@ class ModifyATryjobTest(unittest.TestCase):
mock_add_tryjob.assert_called_once()
# Simulate the behavior of `FindTryjobIndex()` when the tryjob was found.
- @mock.patch.object(update_tryjob_status, 'FindTryjobIndex', return_value=0)
+ @mock.patch.object(modify_a_tryjob, 'FindTryjobIndex', return_value=0)
def testModifyATryjobOptionDoesNotExist(self, mock_find_tryjob_index):
bisect_test_contents = {
'start': 369410,
@@ -372,14 +371,14 @@ class ModifyATryjobTest(unittest.TestCase):
# Create a temporary .JSON file to simulate a .JSON file that has bisection
# contents.
- with test_helpers.CreateTemporaryJsonFile() as temp_json_file:
+ with CreateTemporaryJsonFile() as temp_json_file:
with open(temp_json_file, 'w') as f:
- test_helpers.WritePrettyJsonFile(bisect_test_contents, f)
+ WritePrettyJsonFile(bisect_test_contents, f)
# Add a revision that is outside of 'start' and 'end'.
revision_to_modify = 369414
- args_output = test_helpers.ArgsOutputTest()
+ args_output = ArgsOutputTest()
args_output.builders = None
args_output.options = None