-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathrun_tests.sh
More file actions
executable file
·94 lines (77 loc) · 1.81 KB
/
run_tests.sh
File metadata and controls
executable file
·94 lines (77 loc) · 1.81 KB
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
#!/bin/bash
source venv/bin/activate
# First, install any example-specific dependencies (common dependencies such as
# `componentize-py`, `spin-sdk`, and `mypy` are assumed to have been installed
# in the virtual environment).
if [ ! -d examples/matrix-math/numpy ]
then
(cd examples/matrix-math \
&& curl -OL https://github.com/dicej/wasi-wheels/releases/download/v0.0.2/numpy-wasi.tar.gz \
&& tar xf numpy-wasi.tar.gz)
fi
# Next, run MyPy on all the examples
for example in examples/*
do
echo "linting $example"
if [ $example = "examples/matrix-math" ]
then
# NumPy fails linting as of this writing, so we skip it
extra_option="--follow-imports silent"
else
unset extra_option
fi
export MYPYPATH=$(pwd)/src
(cd $example && mypy --strict $extra_option -m app) || exit 1
done
# Next, build all the examples
for example in examples/*
do
echo "building $example"
(cd $example && spin build) || exit 1
done
# Finally, run some of the examples and test that they behave as expected
for example in examples/hello examples/external-lib-example examples/spin-kv examples/spin-variables
do
pushd $example
spin up &
spin_pid=$!
for x in $(seq 1 10)
do
message="$(curl -s localhost:3000)"
if [ "$message" = "Hello from Python!" ]
then
result=success
break
fi
sleep 1
done
kill "$spin_pid"
if [ "$result" != "success" ]
then
exit 1
fi
popd
done
for example in examples/streaming
do
pushd $example
spin up &
spin_pid=$!
for x in $(seq 1 10)
do
message="$(curl -s -d 'Hello from Python!' localhost:3000/echo)"
if [ "$message" = "Hello from Python!" ]
then
result=success
break
fi
sleep 1
done
kill "$spin_pid"
if [ "$result" != "success" ]
then
exit 1
fi
popd
done
# TODO: run more examples