diff options
author | Cassidy Burden <cburden@google.com> | 2016-06-13 14:49:36 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-06-16 15:26:17 -0700 |
commit | 76c2be6cad46342f69ca5dd3d69f4f4d31f85de9 (patch) | |
tree | b0a99789384eaa5cf693e0bda1e21b6e21c5917b /binary_search_tool/test | |
parent | c57133760fc479a1c3553172934e25fca5750851 (diff) | |
download | toolchain-utils-76c2be6cad46342f69ca5dd3d69f4f4d31f85de9.tar.gz |
Add resuming to binary search tool
Move around logic so that the binary search tool can be properly resumed
and add the --resume option.
TEST=Added unit test for LoadState
Change-Id: I7059fab9ac6c37ecfd79e4cf2ef976bdebfef8fb
Reviewed-on: https://chrome-internal-review.googlesource.com/264778
Commit-Ready: Cassidy Burden <cburden@google.com>
Tested-by: Cassidy Burden <cburden@google.com>
Reviewed-by: Caroline Tice <cmtice@google.com>
Reviewed-by: Han Shen <shenhan@google.com>
Diffstat (limited to 'binary_search_tool/test')
-rwxr-xr-x | binary_search_tool/test/binary_search_tool_tester.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/binary_search_tool/test/binary_search_tool_tester.py b/binary_search_tool/test/binary_search_tool_tester.py index 0f7906b0..47452d03 100755 --- a/binary_search_tool/test/binary_search_tool_tester.py +++ b/binary_search_tool/test/binary_search_tool_tester.py @@ -86,7 +86,7 @@ class BisectingUtilsTest(unittest.TestCase): f.write('test123') bss = binary_search_state.MockBinarySearchState() - with self.assertRaises(SystemExit): + with self.assertRaises(binary_search_state.Error): bss.SaveState() with open(state_file, 'r') as f: @@ -103,10 +103,27 @@ class BisectingUtilsTest(unittest.TestCase): first_state = os.readlink(state_file) bss.SaveState() + second_state = os.readlink(state_file) self.assertTrue(os.path.exists(state_file)) - self.assertTrue(os.readlink(state_file) != first_state) + self.assertTrue(second_state != first_state) self.assertFalse(os.path.exists(first_state)) + bss.RemoveState() + self.assertFalse(os.path.islink(state_file)) + self.assertFalse(os.path.exists(second_state)) + + def test_load_state(self): + test_items = [1, 2, 3, 4, 5] + + bss = binary_search_state.MockBinarySearchState() + bss.all_items = test_items + bss.SaveState() + + bss = None + + bss2 = binary_search_state.MockBinarySearchState.LoadState() + self.assertEquals(bss2.all_items, test_items) + def test_tmp_cleanup(self): bss = binary_search_state.MockBinarySearchState( get_initial_items='echo "0\n1\n2\n3"', switch_to_good='./switch_tmp.py', @@ -148,6 +165,7 @@ def Main(argv): suite.addTest(BisectingUtilsTest('test_bad_install_script')) suite.addTest(BisectingUtilsTest('test_bad_save_state')) suite.addTest(BisectingUtilsTest('test_save_state')) + suite.addTest(BisectingUtilsTest('test_load_state')) suite.addTest(BisectingUtilsTest('test_tmp_cleanup')) runner = unittest.TextTestRunner() runner.run(suite) |