Get logging flags working properly with test script
This commit is contained in:
parent
b1fa49448d
commit
5c3c1dd0bd
19 changed files with 140 additions and 225 deletions
|
|
@ -1,7 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
rm -rf \
|
||||
build out \
|
||||
gyp-mac-tool \
|
||||
Makefile *.Makefile *.target.mk \
|
||||
*.xcodeproj
|
||||
7
script/configure
vendored
7
script/configure
vendored
|
|
@ -1,7 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
git submodule update --init --recursive
|
||||
externals/gyp/gyp project.gyp --depth . --format=make $@
|
||||
externals/gyp/gyp tests.gyp --depth . --format=make $@
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
git submodule update --init --recursive
|
||||
call .\externals\gyp\gyp.bat project.gyp --depth .
|
||||
call .\externals\gyp\gyp.bat tests.gyp --depth .
|
||||
139
script/test
139
script/test
|
|
@ -12,150 +12,53 @@ OPTIONS
|
|||
|
||||
-h print this message
|
||||
|
||||
-b run make under scan-build static analyzer
|
||||
-a Compile C code with the Clang static analyzer
|
||||
|
||||
-d run tests in a debugger (either lldb or gdb)
|
||||
-l run only the corpus tests for the given language
|
||||
|
||||
-g run tests with valgrind's memcheck tool
|
||||
|
||||
-G run tests with valgrind's memcheck tool, including a full leak check
|
||||
|
||||
-v run tests with verbose output
|
||||
|
||||
-f run only tests whose description contain the given string
|
||||
-e run only the corpus tests whose name contain the given string
|
||||
|
||||
-s set the seed used to control random behavior
|
||||
|
||||
-d print parsing log to stderr
|
||||
|
||||
-D pipe tests' stderr to \`dot(1)\` to render an SVG log
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
profile=
|
||||
leak_check=no
|
||||
mode=normal
|
||||
verbose=
|
||||
args=()
|
||||
target=tests
|
||||
export BUILDTYPE=Test
|
||||
cmd="out/${BUILDTYPE}/${target}"
|
||||
run_scan_build=
|
||||
export TREE_SITTER_TEST=1
|
||||
export RUST_TEST_THREADS=1
|
||||
export RUST_BACKTRACE=full
|
||||
|
||||
if [ "$(uname -s)" == "Darwin" ]; then
|
||||
export LINK="clang++ -fsanitize=address"
|
||||
fi
|
||||
|
||||
while getopts "bdf:s:gGhpvD" option; do
|
||||
while getopts "bdl:e:s:gGhpvD" option; do
|
||||
case ${option} in
|
||||
h)
|
||||
usage
|
||||
exit
|
||||
;;
|
||||
d)
|
||||
mode=debug
|
||||
l)
|
||||
export TREE_SITTER_TEST_LANGUAGE_FILTER=${OPTARG}
|
||||
;;
|
||||
g)
|
||||
mode=valgrind
|
||||
;;
|
||||
G)
|
||||
mode=valgrind
|
||||
leak_check=full
|
||||
;;
|
||||
p)
|
||||
profile=true
|
||||
;;
|
||||
f)
|
||||
args+=("--only=${OPTARG}")
|
||||
;;
|
||||
v)
|
||||
verbose=true
|
||||
e)
|
||||
export TREE_SITTER_TEST_EXAMPLE_FILTER=${OPTARG}
|
||||
;;
|
||||
s)
|
||||
export TREE_SITTER_SEED=${OPTARG}
|
||||
;;
|
||||
D)
|
||||
export TREE_SITTER_ENABLE_DEBUG_GRAPHS=1
|
||||
mode=SVG
|
||||
d)
|
||||
export TREE_SITTER_ENABLE_LOG=1
|
||||
;;
|
||||
b)
|
||||
run_scan_build=true
|
||||
D)
|
||||
export TREE_SITTER_ENABLE_LOG_GRAPHS=1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -n $verbose ]]; then
|
||||
args+=("--reporter=spec")
|
||||
if [[ -n $TREE_SITTER_TEST_LANGUAGE_FILTER || -n $TREE_SITTER_TEST_EXAMPLE_FILTER ]]; then
|
||||
top_level_filter=corpus
|
||||
else
|
||||
args+=("--reporter=singleline")
|
||||
top_level_filter=$1
|
||||
fi
|
||||
|
||||
if [[ -n "$run_scan_build" ]]; then
|
||||
. script/util/scan-build.sh
|
||||
scan_build make -j2 $target
|
||||
else
|
||||
make -j2 $target
|
||||
fi
|
||||
args=${args:-""}
|
||||
|
||||
if [[ -n $profile ]]; then
|
||||
export CPUPROFILE=/tmp/${target}-$(date '+%s').prof
|
||||
fi
|
||||
|
||||
case ${mode} in
|
||||
valgrind)
|
||||
valgrind \
|
||||
--suppressions=./script/util/valgrind.supp \
|
||||
--dsymutil=yes \
|
||||
--leak-check=${leak_check} \
|
||||
$cmd "${args[@]}" 2>&1 | \
|
||||
grep --color -E '\w+_tests?.cc:\d+|$'
|
||||
;;
|
||||
|
||||
debug)
|
||||
if hash lldb &> /dev/null; then
|
||||
lldb $cmd -- "${args[@]}"
|
||||
elif hash gdb &> /dev/null; then
|
||||
gdb $cmd -- "${args[@]}"
|
||||
else
|
||||
echo "No debugger found"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
SVG)
|
||||
html_file=log.html
|
||||
dot_file=$html_file.dot
|
||||
|
||||
function write_log_file {
|
||||
echo "<!DOCTYPE html><style>svg { width: 100%; margin-bottom: 20px; }</style>" > $html_file
|
||||
line_count=$(grep -n '^$' $dot_file | tail -1 | cut -f1 -d:)
|
||||
if [[ -n $line_count ]]; then
|
||||
head -n $line_count $dot_file | dot -Tsvg >> $html_file
|
||||
else
|
||||
cat $dot_file | grep -v 'Assertion' | dot -Tsvg >> $html_file
|
||||
fi
|
||||
rm $dot_file
|
||||
echo "Wrote $html_file - $line_count"
|
||||
}
|
||||
|
||||
function handle_sigint {
|
||||
trap '' SIGINT
|
||||
echo
|
||||
write_log_file
|
||||
exit 0
|
||||
}
|
||||
trap handle_sigint SIGINT
|
||||
|
||||
$cmd "${args[@]}" 2> $dot_file || export status=$?
|
||||
write_log_file
|
||||
exit $status
|
||||
;;
|
||||
|
||||
normal)
|
||||
time $cmd "${args[@]}"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ -n $profile ]]; then
|
||||
pprof $cmd $CPUPROFILE
|
||||
fi
|
||||
cargo test --jobs 1 $top_level_filter -- --nocapture
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
@echo off
|
||||
msbuild /p:Configuration=Test tests.vcxproj
|
||||
|
||||
set only_arg=
|
||||
IF not "%~1"=="" (
|
||||
set only_arg=--only=%1
|
||||
)
|
||||
set TREE_SITTER_TEST=1
|
||||
set RUST_TEST_THREADS=1
|
||||
set RUST_BACKTRACE=full
|
||||
|
||||
.\test\tests.exe --reporter=singleline --no-color %only_arg%
|
||||
cargo test "%~1"
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
RUST_TREE_SITTER_TEST=1 cargo test $@
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
find src test include -type f | xargs perl -pi -e 's/ +$//'
|
||||
Loading…
Add table
Add a link
Reference in a new issue