Module Name: src Committed By: rillig Date: Sat Nov 14 17:33:51 UTC 2020
Modified Files: src/usr.bin/make/unit-tests: opt.exp opt.mk Log Message: make(1): add tests for edge cases in parsing the command line To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/unit-tests/opt.exp diff -u src/usr.bin/make/unit-tests/opt.exp:1.1 src/usr.bin/make/unit-tests/opt.exp:1.2 --- src/usr.bin/make/unit-tests/opt.exp:1.1 Sun Aug 16 12:07:51 2020 +++ src/usr.bin/make/unit-tests/opt.exp Sat Nov 14 17:33:51 2020 @@ -1 +1,19 @@ +make -: +usage: make [-BeikNnqrstWwX] + [-C directory] [-D variable] [-d flags] [-f makefile] + [-I directory] [-J private] [-j max_jobs] [-m directory] [-T file] + [-V variable] [-v variable] [variable=value] [target ...] +*** Error code 2 (ignored) + +make -- -VAR=value -f /dev/null +make: don't know how to make -f (continuing) +`/dev/null' is up to date. + +make -? +usage: make [-BeikNnqrstWwX] + [-C directory] [-D variable] [-d flags] [-f makefile] + [-I directory] [-J private] [-j max_jobs] [-m directory] [-T file] + [-V variable] [-v variable] [variable=value] [target ...] +*** Error code 2 (ignored) + exit status 0 Index: src/usr.bin/make/unit-tests/opt.mk diff -u src/usr.bin/make/unit-tests/opt.mk:1.2 src/usr.bin/make/unit-tests/opt.mk:1.3 --- src/usr.bin/make/unit-tests/opt.mk:1.2 Sun Aug 16 14:25:16 2020 +++ src/usr.bin/make/unit-tests/opt.mk Sat Nov 14 17:33:51 2020 @@ -1,8 +1,24 @@ -# $NetBSD: opt.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $ +# $NetBSD: opt.mk,v 1.3 2020/11/14 17:33:51 rillig Exp $ # # Tests for the command line options. # TODO: Implementation -all: - @:; +.MAKEFLAGS: -d0 # make stdout line-buffered + +all: .IGNORE + # Just to see how the custom argument parsing code reacts to a syntax + # error. The colon is used in the options string, marking an option + # that takes arguments. It is not an option by itself, though. + ${MAKE} -: + @echo + + # See whether a '--' stops handling of command line options, like in + # standard getopt programs. Yes, it does, and it treats the '-f' as + # a target to be created. + ${MAKE} -- -VAR=value -f /dev/null + @echo + + # This is the normal way to print the usage of a command. + ${MAKE} -? + @echo