seed: curriculum content
This commit is contained in:
21
1.solar-system/1.welcome/09.the-scripter/testing/test.sh
Normal file
21
1.solar-system/1.welcome/09.the-scripter/testing/test.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
mkdir -p supplies
|
||||
touch supplies/oxygen-tank.txt \
|
||||
supplies/ration-pack.txt \
|
||||
supplies/medkit.txt \
|
||||
supplies/repair-kit.txt \
|
||||
supplies/comms-unit.txt
|
||||
|
||||
bash solution.sh > /dev/null 2>&1
|
||||
|
||||
N=0
|
||||
report() { N=$((N+1)); if [ "$1" = "0" ]; then echo "ok $N - $2"; else echo "not ok $N - $2"; fi; }
|
||||
|
||||
[ -f report.txt ]; report $? "report.txt exists"
|
||||
|
||||
TODAY=$(date '+%Y-%m-%d')
|
||||
LINE1=$(sed -n '1p' report.txt 2>/dev/null)
|
||||
LINE2=$(sed -n '2p' report.txt 2>/dev/null)
|
||||
|
||||
[ "$LINE1" = "Date: $TODAY" ]; report $? "line 1 is 'Date: $TODAY'"
|
||||
[ "$LINE2" = "Files in supplies: 5" ]; report $? "line 2 is 'Files in supplies: 5'"
|
||||
Reference in New Issue
Block a user