|
| 1 | +// Regression test for a bug in which 3C didn't escape backslashes in file paths |
| 2 | +// in its JSON output |
| 3 | +// (https://github.com/correctcomputation/checkedc-clang/issues/619). On |
| 4 | +// Windows, file paths contain backslashes as the directory separator, so the |
| 5 | +// main json_formatting.c test would catch the bug. This test catches the bug on |
| 6 | +// Linux and Mac OS X by manually creating a file with a backslash in the name |
| 7 | +// (which is an ordinary filename character on these OSes). |
| 8 | + |
| 9 | +// UNSUPPORTED: system-windows |
| 10 | + |
| 11 | +// We reuse json_formatting.c to ensure that we test all the same code |
| 12 | +// constructs, but we `#include` it instead of running 3c on it directly because |
| 13 | +// some code used by 3c seems to be messing with backslashes in file names on |
| 14 | +// the command line. The `#include` seems to preserve the backslash. (This is an |
| 15 | +// unusual case, so it wouldn't be surprising if 3c's behavior changes at some |
| 16 | +// point and this test breaks and we have to redesign it.) |
| 17 | + |
| 18 | +// RUN: rm -rf %t* |
| 19 | + |
| 20 | +// RUN: mkdir %t.alltypes && cd %t.alltypes |
| 21 | +// RUN: cp %s . |
| 22 | +// RUN: cp %S/json_formatting.c 'json\_formatting.h' |
| 23 | +// RUN: 3c -alltypes -dump-stats -dump-intermediate -debug-solver -output-dir=out.checked json_formatting_backslash.c -- |
| 24 | +// RUN: python -c "import json, glob; [json.load(open(f)) for f in glob.glob('*.json')]" |
| 25 | + |
| 26 | +// RUN: mkdir %t.noalltypes && cd %t.noalltypes |
| 27 | +// RUN: cp %s . |
| 28 | +// RUN: cp %S/json_formatting.c 'json\_formatting.h' |
| 29 | +// RUN: 3c -dump-stats -dump-intermediate -debug-solver -output-dir=out.checked json_formatting_backslash.c -- |
| 30 | +// RUN: python -c "import json, glob; [json.load(open(f)) for f in glob.glob('*.json')]" |
| 31 | + |
| 32 | +// Even though this looks like a double-quoted string, the Checked C compiler |
| 33 | +// seems to require the backslash to _not_ be escaped. We choose `\_` because it |
| 34 | +// is not a valid escape sequence in a JSON string literal (see |
| 35 | +// https://www.json.org/). |
| 36 | +#include "json\_formatting.h" |
0 commit comments