#!/bin/bash git init -q -b main git config user.name "Setup" git config user.email "setup@learnroom.local" echo "manifest" > manifest.txt; git add manifest.txt; git commit -q -m "add manifest" echo "sensor a online" > sensor-a.txt; git add sensor-a.txt; git commit -q -m "add sensor A" echo "breach details" > breach.txt; git add breach.txt; git commit -q -m "investigate BREACH at sector C" echo "sensor b online" > sensor-b.txt; git add sensor-b.txt; git commit -q -m "add sensor B" echo "resolution applied" > resolution.txt; git add resolution.txt; git commit -q -m "apply resolution" 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 log.txt ]; report $? "log.txt exists" LINES=$(wc -l < log.txt | tr -d ' ') [ "$LINES" = "5" ]; report $? "log.txt has 5 lines (one per commit)" [ -f breach-commit.txt ]; report $? "breach-commit.txt exists" ACTUAL=$(tr -d '[:space:]' < breach-commit.txt 2>/dev/null) EXPECTED=$(git log --grep BREACH --format=%h) [ "$ACTUAL" = "$EXPECTED" ]; report $? "breach-commit.txt contains the BREACH commit's short hash"