diff --git a/infra/base-images/base-builder/detect_repo_test.py b/infra/base-images/base-builder/detect_repo_test.py index 96f4c9ec3..21f64af44 100644 --- a/infra/base-images/base-builder/detect_repo_test.py +++ b/infra/base-images/base-builder/detect_repo_test.py @@ -36,6 +36,8 @@ import test_repos # pylint: enable=wrong-import-position +@unittest.skipIf(not os.getenv('INTEGRATION_TESTS'), + 'INTEGRATION_TESTS=1 not set') class DetectRepoIntegrationTest(unittest.TestCase): """Class to test the functionality of the detect_repo module.""" diff --git a/infra/build_specified_commit_test.py b/infra/build_specified_commit_test.py index 15bf3be0a..c36e3c7bb 100644 --- a/infra/build_specified_commit_test.py +++ b/infra/build_specified_commit_test.py @@ -31,8 +31,10 @@ import test_repos TEST_DIR_PATH = os.path.dirname(os.path.realpath(__file__)) -class BuildImageIntegrationTests(unittest.TestCase): - """Testing if an image can be built from different states e.g. a commit.""" +@unittest.skipIf(not os.getenv('INTEGRATION_TESTS'), + 'INTEGRATION_TESTS=1 not set') +class BuildImageIntegrationTest(unittest.TestCase): + """Tests if an image can be built from different states e.g. a commit.""" @unittest.skip('Test is failing (spuriously?).') def test_build_fuzzers_from_commit(self): @@ -48,8 +50,8 @@ class BuildImageIntegrationTests(unittest.TestCase): host_src_dir = build_specified_commit.copy_src_from_docker( test_case.project_name, tmp_dir) - test_repo_manager = repo_manager.RepoManager( - test_case.git_url, host_src_dir, repo_name=test_case.oss_repo_name) + test_repo_manager = repo_manager.clone_and_get_manager( + test_case.git_url, host_src_dir, test_case.oss_repo_name) build_data = build_specified_commit.BuildData( sanitizer='address', architecture='x86_64', diff --git a/infra/repo_manager_test.py b/infra/repo_manager_test.py index 653a21718..36a773cc6 100644 --- a/infra/repo_manager_test.py +++ b/infra/repo_manager_test.py @@ -37,11 +37,13 @@ def get_oss_fuzz_repo(): yield os.path.join(tmp_dir, repo_name) -class CloneIntegrationTest(unittest.TestCase): +class CloneTest(unittest.TestCase): """Tests the _clone function.""" - def test_clone_valid_repo(self): - """Tests the correct location of the git repo.""" + @unittest.skipIf(not os.getenv('INTEGRATION_TESTS'), + 'INTEGRATION_TESTS=1 not set') + def test_clone_valid_repo_integration(self): + """Integration test that tests the correct location of the git repo.""" with get_oss_fuzz_repo() as oss_fuzz_repo: git_path = os.path.join(oss_fuzz_repo, '.git') self.assertTrue(os.path.isdir(git_path)) @@ -54,6 +56,8 @@ class CloneIntegrationTest(unittest.TestCase): 'oss-fuzz') +@unittest.skipIf(not os.getenv('INTEGRATION_TESTS'), + 'INTEGRATION_TESTS=1 not set') class RepoManagerCheckoutTest(unittest.TestCase): """Tests the checkout functionality of RepoManager.""" @@ -77,6 +81,8 @@ class RepoManagerCheckoutTest(unittest.TestCase): repo_man.checkout_commit('not-a-valid-commit') +@unittest.skipIf(not os.getenv('INTEGRATION_TESTS'), + 'INTEGRATION_TESTS=1 not set') class RepoManagerGetCommitListTest(unittest.TestCase): """Tests the get_commit_list method of RepoManager.""" @@ -110,6 +116,8 @@ class RepoManagerGetCommitListTest(unittest.TestCase): repo_man.get_commit_list(old_commit, new_commit) # pylint: disable=arguments-out-of-order +@unittest.skipIf(not os.getenv('INTEGRATION_TESTS'), + 'INTEGRATION_TESTS=1 not set') class GitDiffTest(unittest.TestCase): """Tests get_git_diff.""" @@ -149,6 +157,8 @@ class GitDiffTest(unittest.TestCase): self.assertIsNone(diff) +@unittest.skipIf(not os.getenv('INTEGRATION_TESTS'), + 'INTEGRATION_TESTS=1 not set') class CheckoutPrIntegrationTest(unittest.TestCase): """Does Integration tests on the checkout_pr method of RepoManager."""