Skip to content

Commit

Permalink
Make the MANIC_TEST_BARE_REPO_ROOT env var special - give it a consta…
Browse files Browse the repository at this point in the history
…nt for easy tracking, and automatically tear it down after each test.
  • Loading branch information
johnpaulalex committed Feb 23, 2023
1 parent 259bfc0 commit 4c96e82
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions test/test_sys_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@

# subdir under test/ that holds all of our checked-in repositories (which we
# will clone for these tests).
BARE_REPO_ROOT_NAME = 'repos'
BARE_REPO_ROOT_NAME = 'repos'

# Environment var referenced by checked-in externals file in mixed-cont-ext.git,
# which should be pointed to the fully-resolved BARE_REPO_ROOT_NAME directory.
# We explicitly clear this after every test, via tearDown().
MIXED_CONT_EXT_ROOT_ENV_VAR = 'MANIC_TEST_BARE_REPO_ROOT'

# Subdirs under bare repo root, each holding a repository. For more info
# on the contents of these repositories, see test/repos/README.md. In these
Expand Down Expand Up @@ -565,6 +570,10 @@ def tearDown(self):
"""
# return to our common starting point
os.chdir(self._return_dir)

# (in case this was set) Don't pollute environment of other tests.
os.environ.pop(MIXED_CONT_EXT_ROOT_ENV_VAR,
None) # Don't care if key wasn't set.

def clone_test_repo(self, parent_repo_name, dest_dir_in=None):
"""Clones repo under self._bare_root"""
Expand Down Expand Up @@ -1141,8 +1150,9 @@ def test_container_mixed_subrepo(self):
self._generator.write_config(cloned_repo_dir)

# The subrepo has a repo_url that uses this environment variable.
os.environ['MANIC_TEST_BARE_REPO_ROOT'] = self._bare_root
debug_env = 'MANIC_TEST_BARE_REPO_ROOT=' + self._bare_root
# It'll be cleared in tearDown().
os.environ[MIXED_CONT_EXT_ROOT_ENV_VAR] = self._bare_root
debug_env = MIXED_CONT_EXT_ROOT_ENV_VAR + '=' + self._bare_root

# inital checkout: all requireds are clean, and optional is empty.
tree = self.execute_checkout_with_status(cloned_repo_dir,
Expand Down Expand Up @@ -1182,8 +1192,6 @@ def test_container_mixed_subrepo(self):
self._check_sync_clean(tree[self._external_path('simp_branch', base_path=sub_ext_base_path)],
ExternalStatus.STATUS_OK,
ExternalStatus.STATUS_OK)
# Don't pollute environment of other tests.
del os.environ['MANIC_TEST_BARE_REPO_ROOT']

def test_container_component(self):
"""Verify that optional component checkout works
Expand Down Expand Up @@ -1285,8 +1293,9 @@ def test_subexternal(self):
self._generator.write_config(cloned_repo_dir)

# The subrepo has a repo_url that uses this environment variable.
os.environ['MANIC_TEST_BARE_REPO_ROOT'] = self._bare_root
debug_env = 'MANIC_TEST_BARE_REPO_ROOT=' + self._bare_root
# It'll be cleared in tearDown().
os.environ[MIXED_CONT_EXT_ROOT_ENV_VAR] = self._bare_root
debug_env = MIXED_CONT_EXT_ROOT_ENV_VAR + '=' + self._bare_root

# After checkout, confirm required's are clean and the referenced
# subexternal's contents are also clean.
Expand All @@ -1298,8 +1307,6 @@ def test_subexternal(self):
tree[self._external_path(BRANCH_SECTION, base_path=SUB_EXTERNALS_PATH)],
ExternalStatus.STATUS_OK,
ExternalStatus.STATUS_OK)
# Don't pollute environment of other tests.
del os.environ['MANIC_TEST_BARE_REPO_ROOT']

def test_container_sparse(self):
"""Verify that 'full' container with simple subrepo
Expand Down

0 comments on commit 4c96e82

Please sign in to comment.