seed: curriculum content
This commit is contained in:
39
1.solar-system/1.welcome/06.the-reader/testing/test.sh
Normal file
39
1.solar-system/1.welcome/06.the-reader/testing/test.sh
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
cat > mission-log.txt <<'LOG'
|
||||
[1969-07-20 13:32] Apollo touchdown confirmed.
|
||||
[1969-07-20 13:33] Surface stable.
|
||||
[1969-07-20 13:34] Cabin sealed.
|
||||
[1969-07-20 13:35] EVA prep started.
|
||||
[1969-07-20 13:40] Hatch open check.
|
||||
[1969-07-20 13:42] Suit pressurization complete.
|
||||
[1969-07-20 13:50] Ladder deployed.
|
||||
[1969-07-20 13:55] First step recorded.
|
||||
[1969-07-20 14:00] Sample collection begun.
|
||||
[1969-07-20 14:10] All systems nominal.
|
||||
[1969-07-20 14:20] Communication test passed.
|
||||
[1969-07-20 14:30] Second sample box sealed.
|
||||
[1969-07-20 14:40] Solar panel deployed.
|
||||
[1969-07-20 14:50] Flag planted.
|
||||
[1969-07-20 15:00] Phone call inbound.
|
||||
[1969-07-20 15:10] Phone call complete.
|
||||
[1969-07-20 15:20] Sample box stowed.
|
||||
[1969-07-20 15:30] EVA wrap-up started.
|
||||
[1969-07-20 15:35] Hatch closed.
|
||||
[1969-07-20 15:40] Cabin re-pressurized.
|
||||
LOG
|
||||
|
||||
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 first-five.txt ]; report $? "first-five.txt exists"
|
||||
diff -q <(head -n 5 mission-log.txt) first-five.txt > /dev/null 2>&1; report $? "first-five.txt matches head -n 5"
|
||||
[ -f last-three.txt ]; report $? "last-three.txt exists"
|
||||
diff -q <(tail -n 3 mission-log.txt) last-three.txt > /dev/null 2>&1; report $? "last-three.txt matches tail -n 3"
|
||||
[ -f line-count.txt ]; report $? "line-count.txt exists"
|
||||
COUNT=$(awk '{print $1}' line-count.txt 2>/dev/null | tr -d ' ')
|
||||
[ "$COUNT" = "20" ]; report $? "line-count.txt contains 20"
|
||||
Reference in New Issue
Block a user