]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/core_source_line_tracking.py
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / tools / build / test / core_source_line_tracking.py
1 #!/usr/bin/python
2
3 # Copyright 2012. Jurko Gospodnetic
4 # Distributed under the Boost Software License, Version 1.0.
5 # (See accompanying file LICENSE.txt or copy at
6 # https://www.bfgroup.xyz/b2/LICENSE.txt)
7
8 # Test Boost Jam parser's source line tracking & reporting.
9
10 import BoostBuild
11
12
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")
19 t.cleanup()
20
21
22 def test_error_missing_argument(eof):
23 """
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
26 trailing newline.
27
28 """
29 t = BoostBuild.Tester(pass_toolset=False)
30 t.write("file.jam", """\
31 rule f ( param ) { }
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")
36 t.cleanup()
37
38
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")
44 t.cleanup()
45
46
47 def test_traceback():
48 t = BoostBuild.Tester(pass_toolset=False)
49 t.write("file.jam", """\
50 NOTFILE all ;
51 ECHO [ BACKTRACE ] ;""")
52 t.run_build_system(["-ffile.jam"])
53 t.expect_output_lines("file.jam 2 module scope")
54 t.cleanup()
55
56
57 def __trailing_newline(eof):
58 """
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).
62
63 """
64 if eof:
65 return ""
66 return "\n"
67
68
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)
73 test_traceback()
74 test_eof_in_string()