|
31 | 31 | import os.path |
32 | 32 | import TestSCons |
33 | 33 |
|
| 34 | +def get_db(workdir, use_abspath, ccflags): |
| 35 | + if use_abspath: |
| 36 | + prefix = workdir |
| 37 | + else: |
| 38 | + prefix = '' |
| 39 | + content = """[ |
| 40 | + { |
| 41 | + "command": "%s mygcc.py cc -o test_main.o %s test_main.c", |
| 42 | + "directory": "%s", |
| 43 | + "file": "%s", |
| 44 | + "output": "%s" |
| 45 | + } |
| 46 | +]""" % (sys.executable, |
| 47 | + ' '.join(['-c'] + ccflags), |
| 48 | + workdir, |
| 49 | + os.path.join(prefix, 'test_main.c'), |
| 50 | + os.path.join(prefix, 'test_main.o')) |
| 51 | + if sys.platform == 'win32': |
| 52 | + content = content.replace('\\', '\\\\') |
| 53 | + return content |
| 54 | + |
34 | 55 | test = TestSCons.TestSCons() |
35 | 56 |
|
36 | 57 | test.file_fixture('mylink.py') |
|
56 | 77 | 'compile_commands_over_abs_1.json', |
57 | 78 | ] |
58 | 79 |
|
59 | | -example_rel_file = """[ |
60 | | - { |
61 | | - "command": "%s mygcc.py cc -o test_main.o -c test_main.c", |
62 | | - "directory": "%s", |
63 | | - "file": "test_main.c", |
64 | | - "output": "test_main.o" |
65 | | - } |
66 | | -]""" % (sys.executable, test.workdir) |
67 | 80 |
|
68 | | -if sys.platform == 'win32': |
69 | | - example_rel_file = example_rel_file.replace('\\', '\\\\') |
| 81 | +example_rel_file = get_db(test.workdir, False, []) |
70 | 82 |
|
71 | 83 | for f in rel_files: |
72 | 84 | # print("Checking:%s" % f) |
73 | 85 | test.must_exist(f) |
74 | 86 | test.must_match(f, example_rel_file, mode='r') |
75 | 87 |
|
76 | | -example_abs_file = """[ |
77 | | - { |
78 | | - "command": "%s mygcc.py cc -o test_main.o -c test_main.c", |
79 | | - "directory": "%s", |
80 | | - "file": "%s", |
81 | | - "output": "%s" |
82 | | - } |
83 | | -]""" % (sys.executable, test.workdir, os.path.join(test.workdir, 'test_main.c'), os.path.join(test.workdir, 'test_main.o')) |
84 | 88 |
|
85 | | -if sys.platform == 'win32': |
86 | | - example_abs_file = example_abs_file.replace('\\', '\\\\') |
| 89 | +example_abs_file = get_db(test.workdir, True, []) |
| 90 | + |
| 91 | +for f in abs_files: |
| 92 | + test.must_exist(f) |
| 93 | + test.must_match(f, example_abs_file, mode='r') |
| 94 | + |
| 95 | + |
| 96 | +test.run(arguments='CCFLAGS=-g') |
| 97 | + |
| 98 | +example_rel_file = get_db(test.workdir, False, ['-g']) |
| 99 | + |
| 100 | +for f in rel_files: |
| 101 | + test.must_exist(f) |
| 102 | + test.must_match(f, example_rel_file, mode='r') |
| 103 | + |
87 | 104 |
|
| 105 | +example_abs_file = get_db(test.workdir, True, ['-g']) |
88 | 106 |
|
89 | 107 | for f in abs_files: |
90 | 108 | test.must_exist(f) |
|
0 commit comments