Skip to content

Commit

Permalink
Make sure b2 exits immediately on syntax errors (#540)
Browse files Browse the repository at this point in the history
Add test verifying Jam syntax error results in non-zero exit status.

Refines #538
Fixes #539
  • Loading branch information
mloskot authored Mar 2, 2020
1 parent 71b8d4b commit bdccf53
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 19 deletions.
42 changes: 23 additions & 19 deletions src/engine/jam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,28 +649,32 @@ int main( int argc, char * * argv, char * * arg_environ )
parse_file( constant_plus, frame );
}

status = yyanyerrors();
if ( status && !last_update_now_status )
last_update_now_status = status;
/* FIXME: What shall we do if builtin_update_now,
* the sole place setting last_update_now_status,
* failed earlier?
*/

/* Manually touch -t targets. */
for ( n = 0; ( s = getoptval( optv, 't', n ) ); ++n )
status = yyanyerrors();
if ( !status )
{
OBJECT * const target = object_new( s );
touch_target( target );
object_free( target );
}

/* Manually touch -t targets. */
for ( n = 0; ( s = getoptval( optv, 't', n ) ); ++n )
{
OBJECT * const target = object_new( s );
touch_target( target );
object_free( target );
}

/* Now make target. */
{
PROFILE_ENTER( MAIN_MAKE );
LIST * const targets = targets_to_update();
if ( !list_empty( targets ) )
status |= make( targets, anyhow );
else
status = last_update_now_status;
PROFILE_EXIT( MAIN_MAKE );
/* Now make target. */
{
PROFILE_ENTER( MAIN_MAKE );
LIST * const targets = targets_to_update();
if ( !list_empty( targets ) )
status |= make( targets, anyhow );
else
status = last_update_now_status;
PROFILE_EXIT( MAIN_MAKE );
}
}

PROFILE_EXIT( MAIN );
Expand Down
23 changes: 23 additions & 0 deletions test/core_syntax_error_exit_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/python

# Copyright (C) Mateusz Loskot 2020.
# 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 Jam syntax error 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.run_build_system(status=1)

t.cleanup()
1 change: 1 addition & 0 deletions test/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def reorder_tests(tests, first_test):
"core_actions_quietly",
"core_at_file",
"core_bindrule",
"core_syntax_error_exit_status",
"core_fail_expected",
"core_jamshell",
"core_multifile_actions",
Expand Down

0 comments on commit bdccf53

Please sign in to comment.