3 # Copyright 2012. Jurko Gospodnetic
4 # Distributed under the Boost Software License, Version 1.0.
5 # (See accompanying file LICENSE_1_0.txt or copy at
6 # http://www.boost.org/LICENSE_1_0.txt)
8 # Test Boost Jam parser's source line tracking & reporting.
13 def test_eof_in_string():
14 t = BoostBuild.Tester(pass_toolset=False)
15 t.write("file.jam", '\n\n\naaa = "\n\n\n\n\n\n')
16 t.run_build_system(["-ffile.jam"], status=1)
17 t.expect_output_lines('file.jam:4: unmatched " in string at keyword =')
18 t.expect_output_lines("file.jam:4: syntax error at EOF")
22 def test_error_missing_argument(eof):
24 This use case used to cause a missing argument error to be reported in
25 module '(builtin)' in line -1 when the input file did not contain a
29 t = BoostBuild.Tester(pass_toolset=False)
30 t.write("file.jam", """\
32 f ;%s""" % __trailing_newline(eof))
33 t.run_build_system(["-ffile.jam"], status=1)
34 t.expect_output_lines("file.jam:2: in module scope")
35 t.expect_output_lines("file.jam:1:see definition of rule 'f' being called")
39 def test_error_syntax(eof):
40 t = BoostBuild.Tester(pass_toolset=False)
41 t.write("file.jam", "ECHO%s" % __trailing_newline(eof))
42 t.run_build_system(["-ffile.jam"], status=1)
43 t.expect_output_lines("file.jam:1: syntax error at EOF")
48 t = BoostBuild.Tester(pass_toolset=False)
49 t.write("file.jam", """\
51 ECHO [ BACKTRACE ] ;""")
52 t.run_build_system(["-ffile.jam"])
53 t.expect_output_lines("file.jam 2 module scope")
57 def __trailing_newline(eof):
59 Helper function returning an empty string or a newling character to
60 append to the current output line depending on whether we want that line to
61 be the last line in the file (eof == True) or not (eof == False).
69 test_error_missing_argument(eof=False)
70 test_error_missing_argument(eof=True)
71 test_error_syntax(eof=False)
72 test_error_syntax(eof=True)