-
Notifications
You must be signed in to change notification settings - Fork 39
/
create_test.sh
executable file
·42 lines (31 loc) · 1.27 KB
/
create_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
#!/bin/sh
set -e
out_dir=$(mktemp -d)
export KLOTHO_DEBUG_DIR=$out_dir/debug
mkdir -p $KLOTHO_DEBUG_DIR
name=$(basename $1)
name=${name%.*}
name=${name%.input}
echo "Running $name"
# Run the engine
echo "Using $out_dir as output directory"
set +e
go run ./cmd/engine Run \
-i "$1" \
-c "$1" \
-t "test" \
-o "$out_dir" > $out_dir/error_details.json 2> $out_dir/err.log
# note: 'go run' always returns exit code 1 if the program returns any non-zero
# so using $? to capture it won't work. We'd need to build and run the binary
echo "Ran $name, copying results to testdata"
set -e
test_dir="pkg/engine/testdata"
if [ ! "$test_dir/$name.input.yaml" -ef "$1" ]; then
cp $1 "$test_dir/$name.input.yaml"
fi
[ -e "$out_dir/resources.yaml" ] && cp "$out_dir/resources.yaml" "$test_dir/$name.expect.yaml"
[ -e "$out_dir/dataflow-topology.yaml" ] && cp "$out_dir/dataflow-topology.yaml" "$test_dir/$name.dataflow-viz.yaml"
[ -e "$out_dir/iac-topology.yaml" ] && cp "$out_dir/iac-topology.yaml" "$test_dir/$name.iac-viz.yaml"
[ -e "$out_dir/error_details.json" ] && cp "$out_dir/error_details.json" "$test_dir/$name.err.json"
[ -e "$out_dir/deployment_permissions_policy.json" ] && cp "$out_dir/deployment_permissions_policy.json" "$test_dir/$name.deployment-policy.json"
rm -rf $out_dir