summaryrefslogtreecommitdiff
path: root/tests/scripts/options
Commit message (Collapse)AuthorAgeFilesLines
* [SV 64115] Suppress warnings about undefined GNUMAKEFLAGSDmitry Goncharov2023-04-301-0/+11
| | | | | * src/variable.c (defined_vars): Add GNUMAKEFLAGS to defined variables. * tests/scripts/options/warn: Add a test.
* [SV 64107] Disable builtins immediately on -R or -rDmitry Goncharov2023-04-301-2/+61
| | | | | | | | | | | Disable builtin variables and rules immediately, when -R or -r is added to MAKEFLAGS inside the makefile. * src/main.c (disable_builtins): Add new function disable_builtins(). (main): Call disable_builtins(). (reset_makeflags): Call disable_builtins(). * tests/scripts/options/dash-r: Add tests. * tests/scripts/variables/MAKEFLAGS: Update tests.
* tests: Run each file in a separate directoryPaul Smith2023-04-022-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Avoid cross-contamination between test files by creating a new working directory for each file, and setting it as the current directory before starting the tests in that file. Rename the test output as tNNN.{base,log,diff,mk} where NNN is a test number starting with 001 for the first test. It is slightly more annoying to find diff files since you can't use autocomplete directly but it is simpler to match things. Detect the source directory as the location of the test_driver.pl script, so remove the separate -srcdir option. * Makefile.am: Remove hacks to create symlinks when building out-of-tree, and remove -srcdir option from run_make_tests. * tests/test_driver.pl: Locate $srcpath based on __FILE__, then compute $toppath as its parent. Set $scriptpath under $srcpath and $workpath under the current directory. Toss $*_filename and modify get_logfile() etc. to use the suffix directly. Add a chdir() around the invocation of the test. * tests/run_make_tests.pl: Throw out the -srcdir option and use $srcpath set in test_driver.pl. The #WORK# helper is no longer useful so remove it. Set #PWD# to the current working dir. Always search the local directory and $srcpath for config-flags.pm. Use $srcpath for finding the thelp.pl script. * tests/scripts/features/vpath: Don't put things in work/ as it is no longer a subdirectory. * tests/scripts/features/vpathgpath: Ditto. * tests/scripts/features/vpathplus: Ditto. * tests/scripts/misc/general1: Ditto. * tests/scripts/misc/general2: Ditto. * tests/scripts/options/dash-k: Ditto. * tests/scripts/options/symlinks: Use $testpath as the working directory. * tests/scripts/variables/GNUMAKEFLAGS: Use the test helper to display env var values (grepping for GNUMAKEFLAGS finds extra things now that it is our current working directory).
* Adjust output strings to be alignedPaul Smith2023-04-024-4/+8
| | | | | | | | Change error and fatal messages to start with lowercase and not end with a period. Note a few very common messages were left as-is, just in case some other tools parse them. Also modify the test known-good-output to satisfy the messages.
* Add support for .WARNINGS special variablePaul Smith2023-04-021-11/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Create a new special variable, .WARNINGS, to allow per-makefile control over warnings. The command line settings will override this. Move the handling of warning flags to a new file: src/warning.c. Allow the decode to work with generic strings, and call it from decode_switches(). * Makefile.am: Add new file src/warning.c. * build_w32.bat: Ditto. * builddos.bat: Ditto. * po/POTFILES.in: Ditto. * src/makeint.h: #define for the .WARNINGS variable name. * src/warning.h: Add declarations for methods moved from main.c. Rename the enum warning_state to warning_action. * src/warning.c: New file. Move all warning encode/decode here from main.c. * src/main.c: Move methods into warning.c and call those methods instead. (main): Set .WARNINGS as a special variable. * src/job.c (construct_command_argv): Rename to warning_action. * src/read.c (tilde_expand): Ditto. * src/variable.c (set_special_var): Update warnings when the .WARNINGS special variable is set. * tests/scripts/options/warn: Check invalid warning options. * tests/scripts/variables/WARNINGS: Add tests for the .WARNINGS special variable.
* Add new warnings invalid-var and invalid-refPaul Smith2023-04-011-2/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | The "invalid-var" warning triggers if the makefile attempts to assign a value to an invalid variable name (a name containing whitespace). The "invalid-ref" warning triggers if the makefile attempts to reference an invalid variable name. Both new warnings have a default action of "warn". * NEWS: Add these new warnings. * doc/make.1: Document them in the man page. * doc/make.texi (Warnings): Document them in the user's manual. * src/warning.h: Add enum values for the new warning types. * src/main.c (initialize_warnings): Initialize the new warnings. * src/variable.h (undefine_variable_in_set, undefine_variable_global): Ask callers to provide a struct floc specifying where the variable is undefined. * src/read.c (do_undefine): Pass floc when undefining. * src/variable.c (check_valid_name): If invalid-var is enabled, check the variable name. (define_variable_in_set): Call it. (undefine_variable_in_set): Ditto. (check_variable_reference): If invalid-ref is enabled, check the variable reference. (lookup_variable): Call it. (lookup_variable_in_set): Ditto. * tests/scripts/options/warn: Add tests for the new warning types.
* Introduce a --warn command line optionPaul Smith2023-04-012-49/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace the singleton --warn-undefined-variables with infrastructure to manage multiple warnings: the --warn option can take an action "ignore", "warn", or "error" (which will apply to all warnings), or a specific warning type and an action for that type. Multiple options can be provided and are consolidated. * NEWS: Announce the new option. * doc/make.1: Document in the man page. * doc/make.texi (Warnings): Document in the user's manual. * Makefile.am: Add new header warning.h. * src/warning.h: Define enum for actions and warning types, and macros to test whether they are set. Keep the default settings separate so that we can correctly reconstruct MAKEFLAGS. * src/makeint.h: Remove deprecated warn_undefined_variables_flag. * src/main.c: Create global variables to hold warning settings. (switches): Add a new switch for --warn. (initialize_warnings): Set the default warning actions. (main): Call initialize_warnings(). (encode_warning_state, decode_warning_state): Convert warning states between strings and enums. (encode_warning_name, decode_warning_name): Convert warning names between strings and enums. (decode_warn_flags): Convert a --warn option into enum values. If deprecated warn_undefined_variables_flag is set convert it to --warn. (decode_switches): Don't remove duplicates of --warn since order matters. Call decode_warn_flags() to handle --warn. (define_makeflags): Special-case handling of --warn options written to MAKEFLAGS: write out the current settings. * src/read.c (tilde_expand): Use new warning control macros. * src/variable.c (warn_undefined): Ditto. * src/job.c (construct_command_argv): Ditto. * tests/scripts/options/warn: Rename from warn-undefined-variables and add tests for --warn. * tests/scripts/variables/MAKEFLAGS: Expect the new behavior.
* * tests/scripts/options/dash-l: Simplify the test via the helperPaul Smith2023-02-261-11/+6
| | | | * tests/thelp.pl: Add "exist" and "noexist" operators.
* * tests/scripts/features/reinvoke: Warn about closing STDIN.Paul Smith2023-01-111-0/+2
| | | | | * tests/scripts/features/temp_stdin: Ditto. * tests/scripts/options/dash-f: Ditto.
* [SV 61218] Ensure MAKEFLAGS is expanded even with -ePaul Smith2023-01-081-3/+12
| | | | | | | | | | | | | | If -e was given we weren't expanding MAKEFLAGS before passing it through the environment to jobs: we don't expand variables we receive from the environment and when -e is given we set the origin of MAKEFLAGS to "environment override". Check for MAKEFLAGS specifically, which seems like a hack but I don't have a better idea offhand. * src/main.c (main): Drive-by: use o_default for MAKEOVERRIDES. * src/variable.c (target_environment): Always expand MAKEFLAGS regardless of the origin type. * tests/scripts/options/dash-e: Create a test.
* [SV 63609] Avoid buffer overrun in --warn-undefined-variablesPaul Smith2023-01-031-0/+11
| | | | | | | | | Reported by Dmitry Goncharov <dgoncharov@users.sf.net> * src/variable.c (struct defined_vars): Create a struct that holds the name and length of each variable name. (warn_undefined): Check the lengths before comparing the contents. * tests/scripts/options/warn-undefined-variables: Add a test.
* Convert references from "GNU make" to "GNU Make"Paul Smith2023-01-012-2/+2
|
* [SV 63439, SV 63452] Don't warn on undefined internal variablesPaul Smith2022-12-241-0/+13
| | | | | | | | | | | | | | | | | Don't generate undefined variable warnings for variables that are internal / special to make and where the empty string is valid. Rather than defining them to empty, which could introduce unwanted behavior, keep a list of variable names which we should never warn about. * src/variable.h (warn_undefined): Convert the macro to a function. * src/variable.c (defined_vars): Always "defined" variable names. (warn_undefined): Implement as a function and check against the defined_vars before generating a warning. * src/read.c (read_all_makefiles): No need to reset warning flag. * src/vpath.c (build_vpath_lists): Ditto. * tests/scripts/options/warn-undefined-variables: Expand all the pre-defined variables to ensure warnings are not generated.
* [SV 63552] Change directories before constructing include pathsPaul Smith2022-12-241-45/+31
| | | | | | | | | | | | | | * src/makeint.h (reset_makeflags): New function to handle changing MAKEFLAGS from within makefiles. Remove decode_env_switches(). * src/variable.c (set_special_var): Call reset_makeflags() instead of various internal methods. * src/main.c (decode_env_switches): Only internal now so make static. (decode_switches): Don't invoke construct_include_path() yet. (reset_makeflags): Decode env switches and construct include paths. (main): Construct include paths after we process -C options. * tests/scripts/options/dash-C: Rewrite to use new test constructs. Add a test using both -C and -I together. Add a test for multiple -C options.
* tests [WINDOWS32]: Support Strawberry Perl on WindowsPaul Smith2022-12-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Strawberry Perl has some different behaviors from ActiveState Perl which impact the test suite: - Avoid Perl's chomp() as it may not remove CRs; chomp() may remove only the final NL but not the CR in a CRNL line ending. - Strawberry Perl doesn't support ActiveState's system(1, ...) form. - Strawberry Perl (or msys?) does something weird with "/tmp" when provided to exec(), replacing it with the user's %TEMP%. - Strawberry Perl uses msys paths like /c/foo instead of C:\foo. * tests/test_driver.pl (get_osname): Strawberry Perl uses 'msys' as its $^O so if we see that use a port of 'W32'. (_run_with_timeout): Strawberry Perl doesn't support the special system(1, ...) form of system() so use POSIX standard fork/exec. (compare_answer): Paths generated by Strawberry Perl use msys path format (e.g., /c/foo instead of C:\foo); check for those differences and compare RE against both the unmodified and modified log. * tests/run_make_tests.pl (set_defaults): Switch from chomp to s/// to remove CRNL and NL line endings. * tests/scripts/features/errors: Executing directories on Strawberry will give an error; translate it to Windows error output format. * tests/scripts/features/output-sync: Ditto. * tests/scripts/features/temp_stdin: Ditto. * tests/scripts/functions/realpath: Ditto. * tests/scripts/options/dash-I: Ditto. * tests/scripts/variables/INCLUDE_DIRS: Ditto. * tests/scripts/misc/close_stdout: /dev/full is reported as existing on Strawberry Perl, but it doesn't do anything. Skip the test. * tests/scripts/variables/MAKEFLAGS: When an argument containing /tmp is passed to a program via exec(), something replaces it with the expansion of the %TEMP% variable. Instead of using /tmp create a local directory to use.
* [SV 63537] Document and test flippable switchesDmitry Goncharov2022-12-181-4/+4
| | | | | | | | | | | | | | | | | | * doc/make.texi (Options/Recursion): Clarify that MAKEFLAGS values from the environment have precedence over those set in the makefile. * tests/scripts/variables/MAKEFLAGS: Check boolean switches -k/-S, -w/--no-print-directory and -s/--no-silent as follows: 1. A switch can be enabled or disabled on the command line. 2. A switch can be enabled or disabled in env. 3. A switch can be enabled or disabled in makefile. 4. Command line beats env and makefile. 5. Env beats makefile. 6. MAKEFLAGS contains each specified switch at parse and build time. 7. If switches are specified in multiple origins, MAKEFLAGS contains the winning switch at parse and build time. 8. MAKEFLAGS does not contain the losing switch. Also test that --debug settings from different origins are combined together into one option.
* Enhance tests to work on different systemsPaul Smith2022-10-221-8/+1
| | | | | | | | | | | | | | | | | | | | | The GNU platform testers reported a number of test errors on different systems; try to address them. * tests/thelp.pl: A number of tests timed out with a 4-second timeout. Increase the default timeout to 10 seconds. * tests/run_make_tests.pl: Executing directories on cygwin behaves differently in Perl than make so skip these tests there. * tests/scripts/options/symlinks: Check for the symlink feature in make, rather than whether the system supports them. * tests/scripts/features/implicit_search: On some systems "false" exits with a different exit code. Use the helper instead. * tests/scripts/features/loadapi: Ditto. * tests/scripts/features/output-sync: Sleep before make -f bar in the first test as well as the second one. * tests/scripts/features/exec: Skip on cygwin, which seems to be "UNIX" but where scripts don't run normally. * tests/scripts/misc/fopen-fail: Skip on cygwin, where make eventually exits with exit code 0 and no error messages.
* [SV 56301] Fail if an included makefile can't be builtDmitry Goncharov2022-09-201-3/+2
| | | | | | | | | | Fail if a mandatory include file fails to be built even if it's built as part of a grouped target where the other include file is optional. * src/main.c (main): If a makefile doesn't build set any_failed. * tests/scripts/features/include: Add tests. * tests/scripts/options/dash-k: Stop after include build failure.
* [SV 63047] Fix shuffle of SECONDEXPANSION prerequisitesSergei Trofimovich2022-09-121-0/+9
| | | | | | | | | | | | | | Commit 07eea3aa4 `make --shuffle` prevented shuffling prerequisites that use .SECONDEXPANSION, since shuffle happens before expansion. This has two problems: 1. No shuffling happens for such prerequisites. 2. Use-after-free when outdated '->shuf' links are used. Add a reshuffle into expansion phase right after dependency changes. * src/file.c (expand_deps): Add reshuffle if dependencies change. * src/shuffle.c (identity_shuffle_array): Fix comment typo. * tests/scripts/options/shuffle: Add new SECONDEXPANSION test.
* [SV 62100] Add '--shuffle' option supportSergei Trofimovich2022-06-041-0/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce non-deterministic ordering into goal and prerequisite traversal to help tease out inconsistent failures that may happen when running in parallel build mode. Introduce second order into each dependency chain: 1. Existing order is syntactic order reachable via 'dep->next' 2. New order is shuffled order stored as 'dep->shuf' in each 'dep' When updating goals and prerequisites and '--shuffle' is provided, use the shuffled order to walk the graph. When automatic variable are set always use the syntactic order of parameters. * Makefile.am: Add new src/shuffle.c and src/shuffle.h file. * build_w32.bat: Ditto. * builddos.bat: Ditto. * makefile.com: Ditto. * po/POTFILES.in: Ditto. * doc/make.texi: Add documentation for --shuffle. * doc/make.1: Ditto. * src/dep.h (DEP): Add the shuf pointer. * src/filedef.h (struct file): Add was_shuffled flag. * src/main.c: (shuffle_mode): Global flag for the shuffle mode. (usage): Add the --shuffle option. (switches): Ditto. (main): Set shuffle_mode based on the command line parameter. Reshuffle prerequisites if requested. * src/remake.c (update_goal_chain): Walk the shuffled list if enabled. (update_file_1): Ditto. * src/shuffle.h: Provide an interface for shuffling prerequisites. * src/shuffle.c: Implement option parsing and prerequisite shuffling. * tests/scripts/options/shuffle: Test shuffle option and modes.
* * tests/scripts/options/dash-f: [SV 62118] Close STDINPaul Smith2022-04-241-2/+1
| | | | | On Windows we can't delete open files, so close STDIN before removing the temporary input file.
* [SV 62356] If -R is set in the makefile, disable -rDmitry Goncharov2022-04-241-0/+8
| | | | | | | | | If -R is given on the command line it implies -r as well; make this same assumption if -R is provided in MAKEFLAGS set in the makefile. * src/main.c (main): Check no_builtin_variables_flag after reading makefiles. * tests/scripts/options/dash-r: Add a test.
* * tests/scripts/options/dash-l: [SV 62172] Skip if not availableDmitry Goncharov2022-04-241-3/+4
|
* * tests/scripts/features/errors: Fix Perl warningsPaul Smith2022-04-181-12/+15
| | | | * tests/scripts/options/dash-f: Ditto.
* [SV 62118] Correctly handle -f- options on re-execPaul Smith2022-02-271-10/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The -f, -file, and --makefile options were not properly handled when re-exec'ing due to makefile updates. This problem, plus a patch and tests, was reported by Dmitry Goncharov <dgoncharov@users.sf.net>. While examining this I found another bug: after re-exec we forgot the batch file was temporary and never deleted it. I decided to fix all these problems at once using a different fix than Dmitry's: I created a new internal-only command-line option, --temp-stdin. When reconstructing the make options for a re-exec, replace the -f/--file/--makefile option that reads from stdin with --temp-stdin=<filename> so that the re-exec'd version of make knows it's a temporary batch file and will delete it. We no longer need to add the -o options because the re-exec'd make knows this is a temporary makefile and treats it as such. To simplify, replace the --file and --makefile options taking a filename, with just -f<filename> on re-exec. Some examples of the rewrite: User command line Re-exec command line ----------------- -------------------- -f- --temp-stdin=<batch> --file - --temp-stdin=<batch> -f - --makefile a.mk --temp-stdin=<batch> -fa.mk --file=a.mk -fa.mk -fa.mk -fa.mk -Rf a.mk -Rf a.mk -Rf- -R --temp-stdin=<batch> * src/main.c (stdin_offset): Remember the offset into the makefiles list of the batch file read from stdin. Remove stdin_nm. (struct command_switch): Create a new --temp-stdin option, which also updates the makefiles list. (main): Add the temporary filename to the string cache. Move the tempfile handling after checking makefile arguments for "-" so that files provided via --temp-stdin are also handled specially. When rewriting re-exec options, we may need one more than we had originally so create a new argv list. Walk through the original list and convert it to the new list, following the above process. (decode_switches): Set the stdin_offset flag if we see --temp-stdin. * tests/scripts/options/dash-f: Add many more tests, provided by Dmitry Goncharov <dgoncharov@users.sf.net>.
* tests: Allow run_make_test() to avoid passing -fPaul Smith2022-02-271-1/+1
| | | | | | | | | | | | We already use undef makefile strings to mean "re-use the previous makefile", so if the string is empty we'll assume it means "don't use a makefile at all" (don't add -f). * tests/run_make_tests.pl (run_make_test): If the makefile string is empty, don't create a makefile or add -f. * tests/scripts/features/include: Change empty makefile to "\n". * tests/scripts/misc/close_stdout: Ditto. * tests/scripts/options/dash-r: Ditto.
* tests: Enhance output to contain filename/line number infoPaul Smith2021-11-271-1/+1
| | | | | | | | * tests/scripts/options/dash-I: Use string comparison operator. * tests/test_driver.pl (cmd2str): New method to convert a command line to a string with proper quoting. * tests/run_make_tests.pl (create_command): Call cmd2str() to format the command. Add the filename/line number to the output.
* * src/main.c (decode_debug_flags): [SV 607777] Preserve -d optionsDmitry Goncharov2021-09-061-0/+9
| | | | * tests/scripts/options/dash-d: Test that -d --trace keeps -d.
* [SV 45211] Parse MAKEFLAGS immediately when it's resetPaul Smith2021-09-051-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When MAKEFLAGS is set in a makefile, reparse it immediately rather than waiting until after all makefiles have been read and parsed. This change doesn't actually fix the SV bug referenced because, even though we do reparse MAKEFLAGS, we don't handle the -r or -R options immediately. Doing this will require more effort. * NEWS: Announce the change. * src/makeint.h: Publish reset_switches() and decode_env_switches() from main.c * src/main.c (main): Don't call construct_include_path(); it will be invoked decode_switches(). Preserve the old values of builtin_rules, builtin_variables, and job_slots before we read makefiles since they can be changed now. (reset_switches): Publish (remove static). Set the initial value of the stringlist list to NULL. (decode_switches): Call construct_include_path() after decoding. (decode_env_switches): Publish (remove static). (define_makeflags): Set the MAKEFLAGS variable for special handling. * src/read.c (eval_makefile): Check for empty include_directories. (construct_include_path): Clear any old value of .INCLUDE_DIRS before appending new values. Free the previous include_directories. * src/variable.c (lookup_special_var): When MAKEFLAGS is set, first reset the switches then re-parse the variable. * tests/run_make_tests.pl: Memo-ize some default variable values. * tests/scripts/options/dash-r: Create tests for setting -r and -R. * tests/scripts/variables/MAKEFLAGS: Test that resetting -I from within the makefile takes effect immediately.
* [SV 60595] Restart whenever any makefile is rebuiltPaul Smith2021-09-031-1/+1
| | | | | | | | | | | | | | | | | | | | | Previously if an included makefile was rebuilt as a prerequisite of another included makefile which didn't need to be rebuilt, make would not realize that it needed to re-exec itself. Ensure that if any included makefile target is rebuilt we re-exec. Also ensure that if an included makefile is not readable, and our rule for rebuilding it doesn't actually change it, we will still fail. * src/remake.c (update_goal_chain): If a goal's update was successful then check its status, even if no actual commands were run because it was already up to date. (show_goal_error): Remove superfluous cast. * src/main.c (main): If the makefile remake did nothing, check that we were able to successfully include all the makefiles we care about; if not fail. When generating error messages about included makefiles be sure to show the filename/linenumber information. * test/scripts/features/reinvoke: Add tests for this behavior. * test/scripts/options/dash-k: Update error messages.
* [SV 60412] Allow -I- to throw out the current directory pathPaul Smith2021-09-031-34/+89
| | | | | | | | | | | | | Accept a "-" directory value to the -I option to clear the set of directories to be searched up to that point, including the default directories. * NEWS: Announce the change. * doc/make.texi (Summary of Options): Add documentation. * src/read.c (construct_include_path): Check for '-' and if found, clear the list of directories to be searched. * tests/scripts/options/dash-I: Add tests for -I-. * tests/scripts/variables/INCLUDE_DIRS: Add tests for -I-.
* tests: Simplify customization of %ENVPaul Smith2020-04-011-13/+4
| | | | | | | | | | | | | | | | | | | | | | Rather than having an %extraENV that is added to the default %ENV and resetting %ENV _before_ each test, allow the test setup to modify %ENV directly as needed then reset %ENV _after_ each test. * tests/test_driver.pl: Remove unused %extraENV. (resetENV): Don't add in %extraENV. (_run_command): Reset after we run the command rather than before. * tests/scripts/features/export: Convert %extraENV to %ENV * tests/scripts/features/jobserver: Ditto * tests/scripts/features/parallelism: Ditto * tests/scripts/features/targetvars: Ditto * tests/scripts/functions/eval: Ditto * tests/scripts/functions/foreach: Ditto * tests/scripts/functions/origin: Ditto * tests/scripts/misc/general4: Ditto * tests/scripts/options/dash-e: Ditto * tests/scripts/targets/POSIX: Ditto * tests/scripts/variables/GNUMAKEFLAGS: Ditto * tests/scripts/variables/SHELL: Ditto
* Obey order of multiple print/no-print directory optionsPaul Smith2020-03-311-7/+44
| | | | | | | | | | | | | | | | | | | | | | | | | Previously if --no-print-directory was seen anywhere even once (environment, command line, etc.) it would always take precedence over any --print-directory option. Change this so that the last seen option (which will be the command line, if present there) takes precedence. * NEWS: Mark this change in behavior. * src/makeint.h (print_directory): A new variable to control printing. * src/output.c (output_dump): Use the new variable. (output_start): Ditto. * src/main.c: Add a new variable print_directory. Use -1 for print_directory_flag so we know of the option was seen or not. Add a new default_print_directory_flag set to -1 to keep options from being added. (switches): Use flag_off for --no-print-directory, rather than a separate inhibit_print_directory_flag. (main): If print_directory_flag was set by the user, use that for print_directory. If not, compute the print_directory value based on -s, -C, and sub-makes as before. * tests/scripts/variables/GNUMAKEFLAGS: -w is not added automatically * tests/scripts/options/print-directory: Add tests for overriding print-directory options.
* * job.c (child_error): Modify error message string.Paul Smith2019-09-221-1/+1
| | | | | | | | This reverts commit 6264deece3bb77798240a906ceed79097adbcf48. Further investigation discovers that the real issue is that GNU Emacs compile mode doesn't have a matching regex for GNU make error messages generated when targets fail. I submitted a patch to GNU Emacs adding a matcher for compile mode.
* * tests: Convert from File::Spec::Functions to File::Spec.Paul Smith2019-09-211-2/+4
| | | | | Users report the Functions version doesn't work correctly for some older versions of Perl.
* * tests/run_make_test.pl: Fix support for valgrind.Paul Smith2019-09-211-1/+1
| | | | | Change the variable holding the make command to be a list that can hold extra commands and options, not just a string.
* Refresh the test suite framework implementation.Paul Smith2019-09-163-51/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | Go through both run_make_tests.pl and test_driver.pl and slightly modernize the Perl and clean up indentation etc. Fix a number of warnings in the test scripts detected by running with -w. * tests/test_driver.pl: Move make error string detection out of the base test driver. (run_all_tests): Ensure that we always look for tests in the cwd. * tests/run_make_tests.pl: Use File::Spec for path manipulations. Correctly use setlocale() when detecting error strings. Get configuration from the config-flags.pm file not config.status. * tests/scripts/features/archives: Use new $cwddir variable. * tests/scripts/features/reinvoke: Add missing semicolon. * tests/scripts/features/vpath2: Avoid non-existent variable. * tests/scripts/functions/foreach: Escape variables. * tests/scripts/misc/bs-nl: Remove non-existing \v escape sequence. * tests/scripts/misc/general4: Use handy create_file(). * tests/scripts/options/dash-C: Use Cwd/$cwddir. * tests/scripts/options/dash-I: Use subst_make_string() and #PWD#. * tests/scripts/options/symlinks: Use File::Spec. * tests/scripts/targets/DEFAULT: Use create_file and run_make_test. * tests/scripts/variables/CURDIR: Use run_make_test. * tests/scripts/variables/automatic: Remove extraneous "\". * tests/scripts/vms/library: Remove extra "my" and extraneous "\".
* * job.c (child_error): Modify error message string.Paul Smith2017-10-301-1/+1
| | | | | Ensure Emacs compile-mode's next-error doesn't match target failure messages. Syntax errors in makefiles are still matched.
* Add test suite support to WindowsPaul Smith2017-06-044-35/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * main.c (main): Sanitize program name detection on Windows. * makeint.h: 'program' is a const string on all platforms now. * tests/run_make_tests.bat: Windows bat file to invoke tests * tests/test_driver.pl: Obtain system-specific error messages. (get_osname): Compute the $port_type here. Add more $osname checks for different Windows Perl ports. (_run_command): Rewrite the timeout capability to work properly with Windows. Don't use Perl fork/exec; instead use system(1,...) which allows a more reliable/proper kill operation. Also, allow options to be given as a list instead of a string, to allow more complex quoting of command-line arguments. * tests/run_make_tests.pl (run_make_with_options): Allow options to be provided as a list in addition to a simple string. (set_more_defaults): Write sample makefiles and run make on them instead of trying to run echo and invoking make with -f-, to avoid relying on shell and echo to get basic configuration values. Also create a $sh_name variable instead of hard-coding /bin/sh. * tests/scripts/features/archives: Skip on Windows. * tests/scripts/features/escape: Use list method for passing options. * tests/scripts/features/include: Use system-specific error messages. * tests/scripts/features/output-sync: "Command not found" errors generate very different / odd output on Windows. This needs to be addressed but for now disable these tests on Windows. * tests/scripts/functions/abspath: Disable on Windows. * tests/scripts/functions/file: Use system-specific error messages. * tests/scripts/functions/shell: "Command not found" errors generate very different / odd output on Windows. This needs to be addressed but for now disable these tests on Windows. * tests/scripts/misc/close_stdout: Disable on Windows. * tests/scripts/options/dash-k: Use system-specific error messages. * tests/scripts/options/dash-l: Disable on Windows. * tests/scripts/options/eval: Use list method for passing options. * tests/scripts/options/general: Skip some non-portable tests. * tests/scripts/targets/ONESHELL: Skip some non-portable tests. * tests/scripts/targets/POSIX: Skip some non-portable tests. * tests/scripts/variables/MAKEFILES: Skip some non-portable tests. * tests/scripts/variables/SHELL: Use a makefile not -f- for testing.
* * main.c (switches): Add -E as an alias for --eval.Paul Smith2016-12-281-2/+17
| | | | | | | * make.1: Document the -E and --eval options. * doc/make.texi: Document the -E option. * tests/scripts/options/eval: Test the -E option and MAKEFILES. * NEWS: Add information about the new option.
* * main.c (switches): Add --no-silent to undo -s options.Paul Smith2016-12-281-0/+26
| | | | | | | | * make.1: Document the new flag. * doc/make.texi: Document the new flag. Remove suggestions that the .SILENT special target is deprecated or should not be used. * tests/scripts/options/dash-s: Test the -s and --no-silent options. * NEWS: Add information about the new option.
* Portability changes for the test suite.Paul Smith2016-12-263-31/+21
| | | | | | * tests/test_driver.pl: Save error strings for later comparison. * tests/run_make_tests.pl: Create portable commands for later use. * tests/*: Use these new variables.
* [SV 102] Don't show unnecessary include file errors.Paul Smith2016-04-093-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | Delay the generation of error messages for included files until we are sure that we can't rebuild that included file. * dep.h (struct dep): Don't reuse "changed"; make a separate field to keep "flags". Get rid of dontcare and use the flag. (struct goaldep): Create a new structure for goal prereqs that tracks an errno value and the floc where the include happened. Rework the structures to ensure they are supersets as expected. In maintainer mode with GCC, use inline to get type checking. * read.c (eval_makefile): Return a struct goaldep for the new makefile. Ensure errno is set properly to denote a failure. (read_all_makefiles): Switch to goaldep and check errno. (eval): Don't show included file errors; instead remember them. * remake.c (update_goal_chain): Set global variables to the current goaldep we're building, and the entire chain. (show_goal_error): Check if the current failure is a consequence of building an included makefile and if so print an error. (complain): Call show_goal_error() on rule failure. * job.c (child_error): Call show_goal_error() on child error. * main.c (main): Switch from struct dep to goaldep. * misc.c (free_dep_chain): Not used; make into a macro. * tests/scripts/features/include: Update and include new tests. * tests/scripts/options/dash-B, tests/scripts/options/dash-W, tests/scripts/options/print-directory, tests/scripts/variables/MAKE_RESTARTS: Update known-good-output.
* * tests/run_make_tests.pl: Preserve $make_commandPaul Smith2016-03-231-1/+1
| | | | | * tests/scripts/options/dash-n: Use $make_command. This fixes a spurious failure when running tests with valgrind enabled.
* * job.c (child_error): Combine file info with error message.Paul Smith2016-03-201-3/+2
| | | | * tests/scripts/...: Update error message matches.
* [SV 47151] Exit with 1 when checking recursive make -qPaul Smith2016-02-291-0/+9
| | | | | | | | * job.h (struct child): New bit to mark recursive command lines. * job.c (start_job_command): Set the recursive command line bit. (reap_children): If the child is a recursive command and it exits with 1 during question mode, don't print an error and exit with 1. * tests/scripts/options/dash-q: Add a regression test.
* [SV 42249] Propagate correct rule status results.Paul Smith2014-05-011-12/+32
| | | | | | | * remake.c (update_file, update_file_1, check_dep): Return an enum update_status value instead of an int, and keep the highest value we find as we walk the graph so that the ultimate status is correct. * tests/scripts/options/dash-q: Add a test for updating prerequisites.
* Rename dash-w to print-directory.Paul Smith2013-09-231-0/+0
| | | | Avoid conflicts with dash-W on case-insensitive filesystems.
* Don't write "Entering" every time we re-exec for remake makefiles.Paul Smith2013-09-211-0/+33
|
* [SV 39203] Don't set MAKEFLAGS when restarting.Paul Smith2013-09-151-0/+10
| | | | | We are restarting with the original command line flags, so if we set MAKEFLAGS as well that will cause double flags.