Add testing for C decl source range extraction#1622
Add testing for C decl source range extraction#1622fw-immunant wants to merge 5 commits intofw/c-decls-ifdefsfrom
Conversation
| c2rust_transpile::create_temp_compile_commands(&[c_path.to_owned()]); | ||
| c2rust_transpile::transpile( | ||
| TranspilerConfig { | ||
| emit_c_decl_map: true, |
There was a problem hiding this comment.
Can we just enable this for everything in fn config? And then refactor the non-snapshot part of fn transpile/fn transpile_snapshot into a shared function, because they're basically both the same except for the end that does the snapshot testing.
There was a problem hiding this comment.
I've factored out the shared code, but setting emit_c_decls_json for all snapshots generates a bunch of irrelevant output files, so I think it's better to only set it when we actually want that output.
There was a problem hiding this comment.
What's wrong with some extra .gitignored output files? This adds some more testing at what is IMO negligible cost (some extra ignored files).
491e9d4 to
3002afd
Compare
otherwise, multiple threads invoking `ast_exporter` at once (e.g. separate #[test]s) cause various kinds of segfaults/aborts
34ba77c to
e423fc6
Compare
| } | ||
|
|
||
| extern "C" { | ||
| // Safety: Not thread-safe; must not be called multiple times concurrently. |
There was a problem hiding this comment.
| // Safety: Not thread-safe; must not be called multiple times concurrently. | |
| /// # Safety | |
| /// | |
| /// Not thread-safe; must not be called multiple times concurrently. |
| anotherfunc(void) | ||
| { | ||
| int var = 0; | ||
| return 4 + var; | ||
| } | ||
| int | ||
| funcholdingdefine(void) | ||
| { | ||
| #define FOO 4000+50 | ||
| return FOO; | ||
| } | ||
| // comment before multiple decl | ||
| int a1, a2, a3; | ||
| void forwarddeclbeforeotherdef(int x); | ||
| void funcafterdecl(int n) {} | ||
| /*real defn*/ | ||
| void forwarddeclbeforeotherdef(int x) { } |
There was a problem hiding this comment.
| anotherfunc(void) | |
| { | |
| int var = 0; | |
| return 4 + var; | |
| } | |
| int | |
| funcholdingdefine(void) | |
| { | |
| #define FOO 4000+50 | |
| return FOO; | |
| } | |
| // comment before multiple decl | |
| int a1, a2, a3; | |
| void forwarddeclbeforeotherdef(int x); | |
| void funcafterdecl(int n) {} | |
| /*real defn*/ | |
| void forwarddeclbeforeotherdef(int x) { } | |
| another_func(void) | |
| { | |
| int var = 0; | |
| return 4 + var; | |
| } | |
| int | |
| func_holding_define(void) | |
| { | |
| #define FOO 4000+50 | |
| return FOO; | |
| } | |
| // comment before multiple decl | |
| int a1, a2, a3; | |
| void forward_decl_before_other_def(int x); | |
| void func_after_decl(int n) {} | |
| /*real defn*/ | |
| void forward_decl_before_other_def(int x) { } |
Was there a reason these names didn't have separators? It's pretty hard to read without them.
Includes some other minor cleanups made on the way.