kit_skip.sh (2208B)
1 # test/lib/kit_skip.sh — unified skip detection for the corpus harness. 2 # 3 # Sourced (POSIX sh). Three independent skip sources the corpus runners all 4 # reimplemented; each returns 0 and echoes a reason when it fires, else 1. 5 6 # kit_skip_sidecar DIR BASE [ARCH] [LANE] 7 # Looks, in priority order, for sidecar files next to a case: 8 # DIR/BASE.skip — skip the whole case on every arch/lane 9 # DIR/BASE.<ARCH>.skip — skip on this arch (when ARCH given) 10 # DIR/BASE.<LANE>.skip — skip just this lane (when LANE given; covers 11 # .cbackend.skip via LANE=cbackend, .wasm.skip 12 # via LANE=wasm, toy's .link.skip via LANE=link) 13 # Echoes the first line of the matching sidecar as the reason. 14 kit_skip_sidecar() { 15 kit_sk_dir=$1; kit_sk_base=$2; kit_sk_arch=${3:-}; kit_sk_lane=${4:-} 16 for kit_sk_f in \ 17 "$kit_sk_dir/$kit_sk_base.skip" \ 18 ${kit_sk_arch:+"$kit_sk_dir/$kit_sk_base.$kit_sk_arch.skip"} \ 19 ${kit_sk_lane:+"$kit_sk_dir/$kit_sk_base.$kit_sk_lane.skip"}; do 20 if [ -e "$kit_sk_f" ]; then 21 head -n1 "$kit_sk_f" 2>/dev/null 22 return 0 23 fi 24 done 25 return 1 26 } 27 28 # kit_skip_diag ERRFILE REGEX 29 # Phased-rollout detector: if ERRFILE contains a line matching the extended 30 # regex REGEX (a backend's "not yet implemented" diagnostic), echo the 31 # matched text as the reason and return 0. Each backend passes its own regex 32 # (e.g. 'interp: .*not supported', 'C target: .*not (implemented|yet supported)', 33 # 'wasm.*not yet implemented'), keeping the panic format local to its lane. 34 kit_skip_diag() { 35 [ -f "$1" ] || return 1 36 kit_sd_hit=$(grep -oE "$2" "$1" 2>/dev/null | head -n1 || true) 37 [ -n "$kit_sd_hit" ] || return 1 38 printf '%s' "$kit_sd_hit" 39 return 0 40 } 41 42 # kit_tuple_applicable TUPLE TARGETS_FILE 43 # Returns 0 (applicable) if TARGETS_FILE is absent/empty, or lists TUPLE 44 # (whitespace-separated <arch>-<obj> tuples). Returns 1 (not applicable -> 45 # caller emits SKIP_NA) when the file exists and does NOT list TUPLE. 46 kit_tuple_applicable() { 47 [ -s "$2" ] || return 0 48 for kit_ta_t in $(cat "$2"); do 49 [ "$kit_ta_t" = "$1" ] && return 0 50 done 51 return 1 52 }