From bd02e2e997cf1bcf6a20d798891cf1d4de371c18 Mon Sep 17 00:00:00 2001 From: Min RK Date: Thu, 27 Jan 2022 10:09:45 +0100 Subject: [PATCH] run check-tmp as root - avoids permission errors - lets us check /root/ where we've left files in the past --- tests/check-tmp | 8 +++++--- tests/conftest.py | 13 ++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/check-tmp b/tests/check-tmp index d7657283..6437c437 100755 --- a/tests/check-tmp +++ b/tests/check-tmp @@ -25,10 +25,12 @@ MB = 1024 * 1024 # missing is okay PATHS = [ "/tmp/", + # check whole home? + # this shouldn't be empty, but for our tests (so far) it should be very small + # This is the easiest way to ensure we aren't leaving any unexpected files + # without knowing ahead of time where all possible caches might be (.npm, .cache, etc.) "~/", - "~/.cache/", - # not running with read permissions on root - # "/root/", + "/root/", ] diff --git a/tests/conftest.py b/tests/conftest.py index c9bd11d9..19c0ca6e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -41,12 +41,14 @@ def pytest_collect_file(parent, path): return RemoteRepoList.from_parent(parent, fspath=path) -def make_test_func(args, skip_build=False): +def make_test_func(args, skip_build=False, extra_run_kwargs=None): """Generate a test function that runs repo2docker""" def test(): app = make_r2d(args) app.initialize() + if extra_run_kwargs: + app.extra_run_kwargs.update(extra_run_kwargs) if skip_build: def build_noop(): @@ -193,10 +195,14 @@ def repo_with_submodule(): class Repo2DockerTest(pytest.Function): """A pytest.Item for running repo2docker""" - def __init__(self, name, parent, args=None, skip_build=False): + def __init__( + self, name, parent, args=None, skip_build=False, extra_run_kwargs=None + ): self.args = args self.save_cwd = os.getcwd() - f = parent.obj = make_test_func(args, skip_build=skip_build) + f = parent.obj = make_test_func( + args, skip_build=skip_build, extra_run_kwargs=extra_run_kwargs + ) super().__init__(name, parent, callobj=f) def reportinfo(self): @@ -254,6 +260,7 @@ class LocalRepo(pytest.File): name="check-tmp", args=check_tmp_args, skip_build=True, + extra_run_kwargs={"user": "root"}, )