diff options
author | 2020-01-06 12:17:26 -0800 | |
---|---|---|
committer | 2020-01-06 12:17:26 -0800 | |
commit | 9532d4781a8a7539591f6edc0b86e82786fffafa (patch) | |
tree | 8b70a7ceaa4904ac03d0af2455badf07fc0bcf99 /infra/repo_manager_test.py | |
parent | 14bdd9332c0ae144dd24c9d09139c55a397f902d (diff) |
[infra] Fixing bisection to work with more OSS-Fuzz projects (#3152)
* Max comments
* Added bisection tests
* Added test cases
* Docker run command added to build_specific commit
* Infer main repo uses docker image rather than docker file
* Added mores tests for repo infer
* With verbosity
* Formatting
* Bisection fixed
* Formatting updates
* Oliver small comments.
* Script infer main repo
* Detect repo and test module finished
* Detect main repo from script
* Regex searching
* Regex searching
* Max comments + bisector test script
* Oliver comments
* Max's comments
* String concat update
* Jonathan comments
Diffstat (limited to 'infra/repo_manager_test.py')
-rw-r--r-- | infra/repo_manager_test.py | 74 |
1 files changed, 39 insertions, 35 deletions
diff --git a/infra/repo_manager_test.py b/infra/repo_manager_test.py index c8627f66..1c271cf5 100644 --- a/infra/repo_manager_test.py +++ b/infra/repo_manager_test.py @@ -20,6 +20,7 @@ The will consist of the following functional tests import os import unittest +import tempfile import repo_manager @@ -31,47 +32,50 @@ class TestRepoManager(unittest.TestCase): def test_clone_correctly(self): """Tests the correct location of the git repo.""" - test_repo_manager = repo_manager.RepoManager(self.curl_repo, 'tmp') - git_path = os.path.join(test_repo_manager.base_dir, - test_repo_manager.repo_name, '.git') - self.assertTrue(os.path.isdir(git_path)) - test_repo_manager.remove_repo() - with self.assertRaises(repo_manager.RepoManagerError): - test_repo_manager = repo_manager.RepoManager(' ', 'tmp') + with tempfile.TemporaryDirectory() as tmp_dir: + test_repo_manager = repo_manager.RepoManager(self.curl_repo, tmp_dir) + git_path = os.path.join(test_repo_manager.base_dir, + test_repo_manager.repo_name, '.git') + self.assertTrue(os.path.isdir(git_path)) + test_repo_manager.remove_repo() + with self.assertRaises(repo_manager.RepoManagerError): + test_repo_manager = repo_manager.RepoManager(' ', tmp_dir) def test_checkout_commit(self): """Tests that the git checkout command works.""" - test_repo_manager = repo_manager.RepoManager(self.curl_repo, 'tmp') - commit_to_test = '036ebac0134de3b72052a46f734e4ca81bb96055' - test_repo_manager.checkout_commit(commit_to_test) - self.assertEqual(commit_to_test, test_repo_manager.get_current_commit()) - with self.assertRaises(ValueError): - test_repo_manager.checkout_commit(' ') - with self.assertRaises(repo_manager.RepoManagerError): - test_repo_manager.checkout_commit( - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') - test_repo_manager.remove_repo() + with tempfile.TemporaryDirectory() as tmp_dir: + test_repo_manager = repo_manager.RepoManager(self.curl_repo, tmp_dir) + commit_to_test = '036ebac0134de3b72052a46f734e4ca81bb96055' + test_repo_manager.checkout_commit(commit_to_test) + self.assertEqual(commit_to_test, test_repo_manager.get_current_commit()) + with self.assertRaises(ValueError): + test_repo_manager.checkout_commit(' ') + with self.assertRaises(repo_manager.RepoManagerError): + test_repo_manager.checkout_commit( + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') + test_repo_manager.remove_repo() def test_get_commit_list(self): """Tests an accurate commit list can be retrived from the repo manager.""" - test_repo_manager = repo_manager.RepoManager(self.curl_repo, 'tmp') - old_commit = '7cf18b05e04bbb0f08c74d2567b0648f6c31a952' - new_commit = '113db127ee2b2f874dfcce406103ffe666e11953' - commit_list = [ - '113db127ee2b2f874dfcce406103ffe666e11953', - '793e37767581aec7102d2ecafa34fc1316b1b31f', - '9a2cbf30b81a2b57149bb20e78e2e4cb5c2ff389', - '7cf18b05e04bbb0f08c74d2567b0648f6c31a952' - ] - result_list = test_repo_manager.get_commit_list(old_commit, new_commit) - self.assertListEqual(commit_list, result_list) - with self.assertRaises(repo_manager.RepoManagerError): - test_repo_manager.get_commit_list('asafd', new_commit) - with self.assertRaises(repo_manager.RepoManagerError): - test_repo_manager.get_commit_list(new_commit, 'asdfasdf') - with self.assertRaises(repo_manager.RepoManagerError): - # Testing commits out of order - test_repo_manager.get_commit_list(new_commit, old_commit) + with tempfile.TemporaryDirectory() as tmp_dir: + test_repo_manager = repo_manager.RepoManager(self.curl_repo, tmp_dir) + old_commit = '7cf18b05e04bbb0f08c74d2567b0648f6c31a952' + new_commit = '113db127ee2b2f874dfcce406103ffe666e11953' + commit_list = [ + '113db127ee2b2f874dfcce406103ffe666e11953', + '793e37767581aec7102d2ecafa34fc1316b1b31f', + '9a2cbf30b81a2b57149bb20e78e2e4cb5c2ff389', + '7cf18b05e04bbb0f08c74d2567b0648f6c31a952' + ] + result_list = test_repo_manager.get_commit_list(old_commit, new_commit) + self.assertListEqual(commit_list, result_list) + with self.assertRaises(repo_manager.RepoManagerError): + test_repo_manager.get_commit_list('asafd', new_commit) + with self.assertRaises(repo_manager.RepoManagerError): + test_repo_manager.get_commit_list(new_commit, 'asdfasdf') + with self.assertRaises(repo_manager.RepoManagerError): + # Testing commits out of order + test_repo_manager.get_commit_list(new_commit, old_commit) if __name__ == '__main__': |