forked from skiplang/skip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·64 lines (57 loc) · 1.93 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash -e
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
dir=$(dirname "$0")
if [[ $BACKEND == "" ]]; then
BACKEND="native"
fi
FILES=$(cd $dir; find . \! \( \( -path ./build -o -path ./native -o -path ./.git \) -prune \) -not -name .#\* -name '*.sk')
TARGETS=$(cd $dir/build; ninja -t targets | sed -e 's/:.*//')
RES=''
for ARG in "$@"; do
if [[ $ARG == test_* ]]; then
RES="$RES $ARG"
else
MATCHES=$(echo "$FILES" | grep `echo "$ARG" | sed -e "s/\.exp$//"` | tr / . | sed -e "s/\.\./test_$BACKEND./" | sed -e "s/\.sk//")
if [[ $MATCHES == "" ]]; then
echo "Cannot find any tests that match $ARG"
exit 1
fi
RES="$RES $MATCHES"
fi
done;
if [[ $RES == "" ]]; then
echo "No tests to run. Some examples you may want to run:"
echo
echo "All the js tests, this is likely what you want to run before sending a PR"
echo " ./test.sh test_js"
echo
echo "All the tests, very very long..."
echo " ./test.sh test"
echo
echo "Run and re-record the test results"
echo "UPDATE_BASELINE=1 ./test.sh test"
echo
echo "A specific test using the js backend"
echo " ./test.sh tests/src/frontend/typechecking/type_const_double_alias.sk"
echo
echo "A specific test using the native backend"
echo " BACKEND=native ./test.sh tests/src/frontend/typechecking/type_const_double_alias.sk"
echo
echo "A specific test using the ninja syntax"
echo " ./test.sh test_js.tests.src.frontend.typechecking.type_const_double_alias"
echo
echo "All the tests that match a part of the path"
echo " ./test.sh type_const_double_alias"
exit 1
fi
for TARGET in $RES; do
if [[ $(echo "$TARGETS" | grep $TARGET) == "" ]]; then
echo "$TARGET is not a registered target by ninja. If you added that test, you need to re-run cmake to get it picked up."
exit 1
fi
done
cd $dir/build
ninja $RES