Skip to content

Commit 397f59b

Browse files
committed
Improve JS testing scripts.
1 parent 031a900 commit 397f59b

File tree

6 files changed

+197
-81
lines changed

6 files changed

+197
-81
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ jobs:
8888
- name: Test (QuickJS)
8989
if: runner.os != 'Windows'
9090
shell: bash
91-
run: tests/quickjs/test.sh -dotnet_configuration $BUILD_CONFIGURATION
91+
run: tests/quickjs/test.sh --dotnet-config $BUILD_CONFIGURATION
9292

9393
- name: Test (Emscripten)
9494
if: runner.os != 'Windows'
9595
shell: bash
96-
run: tests/emscripten/test.sh -dotnet_configuration $BUILD_CONFIGURATION
96+
run: tests/emscripten/test.sh --dotnet-config $BUILD_CONFIGURATION
9797

9898
- name: Pack
9999
shell: bash

tests/emscripten/test.sh

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,46 @@
11
#!/usr/bin/env bash
22
set -e
3+
34
dir=$(cd "$(dirname "$0")"; pwd)
45
rootdir="$dir/../.."
5-
dotnet_configuration=Release
6-
configuration=debug
6+
dotnet_configuration=DebugOpt
7+
make_configuration=debug
78
platform=x64
89
jsinterp=$(which node)
910

10-
for arg in "$@"; do
11-
case $arg in
12-
--with-node=*)
13-
jsinterp="${arg#*=}"
14-
shift
15-
;;
16-
-configuration)
17-
configuration=$2
18-
shift
19-
;;
20-
-dotnet_configuration)
21-
dotnet_configuration=$2
22-
shift
23-
;;
24-
esac
11+
usage() {
12+
cat <<EOF
13+
Usage: $(basename $0) [--with-node=NODE] [--make-config CONFIG] [--dotnet-config CONFIG]
14+
EOF
15+
exit 1
16+
}
17+
18+
while [[ $# -gt 0 ]]; do
19+
case "$1" in
20+
--with-node=*)
21+
jsinterp="${1#*=}"
22+
shift
23+
;;
24+
--with-node)
25+
jsinterp="$2"
26+
shift 2
27+
;;
28+
--make-config|--make-configuration)
29+
make_configuration="$2"
30+
shift 2
31+
;;
32+
--dotnet-config|--dotnet-configuration)
33+
dotnet_configuration="$2"
34+
shift 2
35+
;;
36+
-h|--help)
37+
usage
38+
;;
39+
*)
40+
echo "Unknown option: $1" >&2
41+
usage
42+
;;
43+
esac
2544
done
2645

2746
if [ "$CI" = "true" ]; then
@@ -34,19 +53,21 @@ else
3453
reset=`tput sgr0`
3554
fi
3655

56+
# 1) Generate
3757
generate=true
38-
3958
if [ $generate = true ]; then
40-
echo "${green}Generating bindings${reset}"
41-
dotnet $rootdir/bin/${dotnet_configuration}/CppSharp.CLI.dll --property=keywords \
42-
$dir/bindings.lua
59+
echo "${green}Generating bindings with .NET configuration $dotnet_configuration${reset}"
60+
dotnet "$rootdir/bin/${dotnet_configuration}/CppSharp.CLI.dll" --property=keywords \
61+
"$dir/bindings.lua"
4362
fi
4463

45-
echo "${green}Building generated binding files${reset}"
46-
premake=$rootdir/build/premake.sh
47-
config=$configuration $premake --file=$dir/premake5.lua gmake
48-
emmake make -C $dir/gen
49-
echo
64+
# 2) Build
65+
echo "${green}Building generated binding files (make config: $make_configuration)${reset}"
66+
premake="$rootdir/build/premake.sh"
67+
"$premake" --file=$dir/premake5.lua gmake2
68+
config=$make_configuration emmake make -C "$dir/gen"
5069

70+
# 3) Test
71+
echo
5172
echo "${green}Executing JS tests with Node${reset}"
52-
$jsinterp $dir/test.mjs
73+
"$jsinterp" "$dir/test.mjs"

