Skip to content

Commit 27ebf26

Browse files
committed
Implementing examples using standard templates.
1 parent 91f29e8 commit 27ebf26

File tree

7 files changed

+91
-27
lines changed

7 files changed

+91
-27
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ examples/**/node_conformance_tests/
99
examples/**/package-lock.json
1010
examples/**/node_modules/
1111
examples/**/node_harness_tests/
12+
13+
examples/**/go_build/

examples/example_hello_world_golang/hello_world_golang.plain

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
> "hello, world" in Plain (Go lang version)
2-
3-
***Non-Functional Requirements:***
4-
5-
- Implementation should be in Go lang.
6-
7-
- The main executable code file should be called hello_world.go
1+
{% include "golang-console-app-template.plain", main_executable_file_name: "hello_world.go" %}
82

3+
# "hello, world" in Plain (Go lang version)
94

105
***Functional Requirements:***
116

examples/example_hello_world_golang/run.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@ if [ $VERBOSE -eq 1 ]; then
2727
fi
2828

2929
# Construct the command with optional parameters
30-
CMD="python ../../plain2code.py hello_world_golang.plain"
30+
CMD="python ../../plain2code.py hello_world_golang.plain --unittests-script=../../test_scripts/run_unittests_golang.sh --conformance-tests-script=../../test_scripts/run_conformance_tests_golang.sh"
3131
if [ $VERBOSE -eq 1 ]; then
3232
CMD="$CMD -v"
3333
fi
3434
if [ ! -z "$API_ENDPOINT" ]; then
3535
CMD="$CMD --api $API_ENDPOINT"
3636
fi
3737

38+
# Removing all the conformance tests before rendering the hello world example.
39+
rm -rf conformance_tests
40+
3841
# Execute the command
3942
$CMD
4043

examples/example_hello_world_python/hello_world_python.plain

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
> "hello, world" in Plain (Python version)
2-
3-
***Non-Functional Requirements:***
4-
5-
- Implementation should be in Python.
6-
7-
- The main executable code file should be called hello_world.py
1+
{% include "python-console-app-template.plain", main_executable_file_name: "hello_world.py" %}
82

3+
# "hello, world" in Plain (Python version)
94

105
***Functional Requirements:***
116

examples/example_hello_world_python/run.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@ if [ $VERBOSE -eq 1 ]; then
2727
fi
2828

2929
# Construct the command with optional parameters
30-
CMD="python ../../plain2code.py hello_world_python.plain"
30+
CMD="python ../../plain2code.py hello_world_python.plain --unittests-script=../../test_scripts/run_unittests_python.sh --conformance-tests-script=../../test_scripts/run_conformance_tests_python.sh --debug"
3131
if [ $VERBOSE -eq 1 ]; then
3232
CMD="$CMD -v"
3333
fi
3434
if [ ! -z "$API_ENDPOINT" ]; then
3535
CMD="$CMD --api $API_ENDPOINT"
3636
fi
3737

38+
rm -rf conformance_tests
39+
3840
# Execute the command
3941
$CMD
4042

examples/example_hello_world_react/hello_world_react.plain

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
> "hello, world" in Plain (React version)
2-
3-
4-
***Non-Functional Requirements:***
5-
6-
- Implementation should be written in TypeScript, using React as a web framework.
7-
8-
9-
***Test Requirements:***
10-
11-
- The Conformance Tests should be written in TypeScript, using Cypress as the framework for The Conformance Tests.
1+
{% include "typescript-react-app-template.plain" %}
122

3+
# "hello, world" in Plain (React version)
134

145
***Functional Requirements:***
156

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
3+
# Check if build folder name is provided
4+
if [ -z "$1" ]; then
5+
printf "Error: No build folder name provided.\n"
6+
printf "Usage: $0 <build_folder_name> <conformance_tests_folder>\n"
7+
exit 1
8+
fi
9+
10+
# Check if conformance tests folder name is provided
11+
if [ -z "$2" ]; then
12+
printf "Error: No conformance tests folder name provided.\n"
13+
printf "Usage: $0 <build_folder_name> <conformance_tests_folder>\n"
14+
exit 1
15+
fi
16+
17+
current_dir=$(pwd)
18+
19+
GO_BUILD_SUBFOLDER=go_$1
20+
21+
if [ "${VERBOSE:-}" -eq 1 ] 2>/dev/null; then
22+
printf "Preparing Go build subfolder: $GO_BUILD_SUBFOLDER\n"
23+
fi
24+
25+
# Check if the go build subfolder exists
26+
if [ -d "$GO_BUILD_SUBFOLDER" ]; then
27+
# Find and delete all files and folders except "node_modules", "build", and "package-lock.json"
28+
find "$GO_BUILD_SUBFOLDER" -mindepth 1 -exec rm -rf {} +
29+
30+
if [ "${VERBOSE:-}" -eq 1 ] 2>/dev/null; then
31+
printf "Cleanup completed.\n"
32+
fi
33+
else
34+
if [ "${VERBOSE:-}" -eq 1 ] 2>/dev/null; then
35+
printf "Subfolder does not exist. Creating it...\n"
36+
fi
37+
38+
mkdir $GO_BUILD_SUBFOLDER
39+
fi
40+
41+
cp -R $1/* $GO_BUILD_SUBFOLDER
42+
43+
# Move to the subfolder
44+
cd "$GO_BUILD_SUBFOLDER" 2>/dev/null
45+
46+
if [ $? -ne 0 ]; then
47+
printf "Error: Go build folder '$GO_BUILD_SUBFOLDER' does not exist.\n"
48+
exit 2
49+
fi
50+
51+
# Execute all Go lang conformance tests in the build folder
52+
printf "Compiling Golang conformance tests...\n\n"
53+
54+
output=$(go test -c $current_dir/$2/conformance_test.go 2>&1)
55+
exit_code=$?
56+
57+
# If there was an error, print the output and exit with the error code
58+
if [ $exit_code -ne 0 ]; then
59+
echo "$output"
60+
exit $exit_code
61+
fi
62+
63+
# Execute all Go lang conformance tests in the build folder
64+
printf "Running Golang conformance tests...\n\n"
65+
66+
output=$(./main.test 2>&1)
67+
exit_code=$?
68+
69+
# If there was an error, print the output and exit with the error code
70+
if [ $exit_code -ne 0 ]; then
71+
echo "$output"
72+
exit $exit_code
73+
fi
74+
75+
# Echo the original exit code of the unittest command
76+
exit $exit_code

0 commit comments

Comments
 (0)