Skip to content

Commit 6da1443

Browse files
committed
Extended test harness run scripts to support passing api endpoint.
1 parent 6705506 commit 6da1443

File tree

4 files changed

+162
-44
lines changed

4 files changed

+162
-44
lines changed

examples/example_hello_world_golang/run.sh

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,42 @@
1-
if [[ "$1" == "-v" || "$1" == "--verbose" ]]; then
2-
VERBOSE=1
1+
# Store command line arguments
2+
VERBOSE=0
3+
API_ENDPOINT=""
34

4-
echo "Running Python hello world example in verbose mode."
5+
# Parse command line arguments
6+
while [[ $# -gt 0 ]]; do
7+
case $1 in
8+
-v|--verbose)
9+
VERBOSE=1
10+
shift # Remove --verbose from processing
11+
;;
12+
--api)
13+
API_ENDPOINT="$2"
14+
shift # Remove --api from processing
15+
shift # Remove the API endpoint value from processing
16+
;;
17+
*)
18+
# Unknown option
19+
echo "Unknown option: $1"
20+
exit 1
21+
;;
22+
esac
23+
done
24+
25+
if [ $VERBOSE -eq 1 ]; then
26+
echo "Running Go lang hello world example in verbose mode."
27+
fi
28+
29+
# Construct the command with optional parameters
30+
CMD="python ../../plain2code.py hello_world_golang.plain"
31+
if [ $VERBOSE -eq 1 ]; then
32+
CMD="$CMD -v"
33+
fi
34+
if [ ! -z "$API_ENDPOINT" ]; then
35+
CMD="$CMD --api $API_ENDPOINT"
536
fi
637

7-
python ../../plain2code.py hello_world_golang.plain ${VERBOSE:+-v}
38+
# Execute the command
39+
$CMD
840

941
# Check if the plain2code command failed
1042
if [ $? -ne 0 ]; then

examples/example_hello_world_python/run.sh

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,42 @@
1-
if [[ "$1" == "-v" || "$1" == "--verbose" ]]; then
2-
VERBOSE=1
3-
4-
echo "Running Python hello world example in verbose mode."
1+
# Store command line arguments
2+
VERBOSE=0
3+
API_ENDPOINT=""
4+
5+
# Parse command line arguments
6+
while [[ $# -gt 0 ]]; do
7+
case $1 in
8+
-v|--verbose)
9+
VERBOSE=1
10+
shift # Remove --verbose from processing
11+
;;
12+
--api)
13+
API_ENDPOINT="$2"
14+
shift # Remove --api from processing
15+
shift # Remove the API endpoint value from processing
16+
;;
17+
*)
18+
# Unknown option
19+
echo "Unknown option: $1"
20+
exit 1
21+
;;
22+
esac
23+
done
24+
25+
if [ $VERBOSE -eq 1 ]; then
26+
echo "Running Python hello world example in verbose mode."
527
fi
628

29+
# Construct the command with optional parameters
30+
CMD="python ../../plain2code.py hello_world_python.plain"
31+
if [ $VERBOSE -eq 1 ]; then
32+
CMD="$CMD -v"
33+
fi
34+
if [ ! -z "$API_ENDPOINT" ]; then
35+
CMD="$CMD --api $API_ENDPOINT"
36+
fi
737

8-
python ../../plain2code.py hello_world_python.plain ${VERBOSE:+-v}
38+
# Execute the command
39+
$CMD
940

1041
# Check if the plain2code command failed
1142
if [ $? -ne 0 ]; then

examples/example_hello_world_react/run.sh

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,46 @@
1-
if [[ "$1" == "-v" || "$1" == "--verbose" ]]; then
2-
VERBOSE=1
1+
# Store command line arguments
2+
VERBOSE=0
3+
API_ENDPOINT=""
34

