#!/usr/bin/env bash set -e global count_only_flag := ''"" if test $1 = "-c" { global count_only_flag := '1' shift } global extended_syntax_flag := ''"" if test $1 = "-x" { global extended_syntax_flag := '"-x'" shift } trap "kill 0; exit 1" int global count := '0' for filename in [@Argv] { let count+="$[bats-exec-test -c $filename]" } if test -n $count_only_flag { echo $count exit } echo "1..$count" global status := '0' global offset := '0' for filename in [@Argv] { global index := '0' do { env IFS= read -r # 1..n while IFS= read -r line { matchstr $line { "begin "* { let index+=1 echo $(line/ $index / $(($offset + $index)) ) } "ok "* | "not ok "* { test -n $extended_syntax_flag || let index+=1 echo $(line/ $index / $(($offset + $index)) ) test $(line:0:6) != "not ok" || global status := '1' } * { echo $line } } } } < <( bats-exec-test $extended_syntax_flag "$filename" ) global offset := $($offset + $index) } exit $status (CommandList children: [ (C {(set)} {(-e)}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:count_only_flag) op:Equal rhs:{(DQ )} spids:[8])] spids: [8] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Number "$1"))} {(Lit_Other "=")} {(DQ (-c))} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:count_only_flag) op:Equal rhs:{(1)} spids:[32])] spids: [32] ) (C {(shift)}) ] spids: [-1 29] ) ] spids: [-1 38] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:extended_syntax_flag) op:Equal rhs:{(DQ )} spids:[41])] spids: [41] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Number "$1"))} {(Lit_Other "=")} {(DQ (-x))} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:extended_syntax_flag) op: Equal rhs: {(DQ (-x))} spids: [65] ) ] spids: [65] ) (C {(shift)}) ] spids: [-1 62] ) ] spids: [-1 73] ) (C {(trap)} {(DQ ("kill 0; exit 1"))} {(int)}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:count) op:Equal rhs:{(0)} spids:[85])] spids: [85] ) (ForEach iter_name: filename iter_words: [{(DQ ($ VSub_At "$@"))}] do_arg_iter: False body: (DoGroup children: [ (C {(let)} {(Lit_VarLike "count+=") (DQ (CommandSubPart command_list: (CommandList children: [(C {(bats-exec-test)} {(-c)} {(DQ ($ VSub_Name "$filename"))})] ) left_token: spids: [106 114] ) ) } ) ] spids: [99 117] ) spids: [93 97] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-n)} {(DQ ($ VSub_Name "$count_only_flag"))} {(Lit_Other "]")}) terminator: ) ] action: [(C {(echo)} {(DQ ($ VSub_Name "$count"))}) (C {(exit)})] spids: [-1 133] ) ] spids: [-1 145] ) (C {(echo)} {(DQ (1..) ($ VSub_Name "$count"))}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:status) op:Equal rhs:{(0)} spids:[155])] spids: [155] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:offset) op:Equal rhs:{(0)} spids:[158])] spids: [158] ) (ForEach iter_name: filename iter_words: [{(DQ ($ VSub_At "$@"))}] do_arg_iter: False body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:index) op:Equal rhs:{(0)} spids:[175])] spids: [175] ) (BraceGroup children: [ (SimpleCommand words: [{(read)} {(-r)}] more_env: [(env_pair name:IFS val:{(SQ )} spids:[182])] ) (While cond: [ (Sentence child: (SimpleCommand words: [{(read)} {(-r)} {(line)}] more_env: [(env_pair name:IFS val:{(SQ )} spids:[194])] ) terminator: ) ] body: (DoGroup children: [ (Case to_match: {(DQ ($ VSub_Name "$line"))} arms: [ (case_arm pat_list: [{(DQ ("begin ")) (Lit_Other "*")}] action: [ (C {(let)} {(Lit_VarLike "index+=") (1)}) (C {(echo)} { (DQ (BracedVarSub token: suffix_op: (PatSub pat: {(" ") ($ VSub_Name "$index") (" ")} replace: {(" ") (ArithSubPart anode: (ArithBinary op_id: Arith_Plus left: (ArithWord w:{($ VSub_Name "$offset")}) right: (ArithWord w:{($ VSub_Name "$index")}) ) spids: [240 247] ) (" ") } do_all: False do_prefix: False do_suffix: False ) spids: [232 249] ) ) } ) ] spids: [216 220 253 -1] ) (case_arm pat_list: [ {(DQ ("ok ")) (Lit_Other "*")} {(DQ ("not ok ")) (Lit_Other "*")} ] action: [ (AndOr children: [ (C {(Lit_Other "[")} {(-n)} {(DQ ($ VSub_Name "$extended_syntax_flag"))} {(Lit_Other "]")} ) (C {(let)} {(Lit_VarLike "index+=") (1)}) ] op_id: Op_DPipe ) (C {(echo)} { (DQ (BracedVarSub token: suffix_op: (PatSub pat: {(" ") ($ VSub_Name "$index") (" ")} replace: {(" ") (ArithSubPart anode: (ArithBinary op_id: Arith_Plus left: (ArithWord w:{($ VSub_Name "$offset")}) right: (ArithWord w:{($ VSub_Name "$index")}) ) spids: [300 307] ) (" ") } do_all: False do_prefix: False do_suffix: False ) spids: [292 309] ) ) } ) (AndOr children: [ (C {(Lit_Other "[")} { (DQ (BracedVarSub token: suffix_op: (Slice begin: (ArithWord w:{(Lit_Digits 0)}) length: (ArithWord w:{(Lit_Digits 6)}) ) spids: [316 322] ) ) } {(KW_Bang "!") (Lit_Other "=")} {(DQ ("not ok"))} {(Lit_Other "]")} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:status) op: Equal rhs: {(1)} spids: [336] ) ] spids: [336] ) ] op_id: Op_DPipe ) ] spids: [257 268 340 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [(C {(echo)} {(DQ ($ VSub_Name "$line"))})] spids: [343 345 355 -1] ) ] spids: [206 212 358] ) ] spids: [203 361] ) ) ] redirects: [ (Redir op_id: Redir_Less fd: -1 arg_word: { (CommandSubPart command_list: (CommandList children: [ (C {(bats-exec-test)} {($ VSub_Name "$extended_syntax_flag")} {(DQ ($ VSub_Name "$filename"))} ) ] ) left_token: spids: [368 378] ) } spids: [366] ) ] spids: [179] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:offset) op: Equal rhs: { (ArithSubPart anode: (ArithBinary op_id: Arith_Plus left: (ArithWord w:{($ VSub_Name "$offset")}) right: (ArithWord w:{($ VSub_Name "$index")}) ) spids: [382 389] ) } spids: [381] ) ] spids: [381] ) ] spids: [172 391] ) spids: [166 170] ) (C {(exit)} {(DQ ($ VSub_Name "$status"))}) ] )