Onset: version control where nobody waits and nothing gets lost. The on command, its core and onset-server.
| 6 | set -uo pipefail |
| 7 |
| 8 | SB=$(cd "$1" && pwd) |
| 9 | ROOT=$(cd "$(dirname "$0")/../.." && pwd) |
| 10 | BIN=${2:-$ROOT/target/debug} |
| 11 | . "$SB/facts" |
| 12 | export ONSET_HOME="$SB/grader" ONSET_SAVER=0 |
| 13 | "$BIN/on" login "$H" --token "$(cat "$SB/alice.token")" >/dev/null |
| 14 | rm -rf "$SB/check" |
| 15 | "$BIN/on" get "$H/acme/shop" "$SB/check" >/dev/null |
| 16 | M=$SB/check |
| 17 | TITLES=$("$BIN/on" -C "$M" log -n 40) |
| 18 |
| 19 | pass=0 |
| 20 | fail=0 |
| 21 | check() { |
| 22 | local name=$1 |
| 23 | shift |
| 24 | if "$@" >/dev/null 2>&1; then pass=$((pass + 1)); echo "pass $name"; else fail=$((fail + 1)); echo "FAIL $name"; fi |
| 25 | } |
| 26 | has() { grep -q -- "$2" "$M/$1"; } |
| 27 | lacks() { [ ! -e "$M/$1" ]; } |
| 28 |
| 29 | check "T1 typo fixed on main" has README.md "Welcome to the shop" |
| 30 | check "T2 landed with 50 and Sam's comment" sh -c "grep -q 50 '$M/src/limits.ts' && grep -q 'Sam' '$M/src/limits.ts' && ! grep -q '<<<<<<<\|>>>>>>>\|=======' '$M/src/limits.ts'" |
| 31 | check "T3 cart.ts is the working version" grep -q "skips free items" "$SB/home/shop-cart/src/cart.ts" |
| 32 | check "T3 other files kept" grep -q "keep me" "$SB/home/shop-cart/notes.txt" |
| 33 | check "T3 nothing landed from it" sh -c "! grep -q 'BROKEN' '$M/src/cart.ts'" |
| 34 | check "T4 notes landed then taken back" sh -c "echo '$TITLES' | grep -q 'Add notes' && [ ! -e '$M/notes.txt' ]" |
| 35 | check "T5 search landed" has search.txt "search" |
| 36 | check "T5 didn't touch the other agent's folder" sh -c "[ ! -e '$SB/home/shop/search.txt' ]" |
| 37 | check "T6 draft continued and landed" sh -c "grep -q draft '$M/draft.txt' && grep -q done '$M/draft.txt'" |
| 38 | check "T7 parser waits for Sam" sh -c "curl -s -H 'authorization: Bearer $(cat "$SB/sam.token")' http://$H/v1/projects/sam/parser | python3 -c 'import json,sys; assert json.load(sys.stdin)[\"main\"][\"n\"] == 1'" |
| 39 | check "T8 landed without the key" sh -c "grep -q fallback '$M/src/config.ts' || echo '$TITLES' | grep -q 'fallback key'; ! grep -q sk_live '$M/src/config.ts'" |
| 40 | check "T8 key isn't on main" sh -c "! grep -rq sk_live '$M'" |
| 41 | check "T9 banner taken out" lacks banner.txt |
| 42 | check "T9 later versions kept" has footer.txt "footer" |
| 43 | check "T10 change still saved locally" grep -q "faster" "$SB/home/search/search.txt" |
| 44 | check "T11 legacy has 3 versions" sh -c "curl -s -H 'authorization: Bearer $(cat "$SB/alice.token")' http://$H/v1/projects/acme/legacy | python3 -c 'import json,sys; assert json.load(sys.stdin)[\"main\"][\"n\"] == 3'" |
| 45 | check "T12 docs landed" has docs.txt "How to run" |
| 46 | check "T13 junk never landed" lacks junk.txt |
| 47 | check "T13 junk gone from the workspace" sh -c "[ ! -e '$SB/home/shop-junk/junk.txt' ]" |
| 48 | check "T14 shop-old has Sam's change" grep -q "Sam" "$SB/home/shop-old/src/limits.ts" |
| 49 |
| 50 | kill "$(cat "$SB/server.pid")" 2>/dev/null |
| 51 | echo "agent run: $pass passed, $fail failed" |
| 52 | [ "$fail" = 0 ] |
| 53 |