4-
echo "Running the hello world example for React in verbose mode."
5+
# Parse command line arguments
6+
while [[ $# -gt 0 ]]; do
7+
case $1 in
8+
-v|--verbose)
9+
VERBOSE=1
10+
shift # Remove --verbose from processing
11+
;;
12+
--api)
13+
API_ENDPOINT="$2"
14+
shift # Remove --api from processing
15+
shift # Remove the API endpoint value from processing
16+
;;
17+
*)
18+
# Unknown option
19+
echo "Unknown option: $1"
20+
exit 1
21+
;;
22+
esac
23+
done
24+
25+
if [ $VERBOSE -eq 1 ]; then
26+
echo "Running the hello world example for React in verbose mode."
27+
fi
28+
29+
# Construct the command with optional parameters
30+
CMD="python ../../plain2code.py hello_world_react.plain --e2e-tests-script=../../test_scripts/run_e2e_tests_cypress.sh"
31+
if [ $VERBOSE -eq 1 ]; then
32+
CMD="$CMD -v"
33+
fi
34+
if [ ! -z "$API_ENDPOINT" ]; then
35+
CMD="$CMD --api $API_ENDPOINT"
536
fi
637

738
# Removing all the end-to-end tests before rendering the hello world example.
839
rm -rf e2e_tests
940
rm -rf node_e2e_tests
1041

11-
python ../../plain2code.py hello_world_react.plain --e2e-tests-script=../../test_scripts/run_e2e_tests_cypress.sh ${VERBOSE:+-v}
42+
# Execute the command
43+
$CMD
1244

1345
# Check if the plain2code command failed
1446
if [ $? -ne 0 ]; then

examples/run.sh

Lines changed: 54 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,64 @@
1-
if [[ "$1" == "-v" || "$1" == "--verbose" ]]; then
2-
VERBOSE=1
1+
# Store command line arguments
2+
VERBOSE=0
3+
API_ENDPOINT=""
34

4-
printf "Running plain2code test harness in verbose mode.\n\n"
5-
fi
5+
# Parse command line arguments
6+
while [[ $# -gt 0 ]]; do
7+
case $1 in
8+
-v|--verbose)
9+
VERBOSE=1
10+
shift # Remove --verbose from processing
11+
;;
12+
--api)
13+
API_ENDPOINT="$2"
14+
shift # Remove --api from processing
15+
shift # Remove the API endpoint value from processing
16+
;;
17+
*)
18+
# Unknown option
19+
echo "Unknown option: $1"
20+
exit 1
21+
;;
22+
esac
23+
done
624

7-
(
8-
cd example_hello_world_python
25+
echo "Running all example test harnesses..."
926

10-
sh run.sh ${VERBOSE:+-v}
27+
VERBOSE_FLAG=""
28+
if [ "$VERBOSE" -eq 1 ]; then
29+
VERBOSE_FLAG="-v"
30+
fi
1131

12-
# Check if the example_hello_world/run.sh command failed
13-
if [ $? -ne 0 ]; then
14-
echo "Error: The example_hello_world/run.sh command failed."
15-
exit 1
16-
fi
17-
)
32+
# Construct the API parameter if provided
33+
API_PARAM=""
34+
if [ ! -z "$API_ENDPOINT" ]; then
35+
API_PARAM="--api $API_ENDPOINT"
36+
fi
1837

1938
(
20-
cd example_hello_world_golang
21-
22-
sh run.sh ${VERBOSE:+-v}
23-
24-
# Check if the example_hello_world/run.sh command failed
25-
if [ $? -ne 0 ]; then
26-
echo "Error: The example_hello_world/run.sh command failed."
27-
exit 1
28-
fi
39+
cd example_hello_world_python
40+
sh run.sh ${VERBOSE_FLAG} ${API_PARAM}
41+
if [ $? -ne 0 ]; then
42+
echo "Hello World Python example failed."
43+
exit 1
44+
fi
45+
cd ..
2946
)
3047

31-
(
32-
cd example_hello_world_react
48+
cd example_hello_world_golang
49+
sh run.sh ${VERBOSE_FLAG} ${API_PARAM}
50+
if [ $? -ne 0 ]; then
51+
echo "Hello World Golang example failed."
52+
exit 1
53+
fi
54+
cd ..
3355

34-
sh run.sh ${VERBOSE:+-v}
56+
cd example_hello_world_react
57+
sh run.sh ${VERBOSE_FLAG} ${API_PARAM}
58+
if [ $? -ne 0 ]; then
59+
echo "Hello World React example failed."
60+
exit 1
61+
fi
62+
cd ..
3563

36-
# Check if the example_hello_world/run.sh command failed
37-
if [ $? -ne 0 ]; then
38-
echo "Error: The example_hello_world/run.sh command failed."
39-
exit 1
40-
fi
41-
)
64+
echo "All example test harnesses completed successfully!"

0 commit comments

Comments
 (0)