summaryrefslogtreecommitdiff
path: root/buildscripts/tests
diff options
context:
space:
mode:
authorRichard Samuels <richard.samuels@mongodb.com>2020-06-01 14:33:45 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-02 20:20:56 +0000
commit57602df50ec8a86f133631f9eeaf5f2d1eab2d0c (patch)
tree4a8d609d6d8b6c66c3b500b69e182299b0b14157 /buildscripts/tests
parentbecc8e5ecca4260e844725fa71f4ed1164647e4a (diff)
downloadmongo-57602df50ec8a86f133631f9eeaf5f2d1eab2d0c.tar.gz
SERVER-48188 Fix buildscripts_test on Windows
Diffstat (limited to 'buildscripts/tests')
-rw-r--r--buildscripts/tests/test_evergreen_gen_multiversion_tests.py29
1 files changed, 24 insertions, 5 deletions
diff --git a/buildscripts/tests/test_evergreen_gen_multiversion_tests.py b/buildscripts/tests/test_evergreen_gen_multiversion_tests.py
index 1594548ad3f..4fdba6e44f9 100644
--- a/buildscripts/tests/test_evergreen_gen_multiversion_tests.py
+++ b/buildscripts/tests/test_evergreen_gen_multiversion_tests.py
@@ -34,10 +34,23 @@ class TestRun(unittest.TestCase):
''' Hijacks the write_file_to_dir function to prevent the configuration
from being written to disk, and ensure the command fails '''
under_test.CONFIG_DIR = self._tmpdir.name
- with NamedTemporaryFile(mode='w') as expansions_file, NamedTemporaryFile() as evg_conf:
+
+ # NamedTemporaryFile doesn't work too well on Windows. We need to
+ # close the fd's so that run_generate_tasks can open the files,
+ # so we override the delete-on-close behaviour on Windows, and manually
+ # handle cleanup later
+ is_windows = os.name == 'nt'
+ with NamedTemporaryFile(mode='w',
+ delete=not is_windows) as expansions_file, NamedTemporaryFile(
+ mode='w', delete=not is_windows) as evg_conf:
expansions_file.write(EXPANSIONS)
expansions_file.flush()
should_tasks_be_generated.return_value = True
+ if is_windows:
+ # on windows we need to close the fd's so that
+ # run_generate_tasks can open the file handle
+ expansions_file.close()
+ evg_conf.close()
runner = CliRunner()
result = runner.invoke(
@@ -50,17 +63,26 @@ class TestRun(unittest.TestCase):
f"Multiversion suite generator unexpectedly yielded no configuration in '{self._tmpdir.name}'"
)
self.assertEqual(write_file_to_dir.call_count, 1)
+ if is_windows:
+ # on windows we need to manually delete these files, since
+ # we've disabled the delete-on-close mechanics
+ os.remove(expansions_file.name)
+ os.remove(evg_conf.name)
class TestGenerateExcludeFiles(unittest.TestCase):
def setUp(self):
self._tmpdir = TemporaryDirectory()
+ under_test.CONFIG_DIR = self._tmpdir.name
def tearDown(self):
- self._tmpdir.cleanup()
+ if self._tmpdir is not None:
+ self._tmpdir.cleanup()
under_test.CONFIG_DIR = generate_resmoke.DEFAULT_CONFIG_VALUES["generated_config_dir"]
def test_missing_dir_okay(self):
+ self._tmpdir.cleanup()
+ self._tmpdir = None
self.assertFalse(os.path.exists(under_test.CONFIG_DIR))
runner = CliRunner()
@@ -70,8 +92,6 @@ class TestGenerateExcludeFiles(unittest.TestCase):
self.assertEqual(result.exit_code, 0, result)
def test_empty_dir_okay(self):
- under_test.CONFIG_DIR = self._tmpdir.name
-
runner = CliRunner()
result = runner.invoke(
under_test.generate_exclude_yaml,
@@ -83,7 +103,6 @@ class TestGenerateExcludeFiles(unittest.TestCase):
def test_adds_exclude_file(self, get_exclude_files):
get_exclude_files.return_value = set()
get_exclude_files.return_value.add('jstests/core/count_plan_summary.js')
- under_test.CONFIG_DIR = self._tmpdir.name
with open(self._tmpdir.name + "/sharding_jscore_passthrough_00.yml", mode='w') as fh:
fh.write(CONF)