diff --git a/lib/gates.sh b/lib/gates.sh index bbda35f..ead6a0c 100644 --- a/lib/gates.sh +++ b/lib/gates.sh @@ -107,8 +107,10 @@ _absorb() { # _absorb elif [[ "$1" =~ ^[0-9] ]]; then _err "malformed criterion label at line $2 (want \`N. text\`)" _CUR=-1 - elif [[ "$1" =~ ^ABANDON:[[:space:]]*([0-9]+)?[[:space:]]*(.*)$ ]]; then - _ABANDON_ID+=("${BASH_REMATCH[1]}"); _ABANDON_WHY+=("${BASH_REMATCH[2]}") + elif [[ "$1" =~ ^[[:space:]]*ABANDON:[[:space:]]*([0-9]+)([[:space:]]+(.*))?$ ]]; then + _ABANDON_ID+=("${BASH_REMATCH[1]}"); _ABANDON_WHY+=("${BASH_REMATCH[3]}") + elif [[ "$1" =~ ^[[:space:]]*ABANDON: ]]; then + _err "malformed ABANDON at line $2 (want \`ABANDON: N reason\`)" elif [[ "$1" =~ ^(CHECK|EXPECT|EVIDENCE): ]]; then _err "unindented ${BASH_REMATCH[1]}: at line $2" elif [[ "$1" =~ ^[[:space:]]+(CHECK|EXPECT|EVIDENCE):(.*)$ ]]; then diff --git a/lib/tests/gates.test.sh b/lib/tests/gates.test.sh index 92a18d6..f360c82 100644 --- a/lib/tests/gates.test.sh +++ b/lib/tests/gates.test.sh @@ -302,6 +302,61 @@ gate "abandonment naming nothing" run "unknown criterion" 2 <<'EOF' ABANDON: 9 names a criterion that does not exist EOF +gate "abandonment id 1b is malformed" run "malformed ABANDON" 2 <<'EOF' +## ACCEPTANCE CRITERIA +1. green + CHECK: echo "M" + EXPECT: M + EVIDENCE: pending +2. manual + +ABANDON: 1b moved after renumber +EOF + +gate "abandonment id 1.1 is malformed" run "malformed ABANDON" 2 <<'EOF' +## ACCEPTANCE CRITERIA +1. green + CHECK: echo "M" + EXPECT: M + EVIDENCE: pending +2. manual + +ABANDON: 1.1 moved after renumber +EOF + +gate "abandonment without id is malformed" run "malformed ABANDON" 2 <<'EOF' +## ACCEPTANCE CRITERIA +1. green + CHECK: echo "M" + EXPECT: M + EVIDENCE: pending +2. manual + +ABANDON: upstream offline +EOF + +gate "indented malformed abandonment" run "malformed ABANDON" 2 <<'EOF' +## ACCEPTANCE CRITERIA +1. green + CHECK: echo "M" + EXPECT: M + EVIDENCE: pending +2. manual + + ABANDON: 1b moved +EOF + +gate "indented abandonment counts" run "GATES — VERDICT: ABANDONED(1)" 3 <<'EOF' +## ACCEPTANCE CRITERIA +1. green + CHECK: echo "M" + EXPECT: M + EVIDENCE: pending +2. manual + + ABANDON: 2 upstream offline +EOF + echo "── usage ──" # usage