From fe858f5ecc8b6db4b38b39813900b6558ab3108c Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Wed, 11 Nov 2015 17:14:03 -0800 Subject: [PATCH] Add build integration test checking stderr shows up in stream Signed-off-by: Joffrey F --- Makefile | 2 ++ tests/integration/build_test.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/Makefile b/Makefile index 824ae70d..40f18a18 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,8 @@ all: test clean: + rm -rf tests/__pycache__ + rm -rf tests/*/__pycache__ docker rm -vf dpy-dind build: diff --git a/tests/integration/build_test.py b/tests/integration/build_test.py index 93280ab2..a76bb257 100644 --- a/tests/integration/build_test.py +++ b/tests/integration/build_test.py @@ -114,3 +114,22 @@ class BuildTest(api_test.BaseTestCase): info = self.client.inspect_image('buildargs') self.assertEqual(info['Config']['User'], 'OK') + + def test_build_stderr_data(self): + control_chars = ['\x1b[91m', '\x1b[0m'] + snippet = 'Ancient Temple (Mystic Oriental Dream ~ Ancient Temple)' + script = io.BytesIO(b'\n'.join([ + b'FROM busybox', + 'RUN sh -c ">&2 echo \'{0}\'"'.format(snippet).encode('utf-8') + ])) + + stream = self.client.build( + fileobj=script, stream=True, decode=True, nocache=True + ) + lines = [] + for chunk in stream: + lines.append(chunk.get('stream')) + expected = '{0}{2}\n{1}'.format( + control_chars[0], control_chars[1], snippet + ) + self.assertTrue(any([line == expected for line in lines]))