Skip to content

Commit

Permalink
Add tap-spec to format test output
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Apr 27, 2024
1 parent dbe49e8 commit c5c6a63
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 37 deletions.
1 change: 1 addition & 0 deletions modules/dev-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"prettier-check": "2.0.0",
"tape": "^4.11.0",
"tape-promise": "^4.0.0",
"tap-spec": "^5.0.0",
"typescript": "^5.2.2",
"ts-node": "~10.9.0",
"ts-patch": "^3.1.2",
Expand Down
58 changes: 29 additions & 29 deletions modules/dev-tools/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ BASEDIR=$(dirname "$0")

MODE=$1

MODULE_DIR=$(dirname $0)/..
TEST_SCRIPT=$MODULE_DIR/dist/test.js
DEV_TOOLS_DIR=$(dirname $0)/..
TEST_SCRIPT=$DEV_TOOLS_DIR/dist/test.js
COVERAGE_TEST=`node $DEV_TOOLS_DIR/dist/helpers/get-config.js ".coverage.test"`

usage() {
# TODO: Add more specific url
Expand All @@ -19,10 +20,18 @@ run_test_script() {
(set -x; NODE_ENV=test node $TEST_SCRIPT $1)
}

run_test_script_pretty() {
run_test_script $1 | tap-spec
}

generate_coverage_report() {
(set -x; npx c8 report --reporter=lcov)
}

run_full_test() {
npm run lint
run_test_script node
run_test_script browser-headless
run_test_script_pretty node
run_test_script_pretty browser-headless
ocular-metrics
}

Expand All @@ -39,11 +48,11 @@ case $MODE in

"fast")
ocular-lint pre-commit
run_test_script node
run_test_script_pretty node
;;

"node")
run_test_script $MODE
run_test_script_pretty node
;;

"node-debug")
Expand All @@ -52,43 +61,34 @@ case $MODE in
;;

"dist")
run_test_script dist
run_test_script_pretty dist
;;

"cover")
run_test_script cover
(set -x; npx c8 report --reporter=lcov)
run_test_script_pretty cover
generate_coverage_report
;;

"ci")
# run by Travis CI
# run by CI
npm run lint
run_test_script browser-headless
ocular-test cover
# node test/start.js bench
# ocular-metrics
;;

"browser")
run_test_script $MODE
if [ "$COVERAGE_TEST" == "browser" ]; then
run_test_script_pretty node
else
run_test_script_pretty browser-headless
fi
run_test_script_pretty cover
generate_coverage_report
ocular-metrics
;;

"browser-headless")
run_test_script $MODE
;;

"bench")
run_test_script $MODE
;;

"bench-browser")
run_test_script $MODE
run_test_script_pretty browser-headless
;;

*)
# default test
# echo "Error: unknown test mode $MODE"
# usage()
run_test_script $MODE
;;

esac
4 changes: 0 additions & 4 deletions modules/dev-tools/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ switch (mode) {
runNodeTest(resolveNodeEntry('test')); // Run the tests
break;

case 'bench':
runNodeTest(resolveNodeEntry('bench')); // Run the benchmarks
break;

case 'browser':
case 'browser-headless':
await runBrowserTest({
Expand Down
Loading

0 comments on commit c5c6a63

Please sign in to comment.