-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathexecute-test.sh
executable file
·130 lines (114 loc) · 2.56 KB
/
execute-test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
set -e
# Source external scripts
. scripts/optimize-xcall-build.sh
. scripts/optimize-build.sh
# Define a usage function to display how to use the script
usage() {
echo "Usage: $0 [options]"
echo "Options:"
echo " --clean : Clean contract directories (true/false, default: false)."
echo " --build-ibc : Build IBC contracts (true/false, default: false)."
echo " --build-xcall : Build xCall contracts (true/false, default: false)."
echo " --xcall-branch <branch>: Specify the xCall branch to build (default: main)."
echo " --use-docker : Use Docker for building contracts(true/false, default: false)."
echo " --test <test_type>: Specify the type of test (e2e, e2e-demo, integration, default: e2e)."
exit 1
}
# Define variables with default values
use_docker="false"
clean="false"
build_ibc="false"
build_xcall="false"
test="e2e"
xcall_branch="main"
# Define functions
clean_contracts() {
echo "Cleaning contract directories..."
find artifacts/icon -type f -exec rm {} \;
find artifacts/archway -type f -exec rm {} \;
}
e2e_test() {
echo "Running e2e test..."
go test -v ./test/e2e -timeout 0 -count=1
}
e2e_demo() {
echo "Configuring e2e demo..."
export PRESERVE_DOCKER=true && go test -v ./test/e2e-demo -testify.m TestSetup
}
integration_test() {
echo "Running integration test..."
go test -v ./test/integration -timeout 0 -count=1
}
# Parse command line arguments
while [ $# -gt 0 ]; do
case "$1" in
--clean)
clean="true"
;;
--build-ibc)
build_ibc="true"
;;
--build-xcall)
build_xcall="true"
;;
--xcall-branch)
shift
xcall_branch="$1"
;;
--use-docker)
use_docker="true"
;;
--test)
shift
test="$1"
;;
*)
echo "Error: Unknown option '$1'."
usage
;;
esac
shift
done
# Perform actions based on command line arguments
if [ "$clean" = "true" ]; then
clean_contracts
fi
if [ "$use_docker" = "true" ]; then
make build-builder-img & wait
fi
if [ "$build_ibc" = "true" ]; then
echo "building IBC contracts..."
if [ "$use_docker" = "true" ]; then
make optimize-build &
wait
else
build_ibc_contracts
fi
fi
if [ "$build_xcall" = "true" ]; then
echo "building xCall contracts..."
if [ "$use_docker" = "true" ]; then
make optimize-xcall BRANCH="$xcall_branch" &
wait
else
build_xCall_contracts "$xcall_branch"
fi
fi
# Run the selected test
echo "running $test......"
case "$test" in
"e2e")
e2e_test
;;
"e2e-demo")
e2e_demo
;;
"integration")
integration_test
;;
*)
echo "Error: Unknown test type '$test'."
exit 1
;;
esac