mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-08 13:14:56 +00:00
tools/test-all.sh: Reimplement in golang
Makes future development easier. New features: * A more compact and cleaner results view * Concurrent testing, much quicker across multiple cores * Supports comparing output against an expected file, including a text diff of differences. Also has a flag for updating the expected outputs * Advanced file-globbing support, including scanning for files in subdirectories * Skip lists are now no longer hidden away in the tool, but defined as a SKIP header in the *.expected.* file Change-Id: I4fac80bb084a720ec9a307b4acf9f73792973a1d Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50903 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
72f6ba4efe
commit
57b2a06ba7
1
test/bug_tint_749.spvasm.expected.hlsl
Normal file
1
test/bug_tint_749.spvasm.expected.hlsl
Normal file
@@ -0,0 +1 @@
|
||||
SKIP: TINT_UNIMPLEMENTED crbug.com/tint/726: module-scope private and workgroup variables not yet implemented
|
||||
1
test/bug_tint_749.spvasm.expected.msl
Normal file
1
test/bug_tint_749.spvasm.expected.msl
Normal file
@@ -0,0 +1 @@
|
||||
SKIP: TINT_UNIMPLEMENTED crbug.com/tint/726: module-scope private and workgroup variables not yet implemented
|
||||
5
test/bug_tint_749.spvasm.expected.spvasm
Normal file
5
test/bug_tint_749.spvasm.expected.spvasm
Normal file
@@ -0,0 +1,5 @@
|
||||
SKIP:
|
||||
|
||||
Validation Failure:
|
||||
1:1: OpLoad Pointer <id> '51[%51]' is not a logical pointer.
|
||||
%52 = OpLoad %int %51
|
||||
159
test/test-all.sh
159
test/test-all.sh
@@ -16,33 +16,18 @@
|
||||
|
||||
set -e # Fail on any error.
|
||||
|
||||
TEXT_YELLOW="\033[0;33m"
|
||||
TEXT_GREEN="\033[0;32m"
|
||||
TEXT_RED="\033[0;31m"
|
||||
TEXT_DEFAULT="\033[0m"
|
||||
|
||||
CHECK_WGSL=1
|
||||
CHECK_SPV=1
|
||||
CHECK_MSL=1
|
||||
CHECK_HLSL=1
|
||||
|
||||
TINT="$1"
|
||||
ONLY_FORMAT="$2"
|
||||
TARGETDIR="$3"
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
function usage() {
|
||||
echo "test-all.sh uses tint to compile .wgsl and .spvasm files, reporting errors as test failures."
|
||||
echo "test-all.sh is a simple wrapper around <tint>/tools/test-runner that"
|
||||
echo "injects the <tint>/tools directory as the second command line argument"
|
||||
echo
|
||||
echo "Usage: test-all.sh <path-to-tint-executable> [<only-format> [directory]]"
|
||||
echo
|
||||
echo "<only-format> specifies which output format is tested."
|
||||
echo " Possible values are: all, wgsl, spv, msl, hlsl."
|
||||
echo " The default is 'all'."
|
||||
echo
|
||||
echo "[directory] specifies which directory holds the source files"
|
||||
echo " The default is to use the script directory."
|
||||
echo "Usage of <tint>/tools/test-runner:"
|
||||
SCRIPT_DIR/../tools/test-runner --help
|
||||
}
|
||||
|
||||
TINT="$1"
|
||||
|
||||
if [ -z "$TINT" ]; then
|
||||
echo "error: missing argument: location of the 'tint' executable"
|
||||
echo
|
||||
@@ -56,132 +41,4 @@ if [ ! -x "$TINT" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "$ONLY_FORMAT" ]; then
|
||||
case "${ONLY_FORMAT}" in
|
||||
all)
|
||||
;;
|
||||
wgsl)
|
||||
CHECK_WGSL=1
|
||||
CHECK_SPV=0
|
||||
CHECK_MSL=0
|
||||
CHECK_HLSL=0
|
||||
;;
|
||||
spv)
|
||||
CHECK_WGSL=0
|
||||
CHECK_SPV=1
|
||||
CHECK_MSL=0
|
||||
CHECK_HLSL=0
|
||||
;;
|
||||
msl)
|
||||
CHECK_WGSL=0
|
||||
CHECK_SPV=0
|
||||
CHECK_MSL=1
|
||||
CHECK_HLSL=0
|
||||
;;
|
||||
hlsl)
|
||||
CHECK_WGSL=0
|
||||
CHECK_SPV=0
|
||||
CHECK_MSL=0
|
||||
CHECK_HLSL=1
|
||||
;;
|
||||
*)
|
||||
echo "error: invalid format argument: $ONLY_FORMAT"
|
||||
echo
|
||||
usage
|
||||
exit 1
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ -n "$4" ]; then
|
||||
echo "error: Too many arguments"
|
||||
echo
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
# If no subdirectory was specified, look in the script directory.
|
||||
if [ -z "${TARGETDIR}" ]; then
|
||||
TARGETDIR="${SCRIPT_DIR}"
|
||||
fi
|
||||
|
||||
if [ ! -d "${TARGETDIR}" ]; then
|
||||
echo "error: ${TARGETDIR} is not a directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NUM_PASS=0
|
||||
NUM_SKIP=0
|
||||
NUM_FAIL=0
|
||||
|
||||
SKIPPED=""
|
||||
SKIPPED+="msl:bug_tint_749.spvasm" # TINT_UNIMPLEMENTED crbug.com/tint/726: module-scope private and workgroup variables not yet implemented
|
||||
SKIPPED+="hlsl:bug_tint_749.spvasm" # Failed to generate: error: pointers not supported in HLSL
|
||||
|
||||
# should_skip(TEST_FILE, FORMAT)
|
||||
function should_skip() {
|
||||
local TEST="$1-$2"
|
||||
if [[ "$TEST" == "bug_tint_749.spvasm-msl" ]]; then
|
||||
echo 1
|
||||
return
|
||||
fi
|
||||
echo 0
|
||||
return
|
||||
}
|
||||
|
||||
# check(TEST_FILE, FORMAT)
|
||||
function check() {
|
||||
local TEST_FILE="$1"
|
||||
local FORMAT=$2
|
||||
SKIP=
|
||||
|
||||
TEST_FILE_WITHOUT_DIR=$(basename ${TEST_FILE})
|
||||
if [[ $SKIPPED == *"${FORMAT}:${TEST_FILE_WITHOUT_DIR}"* ]]; then
|
||||
SKIP=1
|
||||
fi
|
||||
|
||||
printf "%7s: " "${FORMAT}"
|
||||
if [[ -n "$SKIP" ]]; then
|
||||
echo -e "${TEXT_YELLOW}SKIPPED${TEXT_DEFAULT}"
|
||||
NUM_SKIP=$((${NUM_SKIP}+1))
|
||||
return
|
||||
fi
|
||||
set +e
|
||||
"${TINT}" ${TEST_FILE} --format ${FORMAT} -o /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${TEXT_GREEN}PASS${TEXT_DEFAULT}"
|
||||
NUM_PASS=$((${NUM_PASS}+1))
|
||||
else
|
||||
echo -e "${TEXT_RED}FAIL${TEXT_DEFAULT}"
|
||||
NUM_FAIL=$((${NUM_FAIL}+1))
|
||||
fi
|
||||
set -e
|
||||
}
|
||||
|
||||
# check_formats(TEST_FILE)
|
||||
function check_formats() {
|
||||
local TEST_FILE=$1
|
||||
echo
|
||||
echo "Testing ${TEST_FILE}..."
|
||||
[ ${CHECK_WGSL} -eq 0 ] || check "${TEST_FILE}" wgsl
|
||||
[ ${CHECK_SPV} -eq 0 ] || check "${TEST_FILE}" spirv
|
||||
[ ${CHECK_MSL} -eq 0 ] || check "${TEST_FILE}" msl
|
||||
[ ${CHECK_HLSL} -eq 0 ] || check "${TEST_FILE}" hlsl
|
||||
}
|
||||
|
||||
for F in "${TARGETDIR}"/*.spvasm "${TARGETDIR}"/*.wgsl
|
||||
do
|
||||
check_formats "$F"
|
||||
done
|
||||
|
||||
if [ ${NUM_FAIL} -ne 0 ]; then
|
||||
echo
|
||||
echo -e "${TEXT_RED}${NUM_FAIL} tests failed. ${TEXT_DEFAULT}${NUM_SKIP} skipped. ${NUM_PASS} passed.${TEXT_DEFAULT}"
|
||||
echo
|
||||
exit 1
|
||||
else
|
||||
echo
|
||||
echo -e "${NUM_SKIP} tests skipped. ${TEXT_GREEN}${NUM_PASS} passed.${TEXT_DEFAULT}"
|
||||
echo
|
||||
fi
|
||||
"${SCRIPT_DIR}/../tools/test-runner" ${@:2} "${TINT}" "${SCRIPT_DIR}"
|
||||
|
||||
Reference in New Issue
Block a user