Browse Source

Improve JS testing scripts.

pull/1932/head
tritao 2 months ago
parent
commit
397f59bffd
  1. 4
      .github/workflows/main.yml
  2. 75
      tests/emscripten/test.sh
  3. 64
      tests/napi/test.sh
  4. 75
      tests/quickjs/test.sh
  5. 2
      tests/test.sh
  6. 58
      tests/ts/test.sh

4
.github/workflows/main.yml

@ -88,12 +88,12 @@ jobs: @@ -88,12 +88,12 @@ jobs:
- name: Test (QuickJS)
if: runner.os != 'Windows'
shell: bash
run: tests/quickjs/test.sh -dotnet_configuration $BUILD_CONFIGURATION
run: tests/quickjs/test.sh --dotnet-config $BUILD_CONFIGURATION
- name: Test (Emscripten)
if: runner.os != 'Windows'
shell: bash
run: tests/emscripten/test.sh -dotnet_configuration $BUILD_CONFIGURATION
run: tests/emscripten/test.sh --dotnet-config $BUILD_CONFIGURATION
- name: Pack
shell: bash

75
tests/emscripten/test.sh

@ -1,27 +1,46 @@ @@ -1,27 +1,46 @@
#!/usr/bin/env bash
set -e
dir=$(cd "$(dirname "$0")"; pwd)
rootdir="$dir/../.."
dotnet_configuration=Release
configuration=debug
dotnet_configuration=DebugOpt
make_configuration=debug
platform=x64
jsinterp=$(which node)
for arg in "$@"; do
case $arg in
--with-node=*)
jsinterp="${arg#*=}"
shift
;;
-configuration)
configuration=$2
shift
;;
-dotnet_configuration)
dotnet_configuration=$2
shift
;;
esac
usage() {
cat <<EOF
Usage: $(basename $0) [--with-node=NODE] [--make-config CONFIG] [--dotnet-config CONFIG]
EOF
exit 1
}
while [[ $# -gt 0 ]]; do
case "$1" in
--with-node=*)
jsinterp="${1#*=}"
shift
;;
--with-node)
jsinterp="$2"
shift 2
;;
--make-config|--make-configuration)
make_configuration="$2"
shift 2
;;
--dotnet-config|--dotnet-configuration)
dotnet_configuration="$2"
shift 2
;;
-h|--help)
usage
;;
*)
echo "Unknown option: $1" >&2
usage
;;
esac
done
if [ "$CI" = "true" ]; then
@ -34,19 +53,21 @@ else @@ -34,19 +53,21 @@ else
reset=`tput sgr0`
fi
# 1) Generate
generate=true
if [ $generate = true ]; then
echo "${green}Generating bindings${reset}"
dotnet $rootdir/bin/${dotnet_configuration}/CppSharp.CLI.dll --property=keywords \
$dir/bindings.lua
echo "${green}Generating bindings with .NET configuration $dotnet_configuration${reset}"
dotnet "$rootdir/bin/${dotnet_configuration}/CppSharp.CLI.dll" --property=keywords \
"$dir/bindings.lua"
fi
echo "${green}Building generated binding files${reset}"
premake=$rootdir/build/premake.sh
config=$configuration $premake --file=$dir/premake5.lua gmake
emmake make -C $dir/gen
echo
# 2) Build
echo "${green}Building generated binding files (make config: $make_configuration)${reset}"
premake="$rootdir/build/premake.sh"
"$premake" --file=$dir/premake5.lua gmake2
config=$make_configuration emmake make -C "$dir/gen"
# 3) Test
echo
echo "${green}Executing JS tests with Node${reset}"
$jsinterp $dir/test.mjs
"$jsinterp" "$dir/test.mjs"

64
tests/napi/test.sh