tests/napi/test.sh

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,47 @@
11
#!/usr/bin/env bash
22
set -e
3+
34
dir=$(cd "$(dirname "$0")"; pwd)
45
rootdir="$dir/../.."
5-
configuration=Release
6+
dotnet_configuration=DebugOpt
7+
make_configuration=debug
68
platform=x64
9+
jsinterp=$(which node)
10+
11+
usage() {
12+
cat <<EOF
13+
Usage: $(basename $0) [--with-node=NODE] [--make-config CONFIG] [--dotnet-config CONFIG]
14+
EOF
15+
exit 1
16+
}
17+
18+
while [[ $# -gt 0 ]]; do
19+
case "$1" in
20+
--with-node=*)
21+
jsinterp="${1#*=}"
22+
shift
23+
;;
24+
--with-node)
25+
jsinterp="$2"
26+
shift 2
27+
;;
28+
--make-config|--make-configuration)
29+
make_configuration="$2"
30+
shift 2
31+
;;
32+
--dotnet-config|--dotnet-configuration)
33+
dotnet_configuration="$2"
34+
shift 2
35+
;;
36+
-h|--help)
37+
usage
38+
;;
39+
*)
40+
echo "Unknown option: $1" >&2
41+
usage
42+
;;
43+
esac
44+
done
745

846
if [ "$CI" = "true" ]; then
947
red=""
@@ -15,15 +53,21 @@ else
1553
reset=`tput sgr0`
1654
fi
1755

