|
3 | 3 | characters produces valid instrumented sources. |
4 | 4 | """ |
5 | 5 |
|
| 6 | +import os.path |
| 7 | + |
| 8 | +from e3.fs import cp |
| 9 | + |
6 | 10 | from SCOV.minicheck import build_run_and_coverage, check_xcov_reports |
| 11 | +from SUITE.control import env |
7 | 12 | from SUITE.context import thistest |
8 | 13 | from SUITE.cutils import Wdir |
9 | 14 | from SUITE.tutils import gprfor |
10 | 15 | from SUITE.gprutils import GPRswitches |
11 | 16 |
|
12 | 17 |
|
13 | | -tmp = Wdir('tmp_') |
| 18 | +tmp = Wdir("tmp_") |
| 19 | + |
| 20 | +# Copy the sources in the temporary directory. Note that we cannot test the |
| 21 | +# case of a filename containing a double quote or a backslash on Windows |
| 22 | +# because of filename restrictions on that platform. |
| 23 | +copy_map = { |
| 24 | + "ada_main.adb": "ada_main.adb", |
| 25 | + "bar.c": "src bar.c" if env.build.os.name == "windows" else 'src\\"bar.c', |
| 26 | + |
| 27 | + "main.c": "main.c", |
| 28 | +} |
| 29 | +for src, dest in copy_map.items(): |
| 30 | + cp(os.path.join("..", src), dest) |
| 31 | + |
| 32 | +# Compute the expected coverage report from the actual source filenames. Note |
| 33 | +# that in xcov filenames, "gnatcov coverage" first turns '\' to '/' (during |
| 34 | +# path separator canonicalization) and then the unique filename machinery turns |
| 35 | +# '/' to '-'. |
| 36 | +coverage_data = { |
| 37 | + "ada_main.adb": {"+": {7, 9}}, |
| 38 | + "bar.c": {"+": {4, 5}, "-": {7}}, |
| 39 | + "foo.c": {"+": {4}}, |
| 40 | + "main.c": {"+": {7, 8}}, |
| 41 | +} |
| 42 | +expected_report = { |
| 43 | + "{}.xcov".format(copy_map[filename].replace("\\", "-")): report |
| 44 | + for filename, report in coverage_data.items() |
| 45 | +} |
14 | 46 |
|
15 | 47 | build_run_and_coverage( |
16 | 48 | gprsw=GPRswitches( |
17 | | - root_project=gprfor(srcdirs=['..'], mains=['main.c', 'ada_main.adb']) |
| 49 | + root_project=gprfor(srcdirs=["."], mains=["main.c", "ada_main.adb"]) |
18 | 50 | ), |
19 | | - covlevel='stmt', |
20 | | - mains=['main', 'ada_main'], |
21 | | - extra_coverage_args=['-axcov', '--output-dir=xcov'], |
22 | | - trace_mode='src', |
23 | | -) |
24 | | -check_xcov_reports( |
25 | | - '*.xcov', |
26 | | - { |
27 | | - 'main.c.xcov': {'+': {6}}, |
28 | | - '$foo@bar$.c.xcov': {'+': {4}}, |
29 | | - 'ada_main.adb.xcov': {'+': {9}}, |
30 | | - }, |
31 | | - 'xcov', |
| 51 | + covlevel="stmt", |
| 52 | + mains=["main", "ada_main"], |
| 53 | + extra_coverage_args=["-axcov", "--output-dir=xcov"], |
| 54 | + trace_mode="src", |
32 | 55 | ) |
| 56 | +check_xcov_reports("*.xcov", expected_report, "xcov") |
33 | 57 |
|
34 | 58 | thistest.result() |
0 commit comments