(command.CommandList children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:expectedF) op: Equal rhs: { (DQ (word_part.BracedVarSub token: <VSub_Name TMPDIR> suffix_op: (suffix_op.StringUnary op_id: VTest_ColonHyphen arg_word: {(Lit_Slash /) (tmp)} ) ) (/expected) ) } ) ] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:returnF) op: Equal rhs: { (DQ (word_part.BracedVarSub token: <VSub_Name TMPDIR> suffix_op: (suffix_op.StringUnary op_id: VTest_ColonHyphen arg_word: {(Lit_Slash /) (tmp)} ) ) (/return) ) } ) ] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:stdoutF) op: Equal rhs: { (DQ (word_part.BracedVarSub token: <VSub_Name TMPDIR> suffix_op: (suffix_op.StringUnary op_id: VTest_ColonHyphen arg_word: {(Lit_Slash /) (tmp)} ) ) (/STDOUT) ) } ) ] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:stderrF) op: Equal rhs: { (DQ (word_part.BracedVarSub token: <VSub_Name TMPDIR> suffix_op: (suffix_op.StringUnary op_id: VTest_ColonHyphen arg_word: {(Lit_Slash /) (tmp)} ) ) (/STDERR) ) } ) ] ) (C {(.)} {(./shflags_test_helpers)}) (command.FuncDef name: testHelp body: (command.BraceGroup children: [ (C {(_testHelp)} {(SQ <-h>)}) (command.AndOr ops: [Op_DPipe] children: [ (C {(flags_getoptIsEnh)}) (command.ControlFlow token:<ControlFlow_Return return>) ] ) (C {(_testHelp)} {(SQ <--help>)}) ] ) ) (command.FuncDef name: _testHelp body: (command.BraceGroup children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:flag) op: Equal rhs: {($ VSub_Number '$1')} ) ] ) (C {(th_clearReturn)}) (command.Subshell command_list: (command.CommandList children: [ (command.SimpleCommand words: [{(FLAGS)} {(DQ (${ VSub_Name flag))}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(DQ (${ VSub_Name stdoutF))} ) (redir.Redir op: <Redir_Great '2>'> fd: 2 arg_word: {(DQ (${ VSub_Name stderrF))} ) ] ) (command.SimpleCommand words: [{(echo)} {($ VSub_QMark '$?')}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(DQ (${ VSub_Name returnF))} ) ] ) ] ) ) (C {(assertFalse)} {(SQ <'a call for help should return a non-zero exit code.'>)} { (DQ (word_part.CommandSubPart command_list: (command.CommandList children:[(C {(th_queryReturn)})]) left_token: <Left_CommandSub '$('> ) ) } ) (command.SimpleCommand words: [{(grep)} {(SQ <'show this help'>)} {(DQ (${ VSub_Name stderrF))}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(/dev/null)})] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:grepped) op: Equal rhs: {($ VSub_QMark '$?')} ) ] ) (C {(assertTrue)} {(SQ <'short request for help should have produced some help output.'>)} {(${ VSub_Name grepped)} ) (command.AndOr ops: [Op_DAmp] children: [ (C {(Lit_Other '[')} {(${ VSub_Name grepped)} {(-ne)} {(DQ (${ VSub_Name FLAGS_TRUE))} {(Lit_Other ']')} ) (C {(th_showOutput)}) ] ) (command.Subshell command_list: (command.CommandList children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:FLAGS_HELP) op: Equal rhs: {(SQ <'this is a test'>)} ) ] ) (command.SimpleCommand words: [{(FLAGS)} {(DQ (${ VSub_Name flag))}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(DQ (${ VSub_Name stdoutF))} ) (redir.Redir op: <Redir_Great '2>'> fd: 2 arg_word: {(DQ (${ VSub_Name stderrF))} ) ] ) ] ) ) (command.SimpleCommand words: [{(grep)} {(SQ <'this is a test'>)} {(DQ (${ VSub_Name stderrF))}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(/dev/null)})] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:grepped) op: Equal rhs: {($ VSub_QMark '$?')} ) ] ) (C {(assertTrue)} {(SQ <'setting FLAGS_HELP did not produce expected result'>)} {(${ VSub_Name grepped)} ) (command.AndOr ops: [Op_DAmp] children: [ (C {(Lit_Other '[')} {(${ VSub_Name grepped)} {(-ne)} {(DQ (${ VSub_Name FLAGS_TRUE))} {(Lit_Other ']')} ) (C {(th_showOutput)}) ] ) (command.Subshell command_list: (command.CommandList children: [ (C {(DEFINE_boolean)} {(b)} {(false)} {(DQ ("help string containing a ' char"))} {(b)}) (command.SimpleCommand words: [{(FLAGS)} {(DQ (${ VSub_Name flag))}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(DQ (${ VSub_Name stdoutF))} ) (redir.Redir op: <Redir_Great '2>'> fd: 2 arg_word: {(DQ (${ VSub_Name stderrF))} ) ] ) ] ) ) (command.SimpleCommand words: [{(grep)} {(DQ ("help string containing a ' char"))} {(DQ (${ VSub_Name stderrF))}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(/dev/null)})] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:grepped) op: Equal rhs: {($ VSub_QMark '$?')} ) ] ) (C {(assertTrue)} {(DQ ("help strings containing apostrophes don't work"))} {(${ VSub_Name grepped)} ) (command.AndOr ops: [Op_DAmp] children: [ (C {(Lit_Other '[')} {(${ VSub_Name grepped)} {(-ne)} {(DQ (${ VSub_Name FLAGS_TRUE))} {(Lit_Other ']')} ) (C {(th_showOutput)}) ] ) ] ) ) (command.FuncDef name: mock_flags_columns body: (command.BraceGroup children:[(C {(echo)} {(80)})]) ) (command.FuncDef name: testStandardHelpOutput body: (command.BraceGroup children: [ (command.AndOr ops: [Op_DPipe] children: [(C {(flags_getoptIsStd)}) (C {(startSkipping)})] ) (C {(DEFINE_boolean)} {(test_bool)} {(false)} {(SQ <'test boolean'>)} {(b)}) (C {(DEFINE_integer)} {(test_int)} {(0)} {(SQ <'test integer'>)} {(i)}) (C {(DEFINE_string)} {(test_str)} {(SQ )} {(SQ <'test string'>)} {(s)}) (C {(DEFINE_string)} {(long_desc)} {(SQ <blah>)} {(SQ <'testing of a long description to force wrap of default value'>)} {(D)} ) (C {(DEFINE_string)} {(long_default)} {(SQ <this_is_a_long_default_value_to_force_alternate_indentation>)} {(SQ <'testing of long default value'>)} {(F)} ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:help) op: Equal rhs: {(SQ <'USAGE: standard [flags] args'>)} ) ] ) (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(DQ (${ VSub_Name expectedF))} ) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 593 stdin_parts: [ (${ 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.FuncDef name: _flags_columns body: (command.BraceGroup children: [ (command.Sentence child: (C {(mock_flags_columns)}) terminator: <Op_Semi ';'> ) ] ) ) (command.Sentence child: (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:FLAGS_HELP) op: Equal rhs: {(${ VSub_Name help)} ) ] ) terminator: <Op_Semi ';'> ) (command.SimpleCommand words: [{(FLAGS)} {(-h)}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(DQ (${ VSub_Name stdoutF))} ) (redir.Redir op: <Redir_Great '2>'> fd: 2 arg_word: {(DQ (${ VSub_Name stderrF))} ) ] ) (command.SimpleCommand words: [{(echo)} {($ VSub_QMark '$?')}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(DQ (${ VSub_Name returnF))} ) ] ) ] ) ) (C {(assertFalse)} {(SQ <'a call for help should return a non-zero exit code.'>)} { (DQ (word_part.CommandSubPart command_list: (command.CommandList children:[(C {(th_queryReturn)})]) left_token: <Left_CommandSub '$('> ) ) } ) (command.SimpleCommand words: [{(diff)} {(DQ (${ VSub_Name expectedF))} {(DQ (${ VSub_Name stderrF))}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(/dev/null)})] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:r3turn) op: Equal rhs: {($ VSub_QMark '$?')} ) ] ) (C {(assertTrue)} {(SQ <'unexpected help output'>)} {(${ VSub_Name r3turn)}) (C {(th_showOutput)} {(${ VSub_Name r3turn)} {(DQ (${ VSub_Name stdoutF))} {(DQ (${ VSub_Name stderrF))} ) ] ) ) (command.FuncDef name: testEnhancedHelpOutput body: (command.BraceGroup children: [ (command.AndOr ops: [Op_DPipe] children: [(C {(flags_getoptIsEnh)}) (C {(startSkipping)})] ) (C {(DEFINE_boolean)} {(test_bool)} {(false)} {(SQ <'test boolean'>)} {(b)}) (C {(DEFINE_integer)} {(test_int)} {(0)} {(SQ <'test integer'>)} {(i)}) (C {(DEFINE_string)} {(test_str)} {(SQ )} {(SQ <'test string'>)} {(s)}) (C {(DEFINE_string)} {(long_desc)} {(SQ <blah>)} {(SQ <'testing of a long description to force wrap of default value'>)} {(D)} ) (C {(DEFINE_string)} {(long_default)} {(SQ <this_is_a_long_default_value_to_force_alternate_indentation>)} {(SQ <'testing of long default value'>)} {(F)} ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:help) op: Equal rhs: {(SQ <'USAGE: enhanced [flags] args'>)} ) ] ) (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(DQ (${ VSub_Name expectedF))} ) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 847 stdin_parts: [ (${ 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.FuncDef name: _flags_columns body: (command.BraceGroup children: [ (command.Sentence child: (C {(mock_flags_columns)}) terminator: <Op_Semi ';'> ) ] ) ) (command.Sentence child: (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:FLAGS_HELP) op: Equal rhs: {(${ VSub_Name help)} ) ] ) terminator: <Op_Semi ';'> ) (command.SimpleCommand words: [{(FLAGS)} {(-h)}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(DQ (${ VSub_Name stdoutF))} ) (redir.Redir op: <Redir_Great '2>'> fd: 2 arg_word: {(DQ (${ VSub_Name stderrF))} ) ] ) (command.SimpleCommand words: [{(echo)} {($ VSub_QMark '$?')}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(DQ (${ VSub_Name returnF))} ) ] ) ] ) ) (C {(assertFalse)} {(SQ <'a call for help should return a non-zero exit code.'>)} { (DQ (word_part.CommandSubPart command_list: (command.CommandList children:[(C {(th_queryReturn)})]) left_token: <Left_CommandSub '$('> ) ) } ) (command.SimpleCommand words: [{(diff)} {(DQ (${ VSub_Name expectedF))} {(DQ (${ VSub_Name stderrF))}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(/dev/null)})] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:differed) op: Equal rhs: {($ VSub_QMark '$?')} ) ] ) (C {(assertTrue)} {(SQ <'unexpected help output'>)} {(${ VSub_Name differed)}) (C {(th_showOutput)} {(${ VSub_Name differed)} {(DQ (${ VSub_Name stdoutF))} {(DQ (${ VSub_Name stderrF))} ) ] ) ) (command.FuncDef name: testNoHelp body: (command.BraceGroup children: [ (command.AndOr ops: [Op_DPipe] children: [(C {(flags_getoptIsEnh)}) (C {(startSkipping)})] ) (command.Subshell command_list: (command.CommandList children: [ (command.SimpleCommand words: [{(FLAGS)} {(--nohelp)}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(DQ (${ VSub_Name stdoutF))} ) (redir.Redir op: <Redir_Great '2>'> fd: 2 arg_word: {(DQ (${ VSub_Name stderrF))} ) ] ) ] ) ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:r3turn) op: Equal rhs: {($ VSub_QMark '$?')} ) ] ) (C {(assertTrue)} {(DQ ('FLAGS returned a non-zero result (') (${ VSub_Name r3turn) (')'))} {(${ VSub_Name r3turn)} ) (C {(assertFalse)} {(SQ <'expected no output to STDOUT'>)} {(DQ ("[ -s '") (${ VSub_Name stdoutF) ("' ]"))} ) (C {(assertFalse)} {(SQ <'expected no output to STDERR'>)} {(DQ ("[ -s '") (${ VSub_Name stderrF) ("' ]"))} ) ] ) ) (command.FuncDef name: testLoggingLevel body: (command.BraceGroup children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:got) op: Equal rhs: { (word_part.CommandSubPart command_list: (command.CommandList children:[(C {(flags_loggingLevel)})]) left_token: <Left_CommandSub '$('> ) } ) (assign_pair lhs: (lhs_expr.LhsName name:want) op: Equal rhs: {(${ VSub_Name __FLAGS_LEVEL_DEFAULT)} ) ] ) (C {(assertTrue)} { (DQ ('Unexpected default logging level = ') (${ VSub_Name got) (', want ') (${ VSub_Name want) ) } {(DQ ('[ ') (${ VSub_Name got) (' -eq ') (${ VSub_Name want) (' ]'))} ) (C {(flags_setLoggingLevel)} {(DQ (${ VSub_Name FLAGS_LEVEL_FATAL))}) (C {(flags_setLoggingLevel)} {(DQ (${ VSub_Name FLAGS_LEVEL_INFO))}) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:got) op: Equal rhs: { (word_part.CommandSubPart command_list: (command.CommandList children:[(C {(flags_loggingLevel)})]) left_token: <Left_CommandSub '$('> ) } ) (assign_pair lhs: (lhs_expr.LhsName name:want) op: Equal rhs: {(${ VSub_Name FLAGS_LEVEL_INFO)} ) ] ) (C {(assertTrue)} { (DQ ('Unexpected configured logging level = ') (${ VSub_Name got) (', want ') (${ VSub_Name want) ) } {(DQ ('[ ') (${ VSub_Name got) (' -eq ') (${ VSub_Name want) (' ]'))} ) ] ) ) (command.FuncDef name: oneTimeSetUp body: (command.BraceGroup children: [ (C {(th_oneTimeSetUp)}) (command.If arms: [ (if_arm cond: [(command.Sentence child:(C {(flags_getoptIsStd)}) terminator:<Op_Semi ';'>)] action: [ (C {(th_warn)} {(SQ <'Standard version of getopt found. Enhanced tests will be skipped.'>)} ) (command.ControlFlow token:<ControlFlow_Return return>) ] ) ] ) (C {(th_warn)} {(SQ <'Enhanced version of getopt found. Standard tests will be skipped.'>)}) ] ) ) (command.FuncDef name:setUp body:(command.BraceGroup children:[(C {(flags_reset)})])) (command.AndOr ops: [Op_DAmp] children: [ (C {(Lit_Other '[')} {(-n)} { (DQ (word_part.BracedVarSub token: <VSub_Name ZSH_VERSION> suffix_op: (suffix_op.StringUnary op_id:VTest_ColonHyphen arg_word:(word.EmptyWord)) ) ) } {(Lit_Other ']')} ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:SHUNIT_PARENT) op: Equal rhs: {($ VSub_Number '$0')} ) ] ) ] ) (C {(.)} {(DQ (${ VSub_Name TH_SHUNIT))}) ] )