"Fossies" - the Fresh Open Source Software Archive

Member "argbash-2.10.0/tests/regressiontests/make/tests/tests-base.m4" (22 Sep 2020, 10967 Bytes) of package /linux/privat/argbash-2.10.0.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "tests-base.m4": 2.9.0_vs_2.10.0.

    1 ADD_SCRIPT([basic2])
    2 ADD_TEST_BASH([stability], [[
    3 	diff -q $< $(word 2,$^)
    4 ]], [$(TESTDIR)/basic2.sh], [$(TESTDIR)/basic.sh])
    5 
    6 ADD_TEST_BASH([basic], [[
    7 	$(generic_regression_posix)
    8 	$(generic_regression_gnu_only)
    9 	$< -h | grep -q 'P percent: %'
   10 	$< -h | grep -q 'O percent: %'
   11 	! $< -h | grep -qe '\[--\]'
   12 ]])
   13 
   14 
   15 ADD_TEST_DASH([basic], [[
   16 	$(generic_regression_posix)
   17 	$< LOO -b | grep -q BOOL=off,
   18 	$< -h | grep -q 'P percent: %'
   19 	$< -h | grep -q 'O percent: %'
   20 	$< -h | grep -qe '\[--\]'
   21 ]])
   22 
   23 
   24 ADD_TEST_BASH([test-void], [[
   25 	! grep -q 'die' $<
   26 ]])
   27 
   28 ADD_SCRIPT([test-salone])
   29 #  the dependency $(TESTDIR)/test-standalone.sh should be assumed
   30 ADD_TEST_BASH([call-salone], [[
   31 	$(generic_regression_posix)
   32 	$(generic_regression_gnu_only)
   33 ]])
   34 
   35 ADD_TEST_BASH([test-most], [[
   36 	$< -h | grep -q '<pos-more1-1> <pos-more1-2> \[<pos-more2-1>\] \[<pos-more2-2>\]'
   37 	$< xx yy | grep -q "POS_MORE1=xx yy,POS_MORE2=hu lu,"
   38 	$< xx yy zz aa | grep -q "POS_MORE1=xx yy,POS_MORE2=zz aa,"
   39 	$< -h | grep -q '<pos-more1-1> <pos-more1-2> \[<pos-more2-1>\] \[<pos-more2-2>\]'
   40 	$< -h | grep -q '<pos-more1>: @pos-more1-arg@'
   41 	$< -h | grep -q "<pos-more2>: @pos-more2-arg@ (defaults for <pos-more2-1> to <pos-more2-2> respectively: 'hu' and 'lu')"
   42 ]])
   43 
   44 ADD_TEST_BASH([test-more], [[
   45 	$< LOO x | grep -q "POS_S=LOO,POS_MORE=x f\[o\]o ba,r,"
   46 	$< LOO lul laa | grep -q "POS_S=LOO,POS_MORE=lul laa ba,r,"
   47 	$< LOO laa bus kus | grep -q "POS_S=LOO,POS_MORE=laa bus kus",
   48 	ERROR="namely: 'pos-arg' and 'pos-more'" $(REVERSE) $<
   49 	grep -q '^		_positionals' $<
   50 ]])
   51 
   52 
   53 ADD_TEST_BASH([test-onlypos], [[
   54 	$(_test_onlypos)
   55 	! grep -q '^_arg_pos_arg=$$' $<
   56 ]])
   57 
   58 
   59 ADD_TEST_BASH([test-onlypos-declared], [[
   60 	$(_test_onlypos)
   61 	grep -q '^_arg_pos_arg=$$' $<
   62 ]])
   63 
   64 
   65 m4_define([test_onlyopt_posix_body], [[
   66 	grep -q '^    esac$$' $<
   67 	@# ! negates the return code
   68 	! grep -q '^	' $<
   69 	$(REVERSE) grep -q POSITION $<
   70 	$< -o "PoS sob" | grep -q 'OPT_S=PoS sob,'
   71 	$< -B | grep -q 'BOOL=on'
   72 	$< -i | grep -q 'OPT_INCR=3,'
   73 	$< -i -i | grep -q 'OPT_INCR=4,'
   74 	! $< -h | grep -q -e '-B,'
   75 	$(REVERSE) $< LOO 2> /dev/null]])
   76 
   77 
   78 ADD_TEST_BASH([test-onlyopt], [test_onlyopt_posix_body
   79 	$< --opt-arg PoS | grep -q OPT_S=PoS,
   80 	$< --opt-arg "PoS sob" | grep -q 'OPT_S=PoS sob,'
   81 	$< --boo_l | grep -q 'BOOL=on'
   82 	$< --no-boo_l | grep -q 'BOOL=off'
   83 	$< -r /usr/lib --opt-repeated /usr/local/lib | grep -q 'ARG_REPEATED=/usr/lib /usr/local/lib,'
   84 	$< -h | grep -q -e '-B|--(no-)boo_l'
   85 	$< -h | grep -q -e '-i|--incrx'
   86 	$< -h | grep -q -e '-i, --incrx'
   87 	$< -h | grep -q -e '-o|--opt-arg <arg>'
   88 	$< -h | grep -q -e '-o, --opt-arg: @opt-arg@'
   89 	$< -h | grep -q -e '-r|--opt-repeated'
   90 	$< -h | grep -q -e '-r, --opt-repeated:'
   91 ])
   92 
   93 dnl TODO: The error that occurs when supplied with positional arg needs fixing.
   94 ADD_TEST_DASH([test-onlyopt], [test_onlyopt_posix_body
   95 	$< -h | grep -q -e '-B'
   96 	$< -h | grep -q -e '-i'
   97 	$< -h | grep -q -e '-o <arg>'
   98 	$< -h | grep -q -e '-o: @opt-arg@'
   99 	! $< -h | grep -q -e '-r'
  100 	ERROR=cosi $(REVERSE) $< -o lala cosi
  101 ])
  102 
  103 ADD_SCRIPT([test-standalone2])
  104 ADD_TEST_BASH([stability-salone], [[
  105 	diff -q $< $(word 2,$^)
  106 ]],
  107 	[$(TESTDIR)/test-standalone2.sh], [$(TESTDIR)/test-standalone.sh])
  108 
  109 ADD_RULE([$(TESTDIR)/test-ddash.m4], [$(TESTDIR)/test-ddash-old.m4 $(ARGBASH_1TO2)],
  110 	[$(ARGBASH_1TO2) $< -o $@
  111 ])
  112 
  113 ADD_TEST_BASH([test-ddash], [[
  114 	$< --boo_l | grep -q 'BOOL=on,'
  115 	$< -- --boo_l | grep -q 'BOOL=off,'
  116 	$< -- --boo_l | grep -q 'POS_OPT=--boo_l,'
  117 	$< -- --help | grep -q 'POS_OPT=--help,'
  118 	$< -- | grep -q 'POS_OPT=pos-default,'
  119 	$< -- --| grep -q 'POS_OPT=--,'
  120 	ERROR=spurious 	$(REVERSE) $< -- foo bar
  121 	ERROR=bar 	$(REVERSE) $< -- foo bar
  122 ]])
  123 
  124 
  125 m4_define([test_simple_body], [[
  126 	$< pos | grep -q 'OPT_S=x,POS_S=pos,'
  127 	$< -o 'uf ta' pos | grep -q 'OPT_S=uf ta,POS_S=pos,'
  128 	$< -h | grep -q 'END-$$'
  129 	$< -h | grep -q '^\s*-BEGIN'
  130 	$< -h | grep -q '^		-BEGIN'
  131 	$< -h | grep -q -v '^\s*-BEGIN2'
  132 	$< -h | grep -q -v 'END2-$$'
  133 	$< -h | grep -q '"line 2" END-\\n'
  134 	$< -h | grep -q '^		-PBEGIN'
  135 	$< -h | grep -q 'PEND-$$'
  136 	grep -q '^		esac' $<
  137 	grep -q '^			\*@:}@' $<
  138 	ERROR=spurious 	$(REVERSE) $< -- one two
  139 	ERROR="last one was: 'two'" 	$(REVERSE) $< one two
  140 	ERROR="expect exactly 1" 	$(REVERSE) $< one two
  141 	ERROR="[Nn]ot enough" 	$(REVERSE) $<
  142 	ERROR="require exactly 1" 	$(REVERSE) $<]])
  143 
  144 
  145 ADD_TEST_BASH([test-simple], [test_simple_body
  146 	$< pos -o 'uf ta' | grep -q 'OPT_S=uf ta,POS_S=pos,'
  147 ])
  148 
  149 ADD_TEST_DASH([test-simple], [test_simple_body
  150 	ERROR="got 3" $(REVERSE) $< -- -o 'uf ta' pos
  151 	ERROR="got 3" $(REVERSE) $< pos -o 'uf ta'
  152 	ERROR="last one was: 'uf ta'" $(REVERSE) $< pos -o 'uf ta'
  153 ])
  154 
  155 dnl The invocation like this is supposed to trigger complaints
  156 ADD_TEST_BASH([test-diy-noop], [[
  157 	$< LOO --opt_arg > /dev/null
  158 	$< LOO 1 2 3 3 > /dev/null
  159 	$< > /dev/null
  160 ]])
  161 
  162 ADD_RULE([$(TESTDIR)/test-diy-noop.m4], [$(TESTDIR)/basic.m4],
  163 	[[sed -e 's/ARGBASH_GO/ARGBASH_PREPARE/' $< > $@
  164 ]])
  165 ADD_SCRIPT([test-diy-noop], [m4])
  166 
  167 ADD_RULE([$(TESTDIR)/test-diy-noop.sh], [$(TESTDIR)/test-diy-noop.m4],
  168 	[[$(ARGBASH_BIN) -c -o "$@" "$<"
  169 ]])
  170 
  171 dnl This is the body of test-simple
  172 ADD_TEST_BASH([test-diy], [[
  173 	$(generic_regression_posix)
  174 	$(generic_regression_gnu_only)
  175 ]])
  176 
  177 dnl Use comments in test-diy-noop.sh to generate the actual commands to parse args. .
  178 ADD_RULE([$(TESTDIR)/test-diy.m4], [$(TESTDIR)/test-diy-noop.m4 $(TESTDIR)/test-diy-noop.sh],
  179 	[[sed -e "s/#.*\@<:@$$/&\n$$(grep -e '#  \S' "$(TESTDIR)/test-diy-noop.sh" | sed -e 's/^#  //' | tr '\n' ';')/" $< > $@
  180 ]])
  181 ADD_SCRIPT([test-diy], [m4])
  182 
  183 
  184 m4_define([test_wrapping_body_base], [[[
  185 	$< -h | grep -q opt-arg
  186 	$< -h | grep -q pos-arg
  187 	@# ! negates the return code
  188 	! $< -h | grep -q boo_l
  189 	@# no spaces as indentation (that test-onlyopt uses)
  190 	! grep -q '^  ' $<
  191 	grep -q '^		esac' $<
  192 	$< XX LOOL | grep -q 'POS_S0=XX,POS_S=LOOL,POS_OPT=pos-default'
  193 	$< XX LOOL | grep -q 'POS_S=LOOL,POS_OPT=pos-default'
  194 	$< XX LOOL --opt-arg lalala | grep -q OPT_S=lalala,
  195 ]]])
  196 
  197 m4_define([test_wrapping_body], m4_dquote(m4_do(
  198 	[test_wrapping_body_base],
  199 	[[	$< XX LOOL --opt-arg lalala | grep -q 'CMDLINE=--opt-arg lalala LOOL pos-default,'
  200 ]],
  201 	[[	$< XX LOOL --opt-repeated w -r x --opt-repeated=y -rz | grep -q 'CMDLINE=--opt-repeated w -r x --opt-repeated=y -rz LOOL pos-default,'
  202 ]],
  203 	)))
  204 
  205 ADD_TEST_BASH([test-wrapping-second_level], [m4_do(
  206 	test_wrapping_body_base,
  207 	[[	$< XX LOOL --opt-arg lalala | grep -q 'CMDLINE=--opt-arg lalala XX LOOL pos-default,'
  208 ]],
  209 	[[	$< XX LOOL --opt-repeated w -r x --opt-repeated=y -rz | grep -q 'CMDLINE=--opt-repeated w -r x --opt-repeated=y -rz XX LOOL pos-default,'
  210 ]],
  211 	[[	$< XX LOOL | grep -q 'POS_S1=,'
  212 ]],
  213 	)])
  214 
  215 ADD_ARGBASH_RULE([$(TESTDIR)/test-wrapping-second_level],
  216 	[$(TESTDIR)/test-wrapping-single_level.sh $(TESTDIR)/test-onlyopt.m4],
  217 	[[$(ARGBASH_EXEC) $< -o $@
  218 ]])
  219 
  220 ADD_SCRIPT([test-wrapping-single_level])
  221 ADD_ARGBASH_RULE([$(TESTDIR)/test-wrapping-single_level],
  222 	[$(TESTDIR)/test-onlypos.m4],
  223 	[[$(ARGBASH_EXEC) $< -o $@
  224 ]])
  225 ADD_SCRIPT([otherdir/test-onlyopt], [m4])
  226 
  227 ADD_TEST_BASH([test-wrapping], test_wrapping_body,
  228 [$(TESTDIR)/test-onlyopt.m4 $(TESTDIR)/test-onlypos.m4])
  229 
  230 ADD_ARGBASH_RULE([$(TESTDIR)/test-wrapping-otherdir],
  231 	[$(TESTDIR)/otherdir/test-onlyopt.m4 $(TESTDIR)/otherdir/test-onlypos.m4 $(ARGBASH_BIN)],
  232 	[[$(ARGBASH_EXEC) $< -o $@
  233 ]])
  234 
  235 ADD_TEST_BASH([test-wrapping-otherdir], test_wrapping_body)
  236 
  237 ADD_RULE([$(TESTDIR)/otherdir/test-onlyopt.m4], [$(TESTDIR)/test-onlyopt.m4],
  238 	[[mkdir -p $(TESTDIR)/otherdir && cp $< $@
  239 ]])
  240 ADD_SCRIPT([otherdir/test-onlyopt], [m4])
  241 
  242 ADD_RULE([$(TESTDIR)/otherdir/test-onlypos.m4], [$(TESTDIR)/test-onlypos.m4],
  243 	[[mkdir -p $(TESTDIR)/otherdir && cp $< $@
  244 ]])
  245 ADD_SCRIPT([otherdir/test-onlypos], [m4])
  246 
  247 ADD_TEST_BASH([test-wrapping-more], [[
  248 	$< -i -i -i | grep -q 'CMDLINE=-i -i -i,'
  249 	$< -i -i | grep -q 'OPT_INCR=4,'
  250 	ERROR="nexpected argument '--opt-arg'" $(REVERSE) $< --opt-arg lalala
  251 ]], [$(TESTDIR)/test-onlyopt.m4])
  252 
  253 ADD_TEST_BASH([test-wrapping-excl], [[
  254 	$(_test_onlypos)
  255 ]], [$(TESTDIR)/test-onlypos.m4])
  256 
  257 ADD_SCRIPT([test-wrapping2])
  258 ADD_TEST_BASH([stability-wrapping], [[
  259 	diff -q $< $(word 2,$^)
  260 ]],
  261 	[$(TESTDIR)/test-wrapping2.sh], [$(TESTDIR)/test-wrapping.sh])
  262 
  263 
  264 m4_define([test_body], [[
  265 	$< | grep -q 'POS_S='
  266 	$< 1 | grep -q 'POS_S=1,'
  267 	$< 1 2 "3 1 4" 4 5 | grep -q 'POS_S=1,2,3 1 4,4,5,'
  268 ]])
  269 
  270 ADD_TEST_BASH([test-infinity-minimal_call], [test_body])
  271 dnl ADD_TEST_BASH([test-infinity-minimal_call-dash], [test_body])
  272 
  273 ADD_TEST_BASH([test-progs], [[
  274 	$< -h | grep MAKE | grep -q utility
  275 	$< -h | grep FULALA | grep -q BOOM
  276 	ERROR="fulala doesnt exist" $(REVERSE) $<
  277 	$< 2>&1 | grep fulala | grep -q exist
  278 	FULALA=make $<
  279 	ERROR="make doesnt work" MAKE=false FULALA=make $(REVERSE) $<
  280 	$< -h | grep fulala | grep -q FULALA
  281 ]])
  282 
  283 ADD_TEST_BASH([test-prog], [[
  284 	$< -h | grep FULALA | grep -q BOOM
  285 	ERROR="fulala doesnt exist" $(REVERSE) $<
  286 	$< 2>&1 | grep fulala | grep -q exist
  287 	FULALA=make $<
  288 	$< -h | grep fulala | grep -q FULALA
  289 	ERROR="fulala doesnt work" FULALA=false $(REVERSE) $<
  290 ]])
  291 
  292 ADD_TEST_BASH([test-infinity], [[
  293 	$< | grep -q 'POS_S=first,second,third,'
  294 	$< 1 | grep -q 'POS_S=1,second,third,'
  295 	$< 1 2 "3 1 4" 4 5 | grep -q 'POS_S=1,2,3 1 4,4,5,'
  296 	! grep -q handle_passed_args_count $<
  297 ]])
  298 
  299 ADD_TEST_BASH([test-infinity-nodefaults], [[
  300 	ERROR="require at least 2" $(REVERSE) $<
  301 	ERROR="namely: 'pos-arg' (2 times)" $(REVERSE) $<
  302 	$< 1 "2 3" | grep -q 'POS_S=1,2 3'
  303 	$< 1 2 "3 1 4" 4 5 | grep -q 'POS_S=1,2,3 1 4,4,5,'
  304 	grep -q handle_passed_args_count $<
  305 ]])
  306 
  307 ADD_TEST_BASH([test-infinity-mixed], [[
  308 	$< -h | grep -q '<pos-arg-1> \[<pos-arg-2>\] \.\.\. \[<pos-arg-n>\] \.\.\.$$'
  309 	ERROR="require at least 1" $(REVERSE) $<
  310 	$< 1 | grep -q 'POS_S=1,first,second'
  311 	$< 1 2 "3 1 4" 4 5 | grep -q 'POS_S=1,2,3 1 4,4,5,'
  312 ]])
  313 
  314 ADD_TEST_BASH([test-leftovers], [[
  315 	$< -? | grep -q '\[-c|--cosi <arg>\] \[--(no-)fear\] \[-m|--more\] \[-?|--hilfe\] <another> \.\.\. $$'
  316 	$< -c ours -m --more --more --no-fear "ours pos" left "o ver" | grep -q 'MORE=3,OPT_S=ours,FEAR=off,POS_S=ours pos,LEFTOVERS=left,o ver,'
  317 ]])
  318 
  319 ADD_GENTEST_DASH([infinity], [supported], [infinite])
  320 ADD_GENTEST_DASH([wrap], [supported])
  321 ADD_GENTEST_BASH([pos], [pos-arg])
  322 ADD_GENTEST_BASH([opt], [opt-arg])
  323 ADD_GENTEST_BASH([pos2], [pos_arg])
  324 ADD_GENTEST_BASH([opt2], [opt_arg])
  325 ADD_GENTEST_BASH([infinity-illegal], [number of expected positional arguments before 'pos-arg' is unknown (because of argument 'pos-arg', which has a default)])
  326 ADD_GENTEST_BASH([bool-default], ['on' or 'off' are allowed as boolean defaults])
  327 ADD_GENTEST_BASH([pos-opt], [same-arg])
  328 ADD_GENTEST_BASH([pos-opt2], [same_arg])
  329 ADD_GENTEST_BASH([more], [is unknown])
  330 ADD_GENTEST_BASH([illegal-pos], [contains forbidden characters])
  331 ADD_GENTEST_BASH([illegal-opt], [one character])
  332 ADD_GENTEST_BASH([misspelled], [ARG_FOOBAR], [ARGBASH_GOO])
  333 dnl We have to escape \[ -> \@<:@ for grep
  334 ADD_GENTEST_BASH([unmatched_bracket], [unmatched square bracket on line 3], [[# ARG_OPTIONAL_BOOLEAN(\[long\], l, \@<:@)]])
  335 ADD_GENTEST_BASH([badcall-multi], [3rd argument], [num of args], [actual number of])