Skip to content

Commit

Permalink
Add unit test for cc.preprocess()
Browse files Browse the repository at this point in the history
  • Loading branch information
xclaesse committed Oct 23, 2022
1 parent 42a7f8e commit 1d56df9
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test cases/common/255 preprocess/bar.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int bar(void) {
return BAR;
}
1 change: 1 addition & 0 deletions test cases/common/255 preprocess/foo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <foo.h>
2 changes: 2 additions & 0 deletions test cases/common/255 preprocess/foo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
int bar(void);
int main(void) { return FOO + bar(); }
15 changes: 15 additions & 0 deletions test cases/common/255 preprocess/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
project('preprocess', 'c')

cc = meson.get_compiler('c')

add_project_arguments(['-DFOO=0', '-DBAR=0'], language: 'c')

pp_files = cc.preprocess('foo.c', 'bar.c', output: '@PLAINNAME@')

foreach f : pp_files
message(f.full_path())
endforeach

subdir('src')

test('test-foo', executable('app', pp_files, link_depends: file_map))
3 changes: 3 additions & 0 deletions test cases/common/255 preprocess/src/file.map.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#if 1
Hello World
#endif
4 changes: 4 additions & 0 deletions test cases/common/255 preprocess/src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
file_map = cc.preprocess('file.map.in',
output: '@BASENAME@',
compile_args: ['-x', 'assembler-with-cpp'],
)

0 comments on commit 1d56df9

Please sign in to comment.