This commit is contained in:
1 parent
6d1c68994c
commit
4cf50a0b9c
40 files changed
+2767
-430
No files matched your search
+54
-9
@@ -40,11 +40,16 @@ done
|
||||
[ -x "$lucisv" ] || { echo "no lucisv binary at $lucisv (cargo build --release?)" >&2; exit 2; }
|
||||
[ -d "$corpus_dir" ] || { echo "no corpus at $corpus_dir (tools/corpus_fetch.sh?)" >&2; exit 2; }
|
||||
|
||||
use_json=0
|
||||
if command -v jq >/dev/null 2>&1; then
|
||||
use_json=1
|
||||
fi
|
||||
|
||||
# --- per-file classification --------------------------------------------------
|
||||
|
||||
# classify FILE LINE MESSAGE -> category name on stdout.
|
||||
# classify FILE LINE MESSAGE [CATEGORY] -> category name on stdout.
|
||||
classify() {
|
||||
file=$1 line=$2 msg=$3
|
||||
file=$1 line=$2 msg=$3 err_cat=${4:-}
|
||||
src=
|
||||
if [ -n "$line" ] && [ "$line" -gt 0 ] 2>/dev/null; then
|
||||
src=$(sed -n "${line}p" "$file" 2>/dev/null || true)
|
||||
@@ -56,12 +61,21 @@ classify() {
|
||||
ctx="$(sed -n "$((line - 1))p" "$file" 2>/dev/null || true) $src"
|
||||
fi
|
||||
|
||||
case $err_cat in
|
||||
verification-error) echo verification-error; return ;;
|
||||
esac
|
||||
case $msg in
|
||||
*"verification failed"*) echo verification-error; return ;;
|
||||
esac
|
||||
case $file in
|
||||
*.tpl.sv) echo not-verilog; return ;;
|
||||
esac
|
||||
if [ "$err_cat" = "lex-error" ]; then
|
||||
case $ctx in
|
||||
*"'h\`"*|*"'d\`"*|*"'b\`"*|*"'o\`"*) echo lex-macro-number; return ;;
|
||||
esac
|
||||
echo lex-error; return
|
||||
fi
|
||||
case $msg in
|
||||
*"keyword \`interface\`"*|*"keyword \`default\`"*|*"keyword \`clocking\`"*) echo interface; return ;;
|
||||
*"(found \"virtual\")"*) echo interface; return ;;
|
||||
@@ -129,7 +143,11 @@ classify() {
|
||||
check_one() {
|
||||
file=$1
|
||||
status=0
|
||||
out=$("$lucisv" --no-cache --check "$file" 2>&1) || status=$?
|
||||
if [ "$use_json" -eq 1 ]; then
|
||||
out=$("$lucisv" --no-cache --check --output-format json "$file" 2>/dev/null) || status=$?
|
||||
else
|
||||
out=$("$lucisv" --no-cache --check "$file" 2>&1) || status=$?
|
||||
fi
|
||||
case $status in
|
||||
0|1)
|
||||
lstatus=0
|
||||
@@ -142,12 +160,39 @@ check_one() {
|
||||
esac
|
||||
;;
|
||||
2)
|
||||
msg=$(printf '%s\n' "$out" | grep '^error: ' | head -1)
|
||||
msg=${msg#error: }
|
||||
msg=${msg#"$file": }
|
||||
err_cat=
|
||||
line=
|
||||
msg=
|
||||
if [ "$use_json" -eq 1 ] && [ -n "$out" ]; then
|
||||
parsed=$(printf '%s\n' "$out" | jq -r '.files[0].error // {} | [(.category // ""), ((.line // "") | tostring), ((.column // "") | tostring), ((.message // "") | gsub("[\t\r\n]"; " "))] | "\(.[0])\n\(.[1])\n\(.[2])\n\(.[3])"' 2>/dev/null || true)
|
||||
if [ -n "$parsed" ]; then
|
||||
{
|
||||
IFS= read -r err_cat
|
||||
IFS= read -r line
|
||||
IFS= read -r col
|
||||
IFS= read -r raw_msg
|
||||
} <<EOF
|
||||
$parsed
|
||||
EOF
|
||||
case $err_cat in
|
||||
parse-error) msg="parse error: ${line}:${col}: ${raw_msg}" ;;
|
||||
lex-error) msg="lex error: ${line}:${col}: ${raw_msg}" ;;
|
||||
*) msg=$raw_msg ;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
if [ -z "$msg" ]; then
|
||||
if [ "$use_json" -eq 1 ]; then
|
||||
out=$("$lucisv" --no-cache --check "$file" 2>&1 || true)
|
||||
fi
|
||||
msg=$(printf '%s\n' "$out" | grep '^error: ' | head -1)
|
||||
msg=${msg#error: }
|
||||
msg=${msg#"$file": }
|
||||
msg=$(printf '%s' "$msg" | tr '\t\n' ' ')
|
||||
line=$(printf '%s' "$msg" | sed -n 's/^[a-z]* error: \([0-9][0-9]*\):.*/\1/p')
|
||||
fi
|
||||
msg=$(printf '%s' "$msg" | tr '\t\n' ' ')
|
||||
line=$(printf '%s' "$msg" | sed -n 's/^[a-z]* error: \([0-9][0-9]*\):.*/\1/p')
|
||||
cat=$(classify "$file" "${line:-0}" "$msg")
|
||||
cat=$(classify "$file" "${line:-0}" "$msg" "$err_cat")
|
||||
printf 'fail\t%s\t%s\t%s\n' "$cat" "$file" "$msg"
|
||||
;;
|
||||
*)
|
||||
@@ -157,7 +202,7 @@ check_one() {
|
||||
}
|
||||
|
||||
export -f classify check_one
|
||||
export lucisv
|
||||
export lucisv use_json
|
||||
|
||||
tmp=$(mktemp)
|
||||
trap 'rm -f "$tmp"' EXIT
|
||||
|
||||
Reference in new issue
Block a user