Skip to content

Commit 223623c

Browse files
committed
feat(test): adding integration tests
Signed-off-by: Andrew Steurer <[email protected]>
1 parent ab254f0 commit 223623c

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
build_and_run() {
6+
STDOUT_FILE=$(mktemp)
7+
STDERR_FILE=$(mktemp)
8+
9+
spin build -f $1
10+
# This is run in the background so we can `curl` it later on
11+
spin otel up -- -f $1 > $STDOUT_FILE 2> $STDERR_FILE &
12+
SPIN_PID=$!
13+
sleep 2
14+
15+
# If the process doesn't exist, `spin otel up` failed
16+
if ! kill -0 $SPIN_PID 2>/dev/null; then
17+
echo "### STDOUT ###"
18+
cat $STDOUT_FILE
19+
echo
20+
echo "### STDERR ###"
21+
cat $STDERR_FILE
22+
rm $STDOUT_FILE $STDERR_FILE
23+
exit 1
24+
fi
25+
26+
curl localhost:3000
27+
kill $SPIN_PID
28+
rm $STDOUT_FILE $STDERR_FILE
29+
}
30+
31+
########################################
32+
# Rust Examples #
33+
########################################
34+
35+
# spin-basic
36+
build_and_run "rust/examples/spin-basic/spin.toml"
37+
38+
# spin-tracing
39+
build_and_run "rust/examples/spin-tracing/spin.toml"

0 commit comments

Comments
 (0)