Skip to content

Commit 1080fe9

Browse files
committed
probe: print control characters, add the workflow
1 parent 12011a0 commit 1080fe9

2 files changed

Lines changed: 29 additions & 15 deletions

File tree

‎.github/probe/655-readings.sh‎

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# fails the compile and must not take the others with it.
66
set +e
77
M="${MCPP:?}"
8+
PY=$(command -v python3 || command -v python)
89
ROOT="$(mktemp -d)"
910
reading() { echo "READING $*"; echo "- \`$*\`" >> "${GITHUB_STEP_SUMMARY:-/dev/null}"; }
1011
case_one() {
@@ -17,7 +18,10 @@ case_one() {
1718
#define STR(...) STR2(__VA_ARGS__)
1819
int main() {
1920
#ifdef V
20-
std::printf("V=[%s]\n", STR(V));
21+
std::printf("V=[");
22+
for (const char* c = STR(V); *c; ++c)
23+
if (*c >= 0x20 && *c < 0x7f) std::putchar(*c); else std::printf("<%02x>", (unsigned char)*c);
24+
std::printf("]\n");
2125
#else
2226
std::printf("V undefined\n");
2327
#endif
@@ -33,24 +37,11 @@ CPP
3337
cdb=$(find "$d" -name compile_commands.json | head -1)
3438
args=""
3539
if [ -n "$cdb" ]; then
36-
args=$(python3 - "$cdb" <<'PY' 2>/dev/null || python - "$cdb" <<'PY2'
37-
import json,sys
38-
e=json.load(open(sys.argv[1]))
39-
a=[x for x in e[0]["arguments"] if "V=" in x or x.startswith(("-DV","/DV"))]
40-
i=e[0]["arguments"].index(a[0]) if a else -1
41-
print(json.dumps(e[0]["arguments"][i:i+2] if a else []))
42-
PY
43-
import json,sys
44-
e=json.load(open(sys.argv[1]))
45-
a=[x for x in e[0]["arguments"] if "V=" in x]
46-
print(json.dumps(a))
47-
PY2
48-
)
40+
args=$("$PY" -c 'import json,sys; a=json.load(open(sys.argv[1]))[0]["arguments"]; i=[k for k,x in enumerate(a) if "V=" in x]; print(json.dumps(a[i[0]:i[0]+2]) if i else "[]")' "$cdb")
4941
fi
5042
reading "$RUNNER_OS $id $channel $element => build: $v | cdb: $args"
5143
}
5244
"$M" --version
53-
case_one esc cflags '"-DV=\\\"esc.h\\\""'
5445
case_one esc_cxx cxxflags '"-DV=\\\"esc.h\\\""'
5546
case_one mid cxxflags '"-DV=\"mid\""'
5647
case_one sq cxxflags "\"-DV='sq'\""

‎.github/workflows/verify-655.yml‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: verify-655
2+
on:
3+
pull_request:
4+
branches: [ main ]
5+
jobs:
6+
readings:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
os: [ubuntu-24.04, macos-15, windows-latest]
11+
runs-on: ${{ matrix.os }}
12+
timeout-minutes: 60
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: ./.github/actions/bootstrap-mcpp
16+
with:
17+
cache-target: 'false'
18+
- name: readings
19+
shell: bash
20+
timeout-minutes: 40
21+
run: |
22+
export MCPP_VENDORED_XLINGS="$XLINGS_BIN"
23+
bash .github/probe/655-readings.sh

0 commit comments

Comments
 (0)