From 24eb3f923af338aa0b42748d7003195a3d6a4749 Mon Sep 17 00:00:00 2001 From: Tim Head Date: Sat, 27 Apr 2019 10:49:32 +0200 Subject: [PATCH 1/3] Fix handling of memory limit command line argument If a string of only numerals is passed as argument we assume it should be converted to an integer and specifies a size in bytes. --- repo2docker/__main__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/repo2docker/__main__.py b/repo2docker/__main__.py index 62d9d883..1cb4862d 100644 --- a/repo2docker/__main__.py +++ b/repo2docker/__main__.py @@ -299,7 +299,12 @@ def make_r2d(argv=None): r2d.user_name = args.user_name if args.build_memory_limit: - r2d.build_memory_limit = args.build_memory_limit + # if the string only contains numerals we assume it should be an int + # and specifies a size inn bytes + if args.build_memory_limit.isnumeric(): + r2d.build_memory_limit = int(args.build_memory_limit) + else: + r2d.build_memory_limit = args.build_memory_limit if args.environment and not r2d.run: print('To specify environment variables, you also need to run ' From c0a33b340b96f5fb8bc7baf38d01f46deda2fb25 Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Tue, 30 Apr 2019 10:46:09 -0700 Subject: [PATCH 2/3] Add test for integral --build-memory-limit --- tests/unit/test_args.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/unit/test_args.py b/tests/unit/test_args.py index a1401468..91ead8bc 100644 --- a/tests/unit/test_args.py +++ b/tests/unit/test_args.py @@ -40,6 +40,17 @@ def test_dry_run(): assert not r2d.run assert not r2d.push + +def test_mem_limit(): + """ + Test various ways of passing --build-memory-limit + """ + r2d = make_r2d(['--build-memory-limit', '1024', '.']) + assert int(r2d.build_memory_limit) == 1024 + + r2d = make_r2d(['--build-memory-limit', '3K', '.']) + assert int(r2d.build_memory_limit) == 1024 * 3 + def test_run_required(): """ Test all the things that should fail if we pass in --no-run From c8cff1bcccad4e5eae060b6bc814879ac77526a4 Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Tue, 30 Apr 2019 10:46:34 -0700 Subject: [PATCH 3/3] Fix typo in comment --- repo2docker/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo2docker/__main__.py b/repo2docker/__main__.py index 1cb4862d..5911c81a 100644 --- a/repo2docker/__main__.py +++ b/repo2docker/__main__.py @@ -300,7 +300,7 @@ def make_r2d(argv=None): if args.build_memory_limit: # if the string only contains numerals we assume it should be an int - # and specifies a size inn bytes + # and specifies a size in bytes if args.build_memory_limit.isnumeric(): r2d.build_memory_limit = int(args.build_memory_limit) else: