diff --git a/repo2docker/__main__.py b/repo2docker/__main__.py index 6d700d37..49d40ff9 100644 --- a/repo2docker/__main__.py +++ b/repo2docker/__main__.py @@ -306,6 +306,7 @@ def make_r2d(argv=None): r2d.environment = args.environment # if the source exists locally we don't want to delete it at the end + # FIXME: Find a better way to figure out if repo is 'local'. Push this into ContentProvider? if os.path.exists(args.repo): r2d.cleanup_checkout = False else: diff --git a/tests/test_args.py b/tests/test_args.py index d116a4d9..c8a9a8af 100644 --- a/tests/test_args.py +++ b/tests/test_args.py @@ -61,4 +61,19 @@ def test_run_required(): # Can't publish any ports while running if we don't specify a command explicitly with pytest.raises(SystemExit): - make_r2d(['-p', '8000:8000', '.']) \ No newline at end of file + make_r2d(['-p', '8000:8000', '.']) + +def test_clean(): + """ + Test checkout is cleaned appropriately + """ + + # Don't clean when repo isn't local and we explicitly ask it to not clean + assert not make_r2d(['--no-clean', 'https://github.com/blah.git']).cleanup_checkout + # Do clean repo when repo isn't localj + assert make_r2d(['https://github.com/blah.git']).cleanup_checkout + + # Don't clean by default when repo exists locally + assert not make_r2d(['.']).cleanup_checkout + # Don't clean when repo exists locally and we explicitly ask it to not clean + assert not make_r2d(['--no-clean', '.']).cleanup_checkout \ No newline at end of file