diff options
author | jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> | 2020-12-18 10:37:56 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-18 10:37:56 -0800 |
commit | 2a1194c9391af6a7d74e7645152969b067dab23c (patch) | |
tree | cd95a1ba45fed458e0507c8b3de750e2b104d6ac /infra/test_helpers.py | |
parent | 878612f603e2937d98e3833ae17229c09b4f51d7 (diff) | |
download | oss-fuzz-2a1194c9391af6a7d74e7645152969b067dab23c.tar.gz |
Improve CIFuzz tests (#4868)
1. Fix problem where permissions were being changed to root by non-root test (test was doing this by invoking test_all.py within docker).
2. Mark tests as integration tests so that cifuzz_test.py can be run in a reasonable amount of time.
3. Prevent some unittests from polluting source repo.
4. Add .venv to .gitignore
5. Rename test_test_all.py to the correctly formatted name "test_all_test.py"
Diffstat (limited to 'infra/test_helpers.py')
-rw-r--r-- | infra/test_helpers.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/infra/test_helpers.py b/infra/test_helpers.py index 5a9a4d582..be0b1b811 100644 --- a/infra/test_helpers.py +++ b/infra/test_helpers.py @@ -13,7 +13,10 @@ # limitations under the License. """Contains convenient helpers for writing tests.""" +import contextlib import os +import shutil +import tempfile from unittest import mock @@ -25,3 +28,12 @@ def patch_environ(testcase_obj, env=None): patcher = mock.patch.dict(os.environ, env) testcase_obj.addCleanup(patcher.stop) patcher.start() + + +@contextlib.contextmanager +def temp_dir_copy(directory): + """Context manager that yields a temporary copy of |directory|.""" + with tempfile.TemporaryDirectory() as temp_dir: + temp_copy_path = os.path.join(temp_dir, os.path.basename(directory)) + shutil.copytree(directory, temp_copy_path) + yield temp_copy_path |