@ -1,9 +1,47 @@ @@ -1,9 +1,47 @@
#!/usr/bin/env bash
set -e
dir=$(cd "$(dirname "$0")"; pwd)
rootdir="$dir/../.."
configuration=Release
dotnet_configuration=DebugOpt
make_configuration=debug
platform=x64
jsinterp=$(which node)
usage() {
cat <<EOF
Usage: $(basename $0) [--with-node=NODE] [--make-config CONFIG] [--dotnet-config CONFIG]
EOF
exit 1
}
while [[ $# -gt 0 ]]; do
case "$1" in
--with-node=*)
jsinterp="${1#*=}"
shift
;;
--with-node)
jsinterp="$2"
shift 2
;;
--make-config|--make-configuration)
make_configuration="$2"
shift 2
;;
--dotnet-config|--dotnet-configuration)
dotnet_configuration="$2"
shift 2
;;
-h|--help)
usage
;;
*)
echo "Unknown option: $1" >&2
usage
;;
esac
done
if [ "$CI" = "true" ]; then
red=""
@ -15,15 +53,21 @@ else @@ -15,15 +53,21 @@ else
reset=`tput sgr0`
fi
echo "${green}Generating bindings${reset}"
dotnet $rootdir/bin/${configuration}/CppSharp.CLI.dll \
--gen=napi -I$dir/.. -o $dir/gen -m tests $dir/../*.h
# 1) Generate
generate=true
if [ $generate = true ]; then
echo "${green}Generating bindings with .NET configuration $dotnet_configuration${reset}"
dotnet "$rootdir/bin/${dotnet_configuration}/CppSharp.CLI.dll" \
--gen=napi -I$dir/.. -o $dir/gen -m tests $dir/../*.h
fi
echo "${green}Building generated binding files${reset}"
premake=$rootdir/build/premake.sh
$premake --file=$dir/premake5.lua gmake
make -C $dir/gen
echo
# 2) Build
echo "${green}Building generated binding files (make config: $make_configuration)${reset}"
premake="$rootdir/build/premake.sh"
"$premake" --file=$dir/premake5.lua gmake
config=$make_configuration make -C "$dir/gen"
# 3) Test
echo
echo "${green}Executing JS tests with Node${reset}"
node $dir/test.js
"$jsinterp" "$dir/test.js"

75
tests/quickjs/test.sh

@ -1,25 +1,47 @@ @@ -1,25 +1,47 @@
#!/usr/bin/env bash
set -e
dir=$(cd "$(dirname "$0")"; pwd)
rootdir="$dir/../.."
dotnet_configuration=Release
configuration=debug
dotnet_configuration=DebugOpt
make_configuration=debug
platform=x64
jsinterp="$dir/runtime/build/qjs"
for arg in "$@"; do
case $arg in
-configuration)
configuration=$2
shift
;;
-dotnet_configuration)
dotnet_configuration=$2
shift
;;
esac
done
usage() {
cat <<EOF
Usage: $(basename $0) [--with-node=NODE] [--make-config CONFIG] [--dotnet-config CONFIG]
EOF
exit 1
}
cd $dir
while [[ $# -gt 0 ]]; do
case "$1" in
--with-node=*)
jsinterp="${1#*=}"
shift
;;
--with-node)
jsinterp="$2"
shift 2
;;
--make-config|--make-configuration)
make_configuration="$2"
shift 2
;;
--dotnet-config|--dotnet-configuration)
dotnet_configuration="$2"
shift 2
;;
-h|--help)
usage
;;
*)
echo "Unknown option: $1" >&2
usage
;;
esac
done
if [ "$CI" = "true" ]; then
red=""
@ -31,20 +53,21 @@ else @@ -31,20 +53,21 @@ else
reset=`tput sgr0`
fi
# 1) Generate
generate=true
if [ $generate = true ]; then
echo "${green}Generating bindings${reset}"
dotnet $rootdir/bin/${dotnet_configuration}/CppSharp.CLI.dll \
$dir/bindings.lua
echo "${green}Generating bindings with .NET configuration $dotnet_configuration${reset}"
dotnet "$rootdir/bin/${dotnet_configuration}/CppSharp.CLI.dll" "$dir/bindings.lua"
fi
echo "${green}Building generated binding files${reset}"
premake=$rootdir/build/premake.sh
config=$configuration $premake --file=$dir/premake5.lua gmake2
verbose=true make -C $dir/gen
echo
# 2) Build
echo "${green}Building generated binding files (make config: $make_configuration)${reset}"
premake="$rootdir/build/premake.sh"
"$premake" --file=$dir/premake5.lua gmake2
config=$make_configuration verbose=true make -C "$dir/gen"
# 3) Test
echo
echo "${green}Executing JS tests with QuickJS${reset}"
cp $dir/gen/bin/$configuration/libtest.so $dir
$jsinterp --std $dir/test.js
cp $dir/gen/bin/$make_configuration/libtest.so $dir
$jsinterp --std $dir/test.js

2
tests/test.sh

@ -2,6 +2,6 @@ @@ -2,6 +2,6 @@
set -e
dir=$(cd "$(dirname "$0")"; pwd)
$dir/napi/test.sh
# $dir/napi/test.sh
$dir/quickjs/test.sh
$dir/emscripten/test.sh

58
tests/ts/test.sh

@ -1,11 +1,47 @@ @@ -1,11 +1,47 @@
#!/usr/bin/env bash
set -e
dir=$(cd "$(dirname "$0")"; pwd)
rootdir="$dir/../.."
dotnet_configuration=Release
configuration=debug
dotnet_configuration=DebugOpt
make_configuration=debug
platform=x64
jsinterp="$rootdir/deps/quickjs/qjs-debug"
jsinterp="$dir/runtime/build/qjs"
usage() {
cat <<EOF
Usage: $(basename $0) [--with-node=NODE] [--make-config CONFIG] [--dotnet-config CONFIG]
EOF
exit 1
}
while [[ $# -gt 0 ]]; do
case "$1" in
--with-node=*)
jsinterp="${1#*=}"
shift
;;
--with-node)
jsinterp="$2"
shift 2
;;
--make-config|--make-configuration)
make_configuration="$2"
shift 2
;;
--dotnet-config|--dotnet-configuration)
dotnet_configuration="$2"
shift 2
;;
-h|--help)
usage
;;
*)
echo "Unknown option: $1" >&2
usage
;;
esac
done
if [ "$CI" = "true" ]; then
red=""
@ -17,22 +53,14 @@ else @@ -17,22 +53,14 @@ else
reset=`tput sgr0`
fi
# 1) Generate
generate=true
if [ $generate = true ]; then
echo "${green}Generating bindings${reset}"
dotnet $rootdir/bin/${dotnet_configuration}/CppSharp.CLI.dll \
echo "${green}Generating bindings with .NET configuration $dotnet_configuration${reset}"
dotnet "$rootdir/bin/${dotnet_configuration}/CppSharp.CLI.dll" \
--gen=ts -I$dir/.. -I$rootdir/include -o $dir/gen -m tests $dir/../*.h
fi
echo "${green}Building generated binding files${reset}"
#make -C $dir/gen
echo
# 2) Type-checking
echo "${green}Typechecking generated binding files with tsc${reset}"
#tsc --noEmit --strict --noImplicitAny --strictNullChecks --strictFunctionTypes --noImplicitThis gen/*.d.ts
# echo "${green}Executing JS tests with QuickJS${reset}"
# cp $dir/gen/bin/$configuration/libtest.so $dir
# #cp $dir/gen/bin/$configuration/libtest.dylib $dir
# $jsinterp --std $dir/test.js
Loading…
Cancel
Save