11#! /bin/bash
2- # Generate uniast for all testdata. Must be run from repo root
2+ # Generate uniast for all testdata.
33#
44# USAGE:
55# 1. Save the uniast to out/
1111# 3. Use a custom abcoder executable
1212# OUTDIR=out/ ABCEXE="./other_abcoder" ./script/run_testdata.sh
1313
14- ABCEXE=${ABCEXE:- ./ abcoder}
14+ SCRIPT_DIR=$( dirname " $( readlink -f " $0 " ) " )
15+ REPO_ROOT=$( realpath --relative-to=$( pwd) " $SCRIPT_DIR /.." )
16+
17+ ABCEXE=${ABCEXE:- " $REPO_ROOT /abcoder" }
1518OUTDIR=${OUTDIR:? Error: OUTDIR is a mandatory environment variable}
1619PARALLEL_FLAGS=${PARALLEL_FLAGS:- --tag}
1720
@@ -20,18 +23,19 @@ LANGS=(go rust python cxx)
2023detect_jobs () {
2124 local ABCEXE=${1:- $ABCEXE }
2225 for lang in ${LANGS[@]} ; do
23- for repo in testdata/$lang /* ; do
24- outname=$( echo $repo | sed ' s/^testdata\///; s/[/:? ]/_/g' )
26+ for repo in " $REPO_ROOT /testdata/$lang " /* ; do
27+ local rel_path=$( realpath --relative-to=" $REPO_ROOT /testdata" " $repo " )
28+ local outname=$( echo " $rel_path " | sed ' s/[/:? ]/_/g' )
2529 echo $ABCEXE parse $lang $repo -o $OUTDIR /$outname .json
2630 done
2731 done
2832}
2933
3034if [[ ! -x " $ABCEXE " ]]; then
31- echo " Error: The specified abcoder executable '$ABCEXE ' does not exist or is not executable." >&2
32- exit 1
35+ echo " Error: The specified abcoder executable '$ABCEXE ' does not exist or is not executable." >&2
36+ exit 1
3337fi
3438mkdir -pv " $OUTDIR "
35- detect_jobs | parallel $PARALLEL_FLAGS echo {}
39+ detect_jobs
3640echo
3741detect_jobs | parallel $PARALLEL_FLAGS -j$( nproc --all) --jobs 0 " eval {}" 2>&1
0 commit comments