(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:expectedF) op: assign_op.Equal rhs: { (DQ (braced_var_sub token: (Token id:Id.VSub_Name val:TMPDIR span_id:49) suffix_op: (suffix_op.Unary op_id: Id.VTest_ColonHyphen arg_word: {(Id.Lit_Slash /) (tmp)} ) ) (/expected) ) } spids: [46] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:returnF) op: assign_op.Equal rhs: { (DQ (braced_var_sub token: (Token id:Id.VSub_Name val:TMPDIR span_id:60) suffix_op: (suffix_op.Unary op_id: Id.VTest_ColonHyphen arg_word: {(Id.Lit_Slash /) (tmp)} ) ) (/return) ) } spids: [57] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:stdoutF) op: assign_op.Equal rhs: { (DQ (braced_var_sub token: (Token id:Id.VSub_Name val:TMPDIR span_id:71) suffix_op: (suffix_op.Unary op_id: Id.VTest_ColonHyphen arg_word: {(Id.Lit_Slash /) (tmp)} ) ) (/STDOUT) ) } spids: [68] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:stderrF) op: assign_op.Equal rhs: { (DQ (braced_var_sub token: (Token id:Id.VSub_Name val:TMPDIR span_id:82) suffix_op: (suffix_op.Unary op_id: Id.VTest_ColonHyphen arg_word: {(Id.Lit_Slash /) (tmp)} ) ) (/STDERR) ) } spids: [79] ) ] ) (C {(.)} {(./shflags_test_helpers)}) (command.ShFunction name: testHelp body: (command.BraceGroup children: [ (C {(_testHelp)} {(SQ (Token id:Id.Lit_Chars val:-h span_id:109))}) (command.AndOr ops: [Id.Op_DPipe] children: [ (C {(flags_getoptIsEnh)}) (command.ControlFlow token: (Token id:Id.ControlFlow_Return val:return span_id:117) ) ] ) (C {(_testHelp)} {(SQ (Token id:Id.Lit_Chars val:--help span_id:123))}) ] ) ) (command.ShFunction name: _testHelp body: (command.BraceGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:flag) op: assign_op.Equal rhs: {($ Id.VSub_Number '$1')} spids: [136] ) ] ) (C {(th_clearReturn)}) (command.Subshell command_list: (command.CommandList children: [ (command.Simple words: [{(FLAGS)} {(DQ (${ Id.VSub_Name flag))}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:159) fd: -1 arg_word: {(DQ (${ Id.VSub_Name stdoutF))} ) (redir.Redir op: (Token id:Id.Redir_Great val:'2>' span_id:166) fd: 2 arg_word: {(DQ (${ Id.VSub_Name stderrF))} ) ] ) (command.Simple words: [{(echo)} {($ Id.VSub_QMark '$?')}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:178) fd: -1 arg_word: {(DQ (${ Id.VSub_Name returnF))} ) ] ) ] ) ) (C {(assertFalse)} { (SQ (Token id: Id.Lit_Chars val: 'a call for help should return a non-zero exit code.' span_id: 194 ) ) } { (DQ (command_sub left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:200) command_list: (command.CommandList children:[(C {(th_queryReturn)})]) ) ) } ) (command.Simple words: [ {(grep)} {(SQ (Token id:Id.Lit_Chars val:'show this help' span_id:209))} {(DQ (${ Id.VSub_Name stderrF))} ] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:218) fd: -1 arg_word: {(/dev/null)} ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:grepped) op: assign_op.Equal rhs: {($ Id.VSub_QMark '$?')} spids: [222] ) ] ) (C {(assertTrue)} { (SQ (Token id: Id.Lit_Chars val: 'short request for help should have produced some help output.' span_id: 231 ) ) } {(${ Id.VSub_Name grepped)} ) (command.AndOr ops: [Id.Op_DAmp] children: [ (C {(Id.Lit_LBracket '[')} {(${ Id.VSub_Name grepped)} {(-ne)} {(DQ (${ Id.VSub_Name FLAGS_TRUE))} {(Id.Lit_RBracket ']')} ) (C {(th_showOutput)}) ] ) (command.Subshell command_list: (command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:FLAGS_HELP) op: assign_op.Equal rhs: {(SQ (Token id:Id.Lit_Chars val:'this is a test' span_id:272))} spids: [270] ) ] ) (command.Simple words: [{(FLAGS)} {(DQ (${ Id.VSub_Name flag))}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:284) fd: -1 arg_word: {(DQ (${ Id.VSub_Name stdoutF))} ) (redir.Redir op: (Token id:Id.Redir_Great val:'2>' span_id:291) fd: 2 arg_word: {(DQ (${ Id.VSub_Name stderrF))} ) ] ) ] ) ) (command.Simple words: [ {(grep)} {(SQ (Token id:Id.Lit_Chars val:'this is a test' span_id:305))} {(DQ (${ Id.VSub_Name stderrF))} ] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:314) fd: -1 arg_word: {(/dev/null)} ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:grepped) op: assign_op.Equal rhs: {($ Id.VSub_QMark '$?')} spids: [318] ) ] ) (C {(assertTrue)} { (SQ (Token id: Id.Lit_Chars val: 'setting FLAGS_HELP did not produce expected result' span_id: 325 ) ) } {(${ Id.VSub_Name grepped)} ) (command.AndOr ops: [Id.Op_DAmp] children: [ (C {(Id.Lit_LBracket '[')} {(${ Id.VSub_Name grepped)} {(-ne)} {(DQ (${ Id.VSub_Name FLAGS_TRUE))} {(Id.Lit_RBracket ']')} ) (C {(th_showOutput)}) ] ) (command.Subshell command_list: (command.CommandList children: [ (C {(DEFINE_boolean)} {(b)} {(false)} {(DQ ("help string containing a ' char"))} {(b)}) (command.Simple words: [{(FLAGS)} {(DQ (${ Id.VSub_Name flag))}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:383) fd: -1 arg_word: {(DQ (${ Id.VSub_Name stdoutF))} ) (redir.Redir op: (Token id:Id.Redir_Great val:'2>' span_id:390) fd: 2 arg_word: {(DQ (${ Id.VSub_Name stderrF))} ) ] ) ] ) ) (command.Simple words: [ {(grep)} {(DQ ("help string containing a ' char"))} {(DQ (${ Id.VSub_Name stderrF))} ] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:413) fd: -1 arg_word: {(/dev/null)} ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:grepped) op: assign_op.Equal rhs: {($ Id.VSub_QMark '$?')} spids: [417] ) ] ) (C {(assertTrue)} {(DQ ("help strings containing apostrophes don't work"))} {(${ Id.VSub_Name grepped)} ) (command.AndOr ops: [Id.Op_DAmp] children: [ (C {(Id.Lit_LBracket '[')} {(${ Id.VSub_Name grepped)} {(-ne)} {(DQ (${ Id.VSub_Name FLAGS_TRUE))} {(Id.Lit_RBracket ']')} ) (C {(th_showOutput)}) ] ) ] ) ) (command.ShFunction name: mock_flags_columns body: (command.BraceGroup children:[(C {(echo)} {(80)})]) ) (command.ShFunction name: testStandardHelpOutput body: (command.BraceGroup children: [ (command.AndOr ops: [Id.Op_DPipe] children: [(C {(flags_getoptIsStd)}) (C {(startSkipping)})] ) (C {(DEFINE_boolean)} {(test_bool)} {(false)} {(SQ (Token id:Id.Lit_Chars val:'test boolean' span_id:491))} {(b)} ) (C {(DEFINE_integer)} {(test_int)} {(0)} {(SQ (Token id:Id.Lit_Chars val:'test integer' span_id:504))} {(i)} ) (C {(DEFINE_string)} {(test_str)} {(SQ )} {(SQ (Token id:Id.Lit_Chars val:'test string' span_id:518))} {(s)} ) (C {(DEFINE_string)} {(long_desc)} {(SQ (Token id:Id.Lit_Chars val:blah span_id:529))} { (SQ (Token id: Id.Lit_Chars val: 'testing of a long description to force wrap of default value' span_id: 535 ) ) } {(D)} ) (C {(DEFINE_string)} {(long_default)} { (SQ (Token id: Id.Lit_Chars val: this_is_a_long_default_value_to_force_alternate_indentation span_id: 548 ) ) } {(SQ (Token id:Id.Lit_Chars val:'testing of long default value' span_id:554))} {(F)} ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:help) op: assign_op.Equal rhs: {(SQ (Token id:Id.Lit_Chars val:'USAGE: standard [flags] args' span_id:562))} spids: [560] ) ] ) (command.Simple words: [{(cat)}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:569) fd: -1 arg_word: {(DQ (${ Id.VSub_Name expectedF))} ) (redir.HereDoc op: (Token id:Id.Redir_DLess val:'<<' span_id:576) fd: -1 here_begin: {(EOF)} here_end_span_id: 593 stdin_parts: [ (${ Id.VSub_Name help) ('\n') ('flags:\n') (' -b test boolean (default: false)\n') (' -i test integer (default: 0)\n') (" -s test string (default: '')\n") (' -D testing of a long description to force wrap of default value\n') (" (default: 'blah')\n") (' -F testing of long default value\n') ( " (default: 'this_is_a_long_default_value_to_force_alternate_indentation')\n" ) (' -h show this help (default: false)\n') ] ) ] ) (command.Subshell command_list: (command.CommandList children: [ (command.ShFunction name: _flags_columns body: (command.BraceGroup children: [ (command.Sentence child: (C {(mock_flags_columns)}) terminator: (Token id:Id.Op_Semi val:';' span_id:605) ) ] ) ) (command.Sentence child: (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:FLAGS_HELP) op: assign_op.Equal rhs: {(${ Id.VSub_Name help)} spids: [610] ) ] ) terminator: (Token id:Id.Op_Semi val:';' span_id:614) ) (command.Simple words: [{(FLAGS)} {(-h)}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:621) fd: -1 arg_word: {(DQ (${ Id.VSub_Name stdoutF))} ) (redir.Redir op: (Token id:Id.Redir_Great val:'2>' span_id:628) fd: 2 arg_word: {(DQ (${ Id.VSub_Name stderrF))} ) ] ) (command.Simple words: [{(echo)} {($ Id.VSub_QMark '$?')}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:640) fd: -1 arg_word: {(DQ (${ Id.VSub_Name returnF))} ) ] ) ] ) ) (C {(assertFalse)} { (SQ (Token id: Id.Lit_Chars val: 'a call for help should return a non-zero exit code.' span_id: 656 ) ) } { (DQ (command_sub left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:662) command_list: (command.CommandList children:[(C {(th_queryReturn)})]) ) ) } ) (command.Simple words: [{(diff)} {(DQ (${ Id.VSub_Name expectedF))} {(DQ (${ Id.VSub_Name stderrF))}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:683) fd: -1 arg_word: {(/dev/null)} ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:r3turn) op: assign_op.Equal rhs: {($ Id.VSub_QMark '$?')} spids: [687] ) ] ) (C {(assertTrue)} {(SQ (Token id:Id.Lit_Chars val:'unexpected help output' span_id:694))} {(${ Id.VSub_Name r3turn)} ) (C {(th_showOutput)} {(${ Id.VSub_Name r3turn)} {(DQ (${ Id.VSub_Name stdoutF))} {(DQ (${ Id.VSub_Name stderrF))} ) ] ) ) (command.ShFunction name: testEnhancedHelpOutput body: (command.BraceGroup children: [ (command.AndOr ops: [Id.Op_DPipe] children: [(C {(flags_getoptIsEnh)}) (C {(startSkipping)})] ) (C {(DEFINE_boolean)} {(test_bool)} {(false)} {(SQ (Token id:Id.Lit_Chars val:'test boolean' span_id:745))} {(b)} ) (C {(DEFINE_integer)} {(test_int)} {(0)} {(SQ (Token id:Id.Lit_Chars val:'test integer' span_id:758))} {(i)} ) (C {(DEFINE_string)} {(test_str)} {(SQ )} {(SQ (Token id:Id.Lit_Chars val:'test string' span_id:772))} {(s)} ) (C {(DEFINE_string)} {(long_desc)} {(SQ (Token id:Id.Lit_Chars val:blah span_id:783))} { (SQ (Token id: Id.Lit_Chars val: 'testing of a long description to force wrap of default value' span_id: 789 ) ) } {(D)} ) (C {(DEFINE_string)} {(long_default)} { (SQ (Token id: Id.Lit_Chars val: this_is_a_long_default_value_to_force_alternate_indentation span_id: 802 ) ) } {(SQ (Token id:Id.Lit_Chars val:'testing of long default value' span_id:808))} {(F)} ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:help) op: assign_op.Equal rhs: {(SQ (Token id:Id.Lit_Chars val:'USAGE: enhanced [flags] args' span_id:816))} spids: [814] ) ] ) (command.Simple words: [{(cat)}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:823) fd: -1 arg_word: {(DQ (${ Id.VSub_Name expectedF))} ) (redir.HereDoc op: (Token id:Id.Redir_DLess val:'<<' span_id:830) fd: -1 here_begin: {(EOF)} here_end_span_id: 847 stdin_parts: [ (${ Id.VSub_Name help) ('\n') ('flags:\n') (' -b,--[no]test_bool: test boolean (default: false)\n') (' -i,--test_int: test integer (default: 0)\n') (" -s,--test_str: test string (default: '')\n") ( ' -D,--long_desc: testing of a long description to force wrap of default value\n' ) (" (default: 'blah')\n") (' -F,--long_default: testing of long default value\n') ( " (default: 'this_is_a_long_default_value_to_force_alternate_indentation')\n" ) (' -h,--help: show this help (default: false)\n') ] ) ] ) (command.Subshell command_list: (command.CommandList children: [ (command.ShFunction name: _flags_columns body: (command.BraceGroup children: [ (command.Sentence child: (C {(mock_flags_columns)}) terminator: (Token id:Id.Op_Semi val:';' span_id:859) ) ] ) ) (command.Sentence child: (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:FLAGS_HELP) op: assign_op.Equal rhs: {(${ Id.VSub_Name help)} spids: [868] ) ] ) terminator: (Token id:Id.Op_Semi val:';' span_id:872) ) (command.Simple words: [{(FLAGS)} {(-h)}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:879) fd: -1 arg_word: {(DQ (${ Id.VSub_Name stdoutF))} ) (redir.Redir op: (Token id:Id.Redir_Great val:'2>' span_id:886) fd: 2 arg_word: {(DQ (${ Id.VSub_Name stderrF))} ) ] ) (command.Simple words: [{(echo)} {($ Id.VSub_QMark '$?')}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:898) fd: -1 arg_word: {(DQ (${ Id.VSub_Name returnF))} ) ] ) ] ) ) (C {(assertFalse)} { (SQ (Token id: Id.Lit_Chars val: 'a call for help should return a non-zero exit code.' span_id: 914 ) ) } { (DQ (command_sub left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:920) command_list: (command.CommandList children:[(C {(th_queryReturn)})]) ) ) } ) (command.Simple words: [{(diff)} {(DQ (${ Id.VSub_Name expectedF))} {(DQ (${ Id.VSub_Name stderrF))}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:941) fd: -1 arg_word: {(/dev/null)} ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:differed) op: assign_op.Equal rhs: {($ Id.VSub_QMark '$?')} spids: [945] ) ] ) (C {(assertTrue)} {(SQ (Token id:Id.Lit_Chars val:'unexpected help output' span_id:952))} {(${ Id.VSub_Name differed)} ) (C {(th_showOutput)} {(${ Id.VSub_Name differed)} {(DQ (${ Id.VSub_Name stdoutF))} {(DQ (${ Id.VSub_Name stderrF))} ) ] ) ) (command.ShFunction name: testNoHelp body: (command.BraceGroup children: [ (command.AndOr ops: [Id.Op_DPipe] children: [(C {(flags_getoptIsEnh)}) (C {(startSkipping)})] ) (command.Subshell command_list: (command.CommandList children: [ (command.Simple words: [{(FLAGS)} {(--nohelp)}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:1002) fd: -1 arg_word: {(DQ (${ Id.VSub_Name stdoutF))} ) (redir.Redir op: (Token id:Id.Redir_Great val:'2>' span_id:1009) fd: 2 arg_word: {(DQ (${ Id.VSub_Name stderrF))} ) ] ) ] ) ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:r3turn) op: assign_op.Equal rhs: {($ Id.VSub_QMark '$?')} spids: [1019] ) ] ) (C {(assertTrue)} {(DQ ('FLAGS returned a non-zero result (') (${ Id.VSub_Name r3turn) (')'))} {(${ Id.VSub_Name r3turn)} ) (C {(assertFalse)} {(SQ (Token id:Id.Lit_Chars val:'expected no output to STDOUT' span_id:1041))} {(DQ ("[ -s '") (${ Id.VSub_Name stdoutF) ("' ]"))} ) (C {(assertFalse)} {(SQ (Token id:Id.Lit_Chars val:'expected no output to STDERR' span_id:1056))} {(DQ ("[ -s '") (${ Id.VSub_Name stderrF) ("' ]"))} ) ] ) ) (command.ShFunction name: testLoggingLevel body: (command.BraceGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:got) op: assign_op.Equal rhs: { (command_sub left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:1082) command_list: (command.CommandList children:[(C {(flags_loggingLevel)})]) ) } spids: [1081] ) (assign_pair lhs: (sh_lhs_expr.Name name:want) op: assign_op.Equal rhs: {(${ Id.VSub_Name __FLAGS_LEVEL_DEFAULT)} spids: [1086] ) ] ) (C {(assertTrue)} { (DQ ('Unexpected default logging level = ') (${ Id.VSub_Name got) (', want ') (${ Id.VSub_Name want) ) } {(DQ ('[ ') (${ Id.VSub_Name got) (' -eq ') (${ Id.VSub_Name want) (' ]'))} ) (C {(flags_setLoggingLevel)} {(DQ (${ Id.VSub_Name FLAGS_LEVEL_FATAL))}) (C {(flags_setLoggingLevel)} {(DQ (${ Id.VSub_Name FLAGS_LEVEL_INFO))}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:got) op: assign_op.Equal rhs: { (command_sub left_token: (Token id:Id.Left_DollarParen val:'$(' span_id:1142) command_list: (command.CommandList children:[(C {(flags_loggingLevel)})]) ) } spids: [1141] ) (assign_pair lhs: (sh_lhs_expr.Name name:want) op: assign_op.Equal rhs: {(${ Id.VSub_Name FLAGS_LEVEL_INFO)} spids: [1146] ) ] ) (C {(assertTrue)} { (DQ ('Unexpected configured logging level = ') (${ Id.VSub_Name got) (', want ') (${ Id.VSub_Name want) ) } {(DQ ('[ ') (${ Id.VSub_Name got) (' -eq ') (${ Id.VSub_Name want) (' ]'))} ) ] ) ) (command.ShFunction name: oneTimeSetUp body: (command.BraceGroup children: [ (C {(th_oneTimeSetUp)}) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (C {(flags_getoptIsStd)}) terminator: (Token id:Id.Op_Semi val:';' span_id:1194) ) ] action: [ (C {(th_warn)} { (SQ (Token id: Id.Lit_Chars val: 'Standard version of getopt found. Enhanced tests will be skipped.' span_id: 1202 ) ) } ) (command.ControlFlow token: (Token id:Id.ControlFlow_Return val:return span_id:1206) ) ] spids: [1191 1196] ) ] ) (C {(th_warn)} { (SQ (Token id: Id.Lit_Chars val: 'Enhanced version of getopt found. Standard tests will be skipped.' span_id: 1215 ) ) } ) ] ) ) (command.ShFunction name:setUp body:(command.BraceGroup children:[(C {(flags_reset)})])) (command.AndOr ops: [Id.Op_DAmp] children: [ (C {(Id.Lit_LBracket '[')} {(-n)} { (DQ (braced_var_sub token: (Token id:Id.VSub_Name val:ZSH_VERSION span_id:1245) suffix_op: (suffix_op.Unary op_id:Id.VTest_ColonHyphen arg_word:(word.Empty)) ) ) } {(Id.Lit_RBracket ']')} ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:SHUNIT_PARENT) op: assign_op.Equal rhs: {($ Id.VSub_Number '$0')} spids: [1254] ) ] ) ] ) (C {(.)} {(DQ (${ Id.VSub_Name TH_SHUNIT))}) ] )