From 9c9c533b937729f24744ee772b946f87eed20079 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Wed, 9 Jun 2010 07:09:29 +0000 Subject: [PATCH] Fix detection of exit status. We use close on pipe to get return status and if program does exit(1) we get '1'. The code for checking was using os.WIFSIGNALLED, and that returns true for '1' -- it seems like it is expecting result of os.system, which would be 256, or something. [SVN r62634] --- v2/test/BoostBuild.py | 6 ++---- v2/test/exit_status.py | 26 ++++++++++++++++++++++++++ v2/test/gcc_runtime.py | 2 +- v2/test/test_all.py | 3 ++- 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100755 v2/test/exit_status.py diff --git a/v2/test/BoostBuild.py b/v2/test/BoostBuild.py index 49db78476..9f7705cb6 100644 --- a/v2/test/BoostBuild.py +++ b/v2/test/BoostBuild.py @@ -131,8 +131,6 @@ if os.name == 'posix': def _failed(self, status=0): if self.status is None: return None - if os.WIFSIGNALED(status): - return None return _status(self) != status def _status(self): if os.WIFEXITED(self.status): @@ -458,8 +456,8 @@ class Tester(TestCmd.TestCmd): annotation("failure", '"%s" returned %d%s' % (kw['program'], _status(self), expect)) - - annotation("reason", "error returned by bjam") + + annotation("reason", "unexpected status returned by bjam") self.fail_test(1) if not (stdout is None) and not match(self.stdout(), stdout): diff --git a/v2/test/exit_status.py b/v2/test/exit_status.py new file mode 100755 index 000000000..11c4abf76 --- /dev/null +++ b/v2/test/exit_status.py @@ -0,0 +1,26 @@ +#!/usr/bin/python + +# Copyright (C) Vladimir Prus 2010. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# Test that build failure results in non-zero exit status + +import BoostBuild + +# Create a temporary working directory. +t = BoostBuild.Tester() + +# Create the needed files. +t.write("jamroot.jam", """ +exe hello : hello.cpp ; +""") + +t.write("hello.cpp", """ +int main() { +""") + +t.run_build_system(status=1) + +t.cleanup() diff --git a/v2/test/gcc_runtime.py b/v2/test/gcc_runtime.py index a7e57550f..696b6a5fd 100644 --- a/v2/test/gcc_runtime.py +++ b/v2/test/gcc_runtime.py @@ -23,7 +23,7 @@ t.write("hello.cpp", """ int main() { } """) -t.run_build_system("runtime-link=static", status=1) +t.run_build_system("runtime-link=static") t.fail_test(string.find(t.stdout(), "On gcc, DLL can't be build with 'static'") == -1) diff --git a/v2/test/test_all.py b/v2/test/test_all.py index 038c2928a..fad67fab6 100644 --- a/v2/test/test_all.py +++ b/v2/test/test_all.py @@ -201,7 +201,8 @@ tests = [ "absolute_sources", "use_requirements", "using", "wrapper", - "wrong_project" + "wrong_project", + "exit_status", ] if os.name == 'posix':