Add tests for checking if memlimit is enforced
ADD
tests/memlimit.py
+import subprocess
+
+def test_memlimit_nondockerfile():
+ """
+ Test if memory limited builds are working for non dockerfile builds
+ """
+ try:
+ subprocess.check_call([
+ 'repo2docker',
+ '--no-run',
+ '--build-memory-limit', '4M',
+ 'tests/memlimit/non-dockerfile'
+ ])
+ # If this doesn't throw an exception, then memory limit was
+ # not enforced!
+ assert False
+ except subprocess.CalledProcessError as e:
+ assert True
+
+
+def test_memlimit_dockerfile():
+ """
+ Test if memory limited builds are working for non dockerfile builds
+ """
+ try:
+ subprocess.check_call([
+ 'repo2docker',
+ '--no-run',
+ '--build-memory-limit', '4M',
+ 'tests/memlimit/dockerfile'
+ ])
+ # If this doesn't throw an exception, then memory limit was
+ # not enforced!
+ assert False
+ except subprocess.CalledProcessError as e:
+ assert True

ADD
tests/memlimit/dockerfile/Dockerfile
+FROM python:3.6
+
+COPY postBuild /usr/local/bin/postBuild
+RUN ./postBuild

ADD
tests/memlimit/dockerfile/postBuild
+#!/usr/bin/env python3
+
+array = []
+for i in range(1024 * 1024 * 64):
+ array.append(i)

ADD
tests/memlimit/non-dockerfile/postBuild
+#!/usr/bin/env python3
+
+array = []
+for i in range(1024 * 1024 * 64):
+ array.append(i)

Add tests for checking if memlimit is enforced