18-
echo "${green}Generating bindings${reset}"
19-
dotnet $rootdir/bin/${configuration}/CppSharp.CLI.dll \
20-
--gen=napi -I$dir/.. -o $dir/gen -m tests $dir/../*.h
56+
# 1) Generate
57+
generate=true
58+
if [ $generate = true ]; then
59+
echo "${green}Generating bindings with .NET configuration $dotnet_configuration${reset}"
60+
dotnet "$rootdir/bin/${dotnet_configuration}/CppSharp.CLI.dll" \
61+
--gen=napi -I$dir/.. -o $dir/gen -m tests $dir/../*.h
62+
fi
2163

22-
echo "${green}Building generated binding files${reset}"
23-
premake=$rootdir/build/premake.sh
24-
$premake --file=$dir/premake5.lua gmake
25-
make -C $dir/gen
26-
echo
64+
# 2) Build
65+
echo "${green}Building generated binding files (make config: $make_configuration)${reset}"
66+
premake="$rootdir/build/premake.sh"
67+
"$premake" --file=$dir/premake5.lua gmake
68+
config=$make_configuration make -C "$dir/gen"
2769

70+
# 3) Test
71+
echo
2872
echo "${green}Executing JS tests with Node${reset}"
29-
node $dir/test.js
73+
"$jsinterp" "$dir/test.js"

tests/quickjs/test.sh

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,47 @@
11
#!/usr/bin/env bash
22
set -e
3+
34
dir=$(cd "$(dirname "$0")"; pwd)
45
rootdir="$dir/../.."
5-
dotnet_configuration=Release
6-
configuration=debug
6+
dotnet_configuration=DebugOpt
7+
make_configuration=debug
8+
platform=x64
79
jsinterp="$dir/runtime/build/qjs"
810

9-
for arg in "$@"; do
10-
case $arg in
11-
-configuration)
12-
configuration=$2
13-
shift
14-
;;
15-
-dotnet_configuration)
16-
dotnet_configuration=$2
17-
shift
18-
;;
19-
esac
20-
done
11+
usage() {
12+
cat <<EOF
13+
Usage: $(basename $0) [--with-node=NODE] [--make-config CONFIG] [--dotnet-config CONFIG]
14+
EOF
15+
exit 1
16+
}
2117

22-
cd $dir
18+
while [[ $# -gt 0 ]]; do
19+
case "$1" in
20+
--with-node=*)
21+
jsinterp="${1#*=}"
22+
shift
23+
;;
24+
--with-node)
25+
jsinterp="$2"
26+
shift 2
27+
;;
28+
--make-config|--make-configuration)
29+
make_configuration="$2"
30+
shift 2
31+
;;
32+
--dotnet-config|--dotnet-configuration)
33+
dotnet_configuration="$2"
34+
shift 2
35+
;;
36+
-h|--help)
37+
usage
38+
;;
39+
*)
40+
echo "Unknown option: $1" >&2
41+
usage
42+
;;
43+
esac
44+
done
2345

2446
if [ "$CI" = "true" ]; then
2547
red=""
@@ -31,20 +53,21 @@ else
3153
reset=`tput sgr0`
3254
fi
3355

56+
# 1) Generate
3457
generate=true
35-
3658
if [ $generate = true ]; then
37-
echo "${green}Generating bindings${reset}"
38-
dotnet $rootdir/bin/${dotnet_configuration}/CppSharp.CLI.dll \
39-
$dir/bindings.lua
59+
echo "${green}Generating bindings with .NET configuration $dotnet_configuration${reset}"
60+
dotnet "$rootdir/bin/${dotnet_configuration}/CppSharp.CLI.dll" "$dir/bindings.lua"
4061
fi
4162

42-
echo "${green}Building generated binding files${reset}"
43-
premake=$rootdir/build/premake.sh
44-
config=$configuration $premake --file=$dir/premake5.lua gmake2
45-
verbose=true make -C $dir/gen
46-
echo
63+
# 2) Build
64+
echo "${green}Building generated binding files (make config: $make_configuration)${reset}"
65+
premake="$rootdir/build/premake.sh"
66+
"$premake" --file=$dir/premake5.lua gmake2
67+
config=$make_configuration verbose=true make -C "$dir/gen"
4768

69+
# 3) Test
70+
echo
4871
echo "${green}Executing JS tests with QuickJS${reset}"
49-
cp $dir/gen/bin/$configuration/libtest.so $dir
50-
$jsinterp --std $dir/test.js
72+
cp $dir/gen/bin/$make_configuration/libtest.so $dir
73+
$jsinterp --std $dir/test.js

tests/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
set -e
33
dir=$(cd "$(dirname "$0")"; pwd)
44

5-
$dir/napi/test.sh
5+
# $dir/napi/test.sh
66
$dir/quickjs/test.sh
77
$dir/emscripten/test.sh

tests/ts/test.sh

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,47 @@
11
#!/usr/bin/env bash
22
set -e
3+
34
dir=$(cd "$(dirname "$0")"; pwd)
45
rootdir="$dir/../.."
5-
dotnet_configuration=Release
6-
configuration=debug
6+
dotnet_configuration=DebugOpt
7+
make_configuration=debug
78
platform=x64
8-
jsinterp="$rootdir/deps/quickjs/qjs-debug"
9+
jsinterp="$dir/runtime/build/qjs"
10+
11+
usage() {
12+
cat <<EOF
13+
Usage: $(basename $0) [--with-node=NODE] [--make-config CONFIG] [--dotnet-config CONFIG]
14+
EOF
15+
exit 1
16+
}
17+
18+
while [[ $# -gt 0 ]]; do
19+
case "$1" in
20+
--with-node=*)
21+
jsinterp="${1#*=}"
22+
shift
23+
;;
24+
--with-node)
25+
jsinterp="$2"
26+
shift 2
27+
;;
28+
--make-config|--make-configuration)
29+
make_configuration="$2"
30+
shift 2
31+
;;
32+
--dotnet-config|--dotnet-configuration)
33+
dotnet_configuration="$2"
34+
shift 2
35+
;;
36+
-h|--help)
37+
usage
38+
;;
39+
*)
40+
echo "Unknown option: $1" >&2
41+
usage
42+
;;
43+
esac
44+
done
945

1046
if [ "$CI" = "true" ]; then
1147
red=""
@@ -17,22 +53,14 @@ else
1753
reset=`tput sgr0`
1854
fi
1955

56+
# 1) Generate
2057
generate=true
21-
2258
if [ $generate = true ]; then
23-
echo "${green}Generating bindings${reset}"
24-
dotnet $rootdir/bin/${dotnet_configuration}/CppSharp.CLI.dll \
59+
echo "${green}Generating bindings with .NET configuration $dotnet_configuration${reset}"
60+
dotnet "$rootdir/bin/${dotnet_configuration}/CppSharp.CLI.dll" \
2561
--gen=ts -I$dir/.. -I$rootdir/include -o $dir/gen -m tests $dir/../*.h
2662
fi
2763

28-
echo "${green}Building generated binding files${reset}"
29-
#make -C $dir/gen
30-
echo
31-
64+
# 2) Type-checking
3265
echo "${green}Typechecking generated binding files with tsc${reset}"
3366
#tsc --noEmit --strict --noImplicitAny --strictNullChecks --strictFunctionTypes --noImplicitThis gen/*.d.ts
34-
35-
# echo "${green}Executing JS tests with QuickJS${reset}"
36-
# cp $dir/gen/bin/$configuration/libtest.so $dir
37-
# #cp $dir/gen/bin/$configuration/libtest.dylib $dir
38-
# $jsinterp --std $dir/test.js

0 commit comments

Comments
 (0)