diff options
author | Cassidy Burden <cburden@google.com> | 2016-06-14 16:47:02 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-06-15 10:53:41 -0700 |
commit | 9c665a01b55ee4e672b29ff352989a640eac084f (patch) | |
tree | 87d3b9e0fbcc4874aa94ec8a5e196ffba1092b00 /binary_search_tool/test | |
parent | 51ba54f3375c17e2a33c1854b635b144802457a4 (diff) | |
download | toolchain-utils-9c665a01b55ee4e672b29ff352989a640eac084f.tar.gz |
Fix binary search tool install unit tests
Change from using module wide variable common.installed to using a file
called "./installed". Previously common.installed wouldn't actually be
set properly because there would be two separate instances of Python
running.
TEST=More robust install unit test made
Change-Id: Iee87a52e0f54fc63837b25918764e804747525db
Reviewed-on: https://chrome-internal-review.googlesource.com/264745
Commit-Ready: Cassidy Burden <cburden@google.com>
Tested-by: Cassidy Burden <cburden@google.com>
Reviewed-by: Caroline Tice <cmtice@google.com>
Diffstat (limited to 'binary_search_tool/test')
-rwxr-xr-x | binary_search_tool/test/binary_search_tool_tester.py | 14 | ||||
-rwxr-xr-x | binary_search_tool/test/install.py | 7 | ||||
-rwxr-xr-x | binary_search_tool/test/is_good.py | 3 |
3 files changed, 17 insertions, 7 deletions
diff --git a/binary_search_tool/test/binary_search_tool_tester.py b/binary_search_tool/test/binary_search_tool_tester.py index 73ea4d13..451543d1 100755 --- a/binary_search_tool/test/binary_search_tool_tester.py +++ b/binary_search_tool/test/binary_search_tool_tester.py @@ -30,6 +30,9 @@ class BisectingUtilsTest(unittest.TestCase): bad_obj_num = 1 gen_obj.Main(['--obj_num', str(obj_num), '--bad_obj_num', str(bad_obj_num)]) + with open('./installed', 'w'): + pass + try: os.remove(binary_search_state.STATE_FILE) except OSError: @@ -42,6 +45,7 @@ class BisectingUtilsTest(unittest.TestCase): print('Deleted "{0}" and "{1}"'.format(common.OBJECTS_FILE, common.WORKING_SET_FILE)) try: + os.remove('./installed') os.remove(os.readlink(binary_search_state.STATE_FILE)) os.remove(binary_search_state.STATE_FILE) except OSError: @@ -57,9 +61,13 @@ class BisectingUtilsTest(unittest.TestCase): def test_install_script(self): args = ['--get_initial_items', './gen_init_list.py', '--switch_to_good', './switch_to_good.py', '--switch_to_bad', './switch_to_bad.py', - '--test_script', './is_good.py', '--prune', '--file_args', - '--install_script', './install.py'] - common.installed = False + '--test_script', './is_good.py', '--prune', '--file_args'] + + os.remove('./installed') + with self.assertRaises(AssertionError): + binary_search_state.Main(args) + + args += ['--install_script', './install.py'] binary_search_state.Main(args) self.check_output() diff --git a/binary_search_tool/test/install.py b/binary_search_tool/test/install.py index 21cf97a1..5f721b92 100755 --- a/binary_search_tool/test/install.py +++ b/binary_search_tool/test/install.py @@ -5,11 +5,12 @@ from __future__ import print_function import sys -import common - def Main(): - common.installed = True + # create ./installed + with open('./installed', 'w'): + pass + return 0 diff --git a/binary_search_tool/test/is_good.py b/binary_search_tool/test/is_good.py index e2ab4642..f7cc8af7 100755 --- a/binary_search_tool/test/is_good.py +++ b/binary_search_tool/test/is_good.py @@ -3,13 +3,14 @@ from __future__ import print_function +import os import sys import common def Main(): - if not common.installed: + if not os.path.exists('./installed'): return 1 working_set = common.ReadWorkingSet() for w in working_set: |