|
1 | 1 | #!/usr/bin/env bash
|
2 | 2 |
|
| 3 | +set -euo pipefail |
| 4 | + |
| 5 | +verdi devel check-load-time |
| 6 | +verdi devel check-undesired-imports |
| 7 | + |
3 | 8 | # Test the loading time of `verdi`. This is an attempt to catch changes to the imports in `aiida.cmdline` that
|
4 | 9 | # would slow down `verdi` invocations and make tab-completion unusable.
|
5 | 10 | VERDI=`which verdi`
|
6 | 11 |
|
7 |
| -# Typically, the loading time of `verdi` should be around ~0.2 seconds. |
| 12 | +# Typically, the loading time of `verdi` should be around <0.2 seconds. |
8 | 13 | # Typically these types of tests are fragile. But with a load limit of more than twice
|
9 | 14 | # the ideal loading time, if exceeded, should give a reasonably sure indication
|
10 | 15 | # that the loading of `verdi` is unacceptably slowed down.
|
11 |
| -LOAD_LIMIT=0.4 |
| 16 | +LOAD_LIMIT=0.3 |
12 | 17 | MAX_NUMBER_ATTEMPTS=5
|
13 | 18 |
|
14 | 19 | iteration=0
|
15 | 20 |
|
16 | 21 | while true; do
|
17 | 22 |
|
18 | 23 | iteration=$((iteration+1))
|
19 |
| - load_time=$(/usr/bin/time -q -f "%e" $VERDI 2>&1 > /dev/null) |
| 24 | + load_time=$(/usr/bin/time -q -f "%e" $VERDI -h 2>&1 > /dev/null) |
20 | 25 |
|
21 | 26 | if (( $(echo "$load_time < $LOAD_LIMIT" | bc -l) )); then
|
22 | 27 | echo "SUCCESS: loading time $load_time at iteration $iteration below $LOAD_LIMIT"
|
|
36 | 41 |
|
37 | 42 | # Test that we can also run the CLI via `python -m aiida`,
|
38 | 43 | # that it returns a 0 exit code, and contains the expected stdout.
|
39 |
| -echo "Invoking verdi via `python -m aiida`" |
40 |
| -OUTPUT=$(python -m aiida 2>&1) |
| 44 | +echo "Invoking verdi via 'python -m aiida -h'" |
| 45 | +OUTPUT=$(python -m aiida -h 2>&1) |
41 | 46 | RETVAL=$?
|
42 |
| -echo $OUTPUT |
43 | 47 | if [ $RETVAL -ne 0 ]; then
|
44 | 48 | echo "'python -m aiida' exitted with code $RETVAL"
|
| 49 | + echo "=== OUTPUT ===" |
| 50 | + echo $OUTPUT |
45 | 51 | exit 2
|
46 | 52 | fi
|
47 | 53 | if [[ $OUTPUT != *"command line interface of AiiDA"* ]]; then
|
48 | 54 | echo "'python -m aiida' did not contain the expected stdout:"
|
| 55 | + echo "=== OUTPUT ===" |
| 56 | + echo $OUTPUT |
49 | 57 | exit 2
|
50 | 58 | fi
|
0 commit comments