-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunner
executable file
·117 lines (107 loc) · 3.51 KB
/
runner
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
#!/bin/sh
# A simple dev tool for crossbus.
#
# - `./runner t` to run all integration testing with different features
# - `./runner c` to check the whole project with different features
# - `./runner demo` to run all the examples
#
cargo_test() {
echo "\n\nTesting with tokio: $1"
cargo t $1 --features tokio,derive,log,force-poll,unstable,time -- --nocapture &&
sleep 0.5
echo "\n\nTesting with async-std: $1"
cargo t $1 --features async-std,derive,log,force-poll,unstable,time -- --nocapture &&
sleep 0.5
echo "\n\nTesting with wasm32: $1"
cargo t $1 --features wasm32,derive,log,force-poll,unstable,time --target wasm32-unknown-unknown
}
cargo_test_timeout() {
echo "\n\nTesting with tokio with 5s timeout: $1"
timeout 5 cargo t $1 --features tokio,derive,log,force-poll,unstable,time -- --nocapture &&
sleep 0.5
echo "\n\nTesting with async-std with 5s timeout: $1"
timeout 5 cargo t $1 --features async-std,derive,log,force-poll,unstable,time -- --nocapture &&
sleep 0.5
echo "\n\nTesting with wasm32 with 5s timeout: $1"
timeout 5 cargo t $1 --features wasm32,derive,log,force-poll,unstable,time --target wasm32-unknown-unknown
}
cargo_example() {
echo "\n\nRun example with tokio: $1"
cargo r --example $1 --features tokio,log -- --nocapture &&
sleep 0.5
echo "\n\nRun example with async-std: $1"
cargo r --example $1 --features async-std,log -- --nocapture
}
case $1 in
c | check)
echo "Checking without features ..."
cargo c --features core &&
sleep 1
echo "\n\nChecking feature std ..."
cargo c --features std &&
sleep 1
echo "\n\nChecking feature tokio ..."
cargo c --features tokio &&
sleep 1
echo "\n\nChecking feature tokio with time ..."
cargo c --features tokio,time,log &&
sleep 1
echo "\n\nChecking feature unstable tokio ..."
cargo c --features tokio,force-poll,unstable,time-metric,time,log &&
sleep 1
echo "\n\nChecking feature async std ..."
cargo c --features async-std &&
sleep 1
echo "\n\nChecking feature async std with time ..."
cargo c --features async-std,time,log &&
sleep 1
echo "\n\nChecking feature unstable async std ..."
cargo c --features async-std,force-poll,unstable,time-metric,time,log &&
sleep 1
echo "\n\nChecking feature wasm32 ..."
cargo c --features wasm32 --target wasm32-unknown-unknown
sleep 1
echo "\n\nChecking feature wasm32 with time ..."
cargo c --features wasm32,time,log --target wasm32-unknown-unknown
sleep 1
echo "\n\nChecking feature unstable wasm32 ..."
cargo c --features wasm32,force-poll,unstable,time-metric,time,log --target wasm32-unknown-unknown
;;
t | test)
[ -z "$2" ] && {
cargo_test test_routine &&
sleep 0.5
cargo_test test_stream &&
sleep 0.5
cargo_test test_block &&
sleep 0.5
cargo_test test_mstream &&
sleep 0.5
cargo_test_timeout test_delay
echo "\n\t\033[0;32mCongratulations! all testings PASS with NO errors\033[0m\n"
exit 0
} || {
echo "test target: $2"
cargo_test $2
}
;;
demo | example)
cargo_example ping &&
sleep 0.5
cargo_example fibonacci &&
sleep 0.5 &&
cargo_example ring &&
cd examples/no-std && cargo r && cd ..
cd wasm32 && trunk serve
;;
-h | --help | h | help)
echo "A simple dev tool for crossbus.\n
\033[0;32mrunner t\033[0m (or \033[0;32mtest\033[0m) to run all integration testing with different features
\033[0;32mrunner c\033[0m (or \033[0;32mcheck\033[0m) to check the whole project with different features
\033[0;32mrunner demo\033[0m (or \033[0;32mexample\033[0m) to run all the examples
\033[0;32mrunner h\033[0m (or \033[0;32mhelp\033[0m) to print this help message"
;;
*)
echo "Invalid command: $1"
;;
esac