From e233ca7a54875a46d287299d4d602231f77be138 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 15 Feb 2015 01:19:06 +0300 Subject: [PATCH 1/2] Fix compiling C client when using Python-2.6 `shlex.split` is inadequate when it receives Unicode strings: `u'-O3'` is split into a single argument that looks like `'-\x00O\x003\x00'`. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5160c19f..de22136f 100755 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ def compile_client(): else: from distutils.ccompiler import new_compiler compiler = new_compiler().compiler - cflags = os.environ.get('CFLAGS', '-O3') + cflags = os.environ.get('CFLAGS', str('-O3')) # A normal split would do a split on each space which might be incorrect. The # shlex will not split if a space occurs in an arguments value. subprocess.check_call(compiler + shlex.split(cflags) + ['client/powerline.c', '-o', 'scripts/powerline']) From 4c6a2e3e597b30fdd1c4ed1c75750cc44d65036c Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 15 Feb 2015 01:25:25 +0300 Subject: [PATCH 2/2] Also check that MIME type matches during tests MIME type names are inconsistent across different systems, so only first component is used. For example, `file` in Travis Ubuntu detects Python scripts as `text/x-java`, in Gentoo these are `text/x-python`. Travis Ubuntu also uses magic file format different from the one sys-apps/file-5.22 from Gentoo has, making it impossible to fix the issue by just copying the files from my system. --- tests/test_shells/test.sh | 40 ++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index fdce0d3e..14430361 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -279,9 +279,11 @@ ln -s ../../test_shells/waitpid.sh tests/shell/path if which socat ; then ln -s "$(which socat)" tests/shell/path fi -for pexe in powerline powerline-config ; do +for pexe in powerline powerline-config powerline-render powerline.sh powerline.py ; do if test -e scripts/$pexe ; then ln -s "$PWD/scripts/$pexe" tests/shell/path + elif test -e client/$pexe ; then + ln -s "$PWD/client/$pexe" tests/shell/path elif which $pexe ; then ln -s "$(which $pexe)" tests/shell/path else @@ -319,6 +321,25 @@ export ADDRESS="powerline-ipc-test-$$" export PYTHON echo "Powerline address: $ADDRESS" +check_test_client() { + local executable="$1" + local client_type="$2" + local actual_mime_type="$(file --mime-type --brief --dereference "tests/shell/path/$executable" | cut -d/ -f1)" + local expected_mime_type + case "$client_type" in + C) expected_mime_type="application/x-executable" ;; + python) expected_mime_type="text/x-python" ;; + render) expected_mime_type="text/x-python" ;; + shell) expected_mime_type="text/x-shellscript" ;; + esac + expected_mime_type="${expected_mime_type%/*}" + if test "$expected_mime_type" != "$actual_mime_type" ; then + echo "Expected $executable to have MIME type $expected_mime_type, but got $actual_mime_type" + FAILED=1 + FAIL_SUMMARY="${FAIL_SUMMARY}${NL}M ${executable}" + fi +} + if test -z "${ONLY_SHELL}" || test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || test "x${ONLY_SHELL}" = xbusybox || test "x${ONLY_SHELL}" = xrc ; then scripts/powerline-config shell command @@ -345,17 +366,18 @@ if test -z "${ONLY_SHELL}" || test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || te echo "> Testing $TEST_TYPE" I=-1 for POWERLINE_COMMAND in \ - $PWD/scripts/powerline \ - $PWD/scripts/powerline-render \ - $PWD/client/powerline.py \ - $PWD/client/powerline.sh + powerline \ + powerline-render \ + powerline.py \ + powerline.sh do case "$POWERLINE_COMMAND" in - *powerline) TEST_CLIENT=C ;; - *powerline-render) TEST_CLIENT=render ;; - *powerline.py) TEST_CLIENT=python ;; - *powerline.sh) TEST_CLIENT=shell ;; + powerline) TEST_CLIENT=C ;; + powerline-render) TEST_CLIENT=render ;; + powerline.py) TEST_CLIENT=python ;; + powerline.sh) TEST_CLIENT=shell ;; esac + check_test_client "$POWERLINE_COMMAND" $TEST_CLIENT if test "$TEST_CLIENT" = render && test "$TEST_TYPE" = daemon ; then continue fi