Skip to content

Commit

Permalink
Merge pull request #22 from avirshup/release0.5.6
Browse files Browse the repository at this point in the history
Release0.5.6
  • Loading branch information
avirshup authored Jun 13, 2017
2 parents 4d1e334 + 989b649 commit 1aacde7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dockermake/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def stream_docker_logs(stream, name):

def get_console_width():
try:
_, consolewidth = map(int, os.popen('stty size', 'r').read().split())
_, consolewidth = map(int, os.popen('stty size 2> /dev/null', 'r').read().split())
except:
consolewidth = 80
return consolewidth
Expand Down
34 changes: 27 additions & 7 deletions test/test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def test_push_dockerhub_with_login():
'docker.io/avirshup/docker-make-test-push:testimage-%s' % customtag
])


def test_example_build():
subprocess.check_call(
"docker-make final --repo myrepo --tag mytag".split(),
Expand All @@ -84,19 +85,38 @@ def test_example_build():
cwd=EXAMPLEDIR)


def test_get_console_width_no_stderr_on_failure():
# run docker-make with a non-console standard input
# (inspiration from Python's subprocess.py)
process = subprocess.Popen("docker-make final --repo myrepo --tag mytag".split(),
cwd=EXAMPLEDIR,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
try:
stdout, stderr = process.communicate(b"I am not a shell")
except:
process.kill()
process.wait()
raise
retcode = process.poll()
if retcode:
raise subprocess.CalledProcessError(retcode, process.args, output=stdout, stderr=stderr)

assert b"ioctl for device" not in stderr


TEMPNAME = 'dmtest__python_test'


def test_write_then_build(tmpdir):
tmppath = str(tmpdir)
subprocess.check_call(
"docker-make -n -p --dockerfile-dir %s python_image" % tmppath,
shell=True,
cwd=EXAMPLEDIR)
subprocess.check_call("docker-make -n -p --dockerfile-dir %s python_image" % tmppath,
shell=True,
cwd=EXAMPLEDIR)
subprocess.check_call("docker rm %s; docker build . -f Dockerfile.python_image -t %s" % (TEMPNAME, TEMPNAME),
shell=True,
cwd=tmppath)
stdout = subprocess.check_output(
"docker run %s python -c 'import pint; print 42'" % TEMPNAME,
shell=True)
stdout = subprocess.check_output("docker run %s python -c 'import pint; print 42'" % TEMPNAME,
shell=True)
assert int(stdout.strip()) == 42

0 comments on commit 1aacde7

Please sign in to comment.