Skip to content

Commit bd02e2e

Browse files
committed
run check-tmp as root
- avoids permission errors - lets us check /root/ where we've left files in the past
1 parent 6b02915 commit bd02e2e

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

tests/check-tmp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ MB = 1024 * 1024
2525
# missing is okay
2626
PATHS = [
2727
"/tmp/",
28+
# check whole home?
29+
# this shouldn't be empty, but for our tests (so far) it should be very small
30+
# This is the easiest way to ensure we aren't leaving any unexpected files
31+
# without knowing ahead of time where all possible caches might be (.npm, .cache, etc.)
2832
"~/",
29-
"~/.cache/",
30-
# not running with read permissions on root
31-
# "/root/",
33+
"/root/",
3234
]
3335

3436

tests/conftest.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ def pytest_collect_file(parent, path):
4141
return RemoteRepoList.from_parent(parent, fspath=path)
4242

4343

44-
def make_test_func(args, skip_build=False):
44+
def make_test_func(args, skip_build=False, extra_run_kwargs=None):
4545
"""Generate a test function that runs repo2docker"""
4646

4747
def test():
4848
app = make_r2d(args)
4949
app.initialize()
50+
if extra_run_kwargs:
51+
app.extra_run_kwargs.update(extra_run_kwargs)
5052
if skip_build:
5153

5254
def build_noop():
@@ -193,10 +195,14 @@ def repo_with_submodule():
193195
class Repo2DockerTest(pytest.Function):
194196
"""A pytest.Item for running repo2docker"""
195197

196-
def __init__(self, name, parent, args=None, skip_build=False):
198+
def __init__(
199+
self, name, parent, args=None, skip_build=False, extra_run_kwargs=None
200+
):
197201
self.args = args
198202
self.save_cwd = os.getcwd()
199-
f = parent.obj = make_test_func(args, skip_build=skip_build)
203+
f = parent.obj = make_test_func(
204+
args, skip_build=skip_build, extra_run_kwargs=extra_run_kwargs
205+
)
200206
super().__init__(name, parent, callobj=f)
201207

202208
def reportinfo(self):
@@ -254,6 +260,7 @@ def collect(self):
254260
name="check-tmp",
255261
args=check_tmp_args,
256262
skip_build=True,
263+
extra_run_kwargs={"user": "root"},
257264
)
258265

259266

0 commit comments

Comments
 (0)