From e0eb375449d29a0996da89ca0b8358bbd3e596b5 Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Mon, 21 Oct 2019 11:42:43 +0100 Subject: [PATCH] Returncode fix (#1) Some trial and error to make sure it works reliably. * remove test_retcode * debug local bash settings * set errexit explicitly in subshell * set errexit also in the subshell in parenthesis * debugging * more debugging (exit code of sh) * is the venv subshell returning exit 1? * what if we remove the additional subshell? * then we need to unquote the command * if statement needs test command quoted * simple if statement * echo command needs to be removed of course * remove debug statements * check if setting errexit here is needed * these settings can be removed At this point ("before") the shell already has errexit set. * setting errexit in the sh invocation is needed This is not inherited, so it's good to specify it. * just double checking that the subshell doesn't exit * use solution from fvue.nl * Solution doesn't seem to work, even popd is run So now I'm putting back the if statement, it seems to be the simplest and most effective solution. * add a comment * prove that errexit is necessary * errexit is indeed needed for chaining --- cibuildwheel/linux.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 453bcde9..2ca2b8df 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -57,8 +57,6 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef mkdir /output cd /project - test_retcode=0 - {environment_exports} for PYBIN in {pybin_paths}; do @@ -111,10 +109,13 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef # Run the tests from a different directory pushd $HOME - sh -c {test_command} + sh -o errexit -c {test_command} popd ) - test_retcode=$(( $test_retcode || $? )) + # exit if tests failed + if [ $? -ne 0 ]; then + exit 1; + fi # clean up rm -rf "$venv_dir" @@ -124,8 +125,6 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef mv "$delocated_wheel" /output chown {uid}:{gid} "/output/$(basename "$delocated_wheel")" done - - exit $test_retcode '''.format( pybin_paths=' '.join(c.path+'/bin' for c in platform_configs), test_requires=' '.join(test_requires),