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