Skip to content

Commit d731168

Browse files
author
Fabiana Severin
committed
Adding specific error message for different node versions and formatiing
1 parent 7e18147 commit d731168

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

scripts/test_local.sh

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,35 @@ fi
2323

2424
# Function to run unit tests for specific Node version
2525
run_unit_tests() {
26-
local node_version=$1
27-
echo "Running unit tests for Node.js $node_version..."
28-
docker build -f test/unit/Dockerfile.nodejs${node_version}.x -t unit/nodejs.${node_version}x .
29-
docker run --rm unit/nodejs.${node_version}x
26+
local node_version=$1
27+
echo "Running unit tests for Node.js $node_version..."
28+
docker build -f test/unit/Dockerfile.nodejs${node_version}.x -t unit/nodejs.${node_version}x . || {
29+
echo "Build failed for Node.js $node_version"
30+
exit 1
31+
}
32+
docker run --rm unit/nodejs.${node_version}x || {
33+
echo "Tests failed for Node.js $node_version"
34+
exit 1
35+
}
3036
}
3137

3238
# Parse command line arguments
3339
case "${1:-all}" in
34-
"unit")
35-
NODE_VERSION=${2:-"20"}
36-
run_unit_tests $NODE_VERSION
37-
;;
38-
"all")
39-
echo "Running unit tests for all Node versions..."
40-
for version in 18 20 22; do
41-
run_unit_tests $version
42-
done
43-
;;
44-
*)
45-
echo "Usage: $0 [unit|all] [node_version]"
46-
echo "Examples:"
47-
echo " $0 unit 20 # Run unit tests for Node 20"
48-
echo " $0 all # Run unit tests for all Node versions"
49-
exit 1
50-
;;
40+
"unit")
41+
NODE_VERSION=${2:-"20"}
42+
run_unit_tests $NODE_VERSION
43+
;;
44+
"all")
45+
echo "Running unit tests for all Node versions..."
46+
for version in 18 20 22; do
47+
run_unit_tests $version
48+
done
49+
;;
50+
*)
51+
echo "Usage: $0 [unit|all] [node_version]"
52+
echo "Examples:"
53+
echo " $0 unit 20 # Run unit tests for Node 20"
54+
echo " $0 all # Run unit tests for all Node versions"
55+
exit 1
56+
;;
5157
esac

0 commit comments

Comments
 (0)