Module Name: src Committed By: rillig Date: Sun Sep 10 11:41:33 UTC 2023
Modified Files: src/usr.bin/make: main.c src/usr.bin/make/unit-tests: opt-jobs.mk Log Message: make: add more details to usage message of -j option To generate a diff of this commit: cvs rdiff -u -r1.597 -r1.598 src/usr.bin/make/main.c cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-jobs.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/main.c diff -u src/usr.bin/make/main.c:1.597 src/usr.bin/make/main.c:1.598 --- src/usr.bin/make/main.c:1.597 Sun Sep 10 10:18:05 2023 +++ src/usr.bin/make/main.c Sun Sep 10 11:41:32 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.597 2023/09/10 10:18:05 rillig Exp $ */ +/* $NetBSD: main.c,v 1.598 2023/09/10 11:41:32 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,7 +111,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.597 2023/09/10 10:18:05 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.598 2023/09/10 11:41:32 rillig Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -424,8 +424,9 @@ MainParseArgJobs(const char *arg) #endif if (*p != '\0' || opts.maxJobs < 1) { (void)fprintf(stderr, - "%s: illegal argument to -j -- must be positive integer!\n", - progname); + "%s: argument '%s' to option '-j' " + "must be a positive number\n", + progname, arg); exit(2); /* Not 1 so -q can distinguish error */ } snprintf(v, sizeof(v), "%d", opts.maxJobs); Index: src/usr.bin/make/unit-tests/opt-jobs.mk diff -u src/usr.bin/make/unit-tests/opt-jobs.mk:1.3 src/usr.bin/make/unit-tests/opt-jobs.mk:1.4 --- src/usr.bin/make/unit-tests/opt-jobs.mk:1.3 Sun Sep 10 11:00:55 2023 +++ src/usr.bin/make/unit-tests/opt-jobs.mk Sun Sep 10 11:41:33 2023 @@ -1,22 +1,23 @@ -# $NetBSD: opt-jobs.mk,v 1.3 2023/09/10 11:00:55 rillig Exp $ +# $NetBSD: opt-jobs.mk,v 1.4 2023/09/10 11:41:33 rillig Exp $ # # Tests for the -j command line option, which creates the targets in parallel. # The option '-j <integer>' specifies the number of targets that can be made # in parallel. -ARGS= 0 1 2 8 08 0x10 -5 1000 -EXPECT.0= illegal argument to -j -- must be positive integer! exit 2 +ARGS= 0 1 2 8 08 017 0x10 -5 1000 +EXPECT.0= argument '0' to option '-j' must be a positive number (exit 2) EXPECT.1= 1 EXPECT.2= 2 EXPECT.8= 8 -EXPECT.08= illegal argument to -j -- must be positive integer! exit 2 +EXPECT.08= argument '08' to option '-j' must be a positive number (exit 2) +EXPECT.017= 15 EXPECT.0x10= 16 -EXPECT.-5= illegal argument to -j -- must be positive integer! exit 2 +EXPECT.-5= argument '-5' to option '-j' must be a positive number (exit 2) EXPECT.1000= 1000 .for arg in ${ARGS} -OUTPUT!= ${MAKE} -r -f /dev/null -j ${arg} -v .MAKE.JOBS 2>&1 || echo exit $$? +OUTPUT!= ${MAKE} -r -f /dev/null -j ${arg} -v .MAKE.JOBS 2>&1 || echo "(exit $$?)" . if ${OUTPUT:[2..-1]} != ${EXPECT.${arg}} . warning ${arg}:${.newline} have: ${OUTPUT:[2..-1]}${.newline} want: ${EXPECT.${arg}} . endif @@ -25,20 +26,22 @@ OUTPUT!= ${MAKE} -r -f /dev/null -j ${ar # The options '-j <float>' and '-j <integer>C' multiply the given number with # the number of available CPUs. -ARGS= 0.0 .5 .5C 1C 1CPUs 1.2 .5e1C 07.5C 08.5C -EXPECT.0.0= illegal argument to -j -- must be positive integer! exit 2 -EXPECT..5= <integer> # rounded up to 1 if necessary -EXPECT..5C= <integer> # rounded up to 1 if necessary +ARGS= 0.0 0C 0.0C .00001 .00001C 1C 1CPUs 1.2 .5e1C 07.5C 08.5C +EXPECT.0.0= argument '0.0' to option '-j' must be a positive number (exit 2) +EXPECT.0C= <integer> # rounded up to 1C +EXPECT.0.0C= argument '0.0C' to option '-j' must be a positive number (exit 2) +EXPECT..00001= argument '.00001' to option '-j' must be a positive number (exit 2) +EXPECT..00001C= argument '.00001C' to option '-j' must be a positive number (exit 2) EXPECT.1C= <integer> EXPECT.1CPUs= <integer> EXPECT.1.2= <integer> EXPECT..5e1C= <integer> # unlikely to occur in practice EXPECT.07.5C= <integer> -EXPECT.08.5C= illegal argument to -j -- must be positive integer! exit 2 +EXPECT.08.5C= argument '08.5C' to option '-j' must be a positive number (exit 2) .if ${.MAKE.JOBS.C} . for arg in ${ARGS} -OUTPUT!= ${MAKE} -r -f /dev/null -j ${arg} -v .MAKE.JOBS 2>&1 || echo exit $$? +OUTPUT!= ${MAKE} -r -f /dev/null -j ${arg} -v .MAKE.JOBS 2>&1 || echo "(exit $$?)" . if ${OUTPUT:C,^[0-9]+$,numeric,W} == numeric OUTPUT= <integer> . endif