Commit graph

382 commits

Author SHA1 Message Date
Paul Smith
7449abfe1b * tests/test_driver.pl: Compute full path to Perl interpreter 2020-01-03 02:08:59 -05:00
Paul Smith
53b9770b40 * tests/scripts/features/exec: Don't use $ENV in the description 2020-01-03 02:08:59 -05:00
Paul Smith
e64674b718 [SV 57022] Avoid posix_spawn which fails asynchronously
Avoid using posix_spawn implementations that fail asynchronously when
the spawned program can't be invoked: this means instead of getting
an error such as "No such file or directory" we get just "Exit 127".

Original implementation of the configure.ac macro provided by
Martin Dorey <martin.dorey@hds.com>

Original implementation of the regression tests provided by
Dmitry Goncharov <dgoncharov@users.sf.net>

* configure.ac: Test whether posix_spawn fails asynchronously.  In a
cross-compilation environment, assume that it does not.  If we detect
that it does, fall back to fork/exec.
* tests/scripts/features/exec: Add regression tests for different
shebang invocation methods.
2019-12-27 01:37:17 -05:00
Paul Smith
564fb212a7 [SV 56655] Allow pattern expansion to contain spaces
* src/dep.h: Add a new flag PARSEFS_ONEWORD
* src/read.c (parse_file_seq): If PARSEFS_ONEWORD is given, treat the
entire incoming string as a single pattern.
* src/implicit.c (pattern_search): Pass PARSEFS_ONEWORD when parsing
patterns for wildcards.
* tests/scripts/features/patternrules: Add a new test.
2019-12-26 18:39:56 -05:00
Jouke Witteveen
86f2f8bcb5 [SV 54161] Fix second expansion of $* for paths
If the stem matches a path containing a directory not just a
filename, make sure the second expansion of $* in the
prerequisites matches $* in the recipe.  This requires using
$(*F) when replacing % in the first expansion to preserve the
simple filename.

* src/implicit.c (pattern_search): If lastslash is set prepend
the directory onto the stem.  Then use $(*F) when expanding %.
* tests/scripts/features/se_implicit: Add a test case
2019-12-18 09:05:17 -05:00
Paul Smith
f389aabde6 * tests/run_make_tests.pl (set_more_defaults): Fix typo 2019-12-17 15:06:28 -05:00
Paul Smith
acbef3f612 * tests/run_make_tests.pl (subst_make_string): Force use of /
On Windows the path to the helper tool will contain '\': this will
fail if recipes are run with a POSIX shell.  Convert '\' to '/'
on Windows.  While here, escape any spaces in the path as well.
2019-12-16 16:18:58 -05:00
Paul Smith
3822f77c1d Rename jhelp.pl to thelp.pl and make it a generic test helper.
* tests/thelp.pl: Rename from tests/jhelp.pl.
(op): Use names instead of options for the operations.
(op): Add new operations for sleep, mkdir, and rm.
(op): Enhance wait to time out
* tests/run_make_tests.pl: Add a new #HELPER# replacement
(subst_make_string): Use fully-qualified path to thelp.pl
* tests/scripts/features/parallelism: Update to use thelp.pl
and the new named operations.  Use thelp.pl sleep instead of
system-specific sleep commands.
* tests/scripts/features/output-sync: Update to use thelp.pl
instead of complex shell scripts.
* Makefile.am: Distribute tests/thelp.pl instead of tests/jhelp.pl
2019-12-16 09:31:31 -05:00
Paul Eggert
1cf3932a39 Port functions/shell test to Solaris 10
* tests/scripts/functions/shell: Port exit-status calculation
to Solaris 10 with Perl 5.8.4.
2019-10-10 18:31:50 -04:00
Paul Smith
5920d6d2b3 * Makefile.am (check-regression): Use PERLFLAGS when running Perl
* maintMakefile: Set PERLFLAGS to enable warnings.
* tests/run_make_tests.pl: Clean up issues pointed out by perl -w.
2019-10-05 17:48:19 -04:00
Paul Smith
2e6468c811 * tests/scripts/functions/wildcard: Skip slash tests for local glob. 2019-10-05 17:48:19 -04:00
Paul Smith
393d2a2d4a tests: Convert %CONFIG_FLAGS to get_config()
* tests/config-flags.pm.W32: Create a predefined Windows file.
* Makefile.am (test_FILES): Add it to the distribution.
* build_w32.bat: Install tests/config-flags.pm if not existing.
* tests/run_make_tests.pl (get_config): Create new function.
* tests/scripts/features/archives: Call get_config() rather than
using %CONFIG_FLAGS directly.
* tests/scripts/features/load: Ditto.
* tests/scripts/features/loadapi: Ditto.
* tests/scripts/functions/wildcard: Ditto.
2019-10-05 17:47:52 -04:00
Paul Smith
a4a173928f * tests/run_make_tests.pl (valid_option): Add missing File::Spec 2019-10-05 07:43:52 -04:00
Paul Smith
b0eab8ecb9 * tests/scripts/features/vpathplus: Fix output for big-endian systems.
Our hashing algorithm gives different ordering on LE vs BE systems.
Patch from Dmitry Goncharov <dgoncharov@users.sf.net>.
2019-09-22 17:35:51 -04:00
Paul Smith
99d1423059 * test/test_driver.el (_run_with_timeout): Show error message. 2019-09-22 17:03:05 -04:00
Paul Smith
7fbd58cd6b * job.c (child_error): Modify error message string.
This reverts commit 6264deece3.
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.
2019-09-22 17:02:57 -04:00
Paul Smith
3ede0b96ac * tests: Convert from File::Spec::Functions to File::Spec.
Users report the Functions version doesn't work correctly for some
older versions of Perl.
2019-09-21 16:37:56 -04:00
Paul Smith
1d289b424a * tests/scripts/function/guile: Valgrind doesn't work with Guile. 2019-09-21 15:38:52 -04:00
Paul Smith
bd4ce86785 [SV 56918] Compute job slots properly on failing command
Ensure we properly reduce job_slots_used if a command fails because
it doesn't exist/can't be started.

* src/job.h (struct child): Add a field jobslot to be set when using
a job slot.
* src/job.c (start_waiting_job): Remember if we are using a job slot.
(reap_children): Reduce number of job slots used by jobslot.
2019-09-21 15:38:48 -04:00
Paul Smith
af0074547d * tests/scripts/functions/shell: Detect correct SHELLSTATUS code. 2019-09-21 15:13:32 -04:00
Paul Smith
4a7a8278e8 * tests/run_make_test.pl: Fix support for valgrind.
Change the variable holding the make command to be a list that can
hold extra commands and options, not just a string.
2019-09-21 15:13:24 -04:00
Paul Smith
00fa3ca3a5 * tests/run_make_tests.pl (find_prog): Fix syntax error. 2019-09-21 12:39:07 -04:00
Paul Smith
4c64a5f986 * tests/run_make_tests.pl: Create $scriptsuffix for Windows/VMS.
* tests/scripts/features/targetvars: Add a suffix to scripts.
* tests/scripts/misc/general4: Ditto.
2019-09-16 08:25:33 -04:00
Paul Smith
414af96a50 Refresh the test suite framework implementation.
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 "\".
2019-09-16 08:25:33 -04:00
Paul Smith
1b976397e5 * tests/config-flags.pm.in: Add USE_SYSTEM_GLOB.
* tests/config_flags_pm.com [VMS]: Ditto.
2019-09-16 08:25:33 -04:00
Paul Smith
57b13c8020 * tests/test_driver.pl: Remember error for "running" a directory.
* tests/scripts/features/errors: Check errors "running" a directory.
2019-09-16 08:25:33 -04:00
Paul Smith
02a4c2913a * src/job.c (child_execute_job): Use errno from find_in_given_path().
* tests/test_driver.pl: Determine non-executable error message.
* tests/scripts/features/errors: Use the local non-executable error.
2019-09-16 08:25:33 -04:00
Paul Smith
60905a8afb [SV 56834] Support local PATH search with posix_spawnp
When using exec we install the child's environment before invoking
execlp(), so commands are found on the child's PATH.  posix_spawnp
searches on the parent's PATH, which we don't want.

Import gnulib's findprog-in module and use it to search the child's
PATH, then use posix_spawn() to run it.

Also, posix_spawn() does not fall back to trying sh on ENOEXEC, as
execlp() does, so implement that as well.

* bootstrap.conf: Add the findprog-in gnulib module
* src/job.c: Include findprog.h if we're using posix_spawn.
(start_job_command): Remove the handling of child->cmd_name,
(child_execute_job): and add it here.  Look up the command to be
run in the child's path and invoke it if found.  If it fails with
ENOEXEC then retry it as an argument to the default shell.
* tests/scripts/misc/general4: Test makefile PATH assignments.
* tests/scripts/features/targetvars: Ditto, for target variables.
2019-09-08 15:12:40 -04:00
Paul Smith
5ff6ae6177 * tests/scripts/features/archives: Fix expected long ar name output. 2019-09-07 18:27:26 -04:00
Paul Smith
7c202b50fa * tetss/run_make_test.pl: Avoid 'sh -c' for Windows portability. 2019-09-07 18:27:26 -04:00
Paul Smith
0a6c38eff8 * tests/scripts/functions/wildcard: Skip dangling symlink test.
The built-in glob implementation does not correctly handle dangling
symlinks.  This needs to be fixed by switching to the latest glob
implementation from gnulib but that's a big job: for now avoid the
test if we know it will fail.
2019-09-07 18:27:26 -04:00
Paul Smith
31394f7f53 * src/dir.c (dir_setup_glob): Initialize unused gl_offs.
* tests/scripts/functions/wildcard: Add trailing slash tests.
Initial changes by Dmitry Goncharov <dgoncharov@users.sf.net>
2019-09-07 18:27:26 -04:00
Paul Eggert
8bffc8d53c Port grouped_targets test to Solaris 10
* tests/scripts/features/grouped_targets: Use ‘printf ''’
instead of ‘echo -n’, as POSIX says the latter is not portable.
2019-09-02 11:11:26 -04:00
Paul Smith
7e60ffe83e * src/read.c (parse_file_seq): [SV 52076] Don't reverse glob() results. 2019-09-02 11:11:26 -04:00
Paul Smith
2e388a18a1 * tests/scripts/features/archives: [SV 54395] Support non-GNU ar. 2019-08-26 07:54:09 -04:00
Paul Smith
39bf50b2da * tests/scripts/misc/general3: Add more tests for SHELL/.SHELLFLAGS 2019-08-26 07:54:09 -04:00
Mike Haboustak
ee167c650e [SV 28456] Don't override $< when no default rule has been defined
The check for matching a file's command to the default rule's command
does not account for null. If no .DEFAULT is defined a rule with no
recipe has it's $< variable set to the value of $@. This breaks second
expansion, particularly when used with pattern rules.

* src/commands.c [set_file_variables]: Check that cmds is set
* tests/scripts/features/se_explicit: Test case
* tests/scripts/features/se_implicit: Test case

Copyright-paperwork-exempt: yes
2019-07-13 11:47:26 -04:00
Paul Smith
4ed31830cb * doc/make.texi: [SV 54116] Document whitespace removal trick.
Discovered and explained by Michael Henry <gnu@drmikehenry.com>
* tests/scripts/variables/flavors: Add a test to preserve the behavior.
2019-05-19 19:25:50 -04:00
Paul Smith
d7ff21ecd7 [SV 46013] Allow recursive variable overrides from Makefiles
Ensure that variable overrides are passed to recursive make instances
even if no overrides were provided on the command line.
Fix suggested by Rici Lake <ricilake@gmail.com>

* src/main.c (define_makeflags): Add overrides without respect to the
value of command_variables.
* tests/scripts/features/recursion: Add a test.
2019-05-19 19:25:50 -04:00
Paul Smith
f32ca1666f [SV 54549] Don't free used set_lists during merge
When merging the variable_set_lists for two targets it could be
that the "from" set list is a subset of the "to" set list: check
for this situation to avoid freeing used memory.

* src/variable.c (merge_variable_set_lists): Walk the "to" list and
if the "from" list is contained in it, nothing to do.
* tests/scripts/features/se_explicit: Add a test.
2019-05-19 15:27:26 -04:00
Paul Smith
9ce370249b * src/hash.c (jash_string): [SV 54980] Avoid ASAN error 2019-05-19 15:27:26 -04:00
Paul Smith
b5de783f77 [SV 54740] Ensure .SILENT settings do not leak into sub-makes
Create a new variable run_silent to hold the current instance's global
silence setting, allowing silent_flag to represent only whether the -s
option was provided on the command line.

* src/makeint.h: Change silent_flag variable to run_silent.
* src/job.c: Ditto.
* src/remake.c: Ditto.
* src/file.c: Ditto.
* src/main.c: Add a new global variable run_silent.
(decode_switches): After switches are decoded, initialize run_silent.
* tests/scripts/targets/SILENT: Add a test for recursive behavior.
2019-05-19 15:27:26 -04:00
Paul Smith
389dcb608f Update copyright statements for 2019 2019-05-19 15:27:26 -04:00
Kaz Kylheku
8c888d95f6 [SV 8297] Implement "grouped targets" for explicit rules.
This patch allows "grouped targets" using the &: syntax:

  tgt1 tgt2 ... tgtn &: pre1 pre2 ...
        recipe

When the &: separator is used (in single or double colon forms), all
the targets are understood to be built by a single invocation of the
recipe.  This is accomplished by piggy-backing on the already-existing
pattern rule feature, using the file's "also_make" list.

* NEWS: Add information about grouped targets.
* doc/make.texi (Multiple Targets): Add information on grouped targets.
(Pattern Intro): Refer to the new section to discuss multiple patterns.
* src/main.c (main): Add "grouped-targets" to .FEATURES
* src/read.c (make_word_type): Add new types for &: and &::.
(eval): Recognize the &: and &:: separator and remember when used.
(record_files): Accept an indicator of whether the rule is grouped.
If so, update also_make for each file to depend on the other files.
(get_next_mword): Recognize the &: and &:: word types.
* tests/scripts/features/grouped_targets: New test script.
* AUTHORS: Add Kaz Kylheku
2019-05-12 16:29:20 -04:00
Paul Smith
d603b2e6ac * src/main.c (main): Set jobserver permissions before re-execing
Fixes an issue seen in the Linux kernel build system, reported by
Masahiro Yamada <yamada.masahiro@socionext.com>.  Fix suggested
on the bug-make mailing list by Mike Shal <marfey@gmail.com>.
* tests/scripts/features/parallelism: Add a test to verify this.
2018-09-15 15:08:47 -04:00
Paul Smith
67e6d81256 [SV 40657] Don't create pattern rules for suffix rules with deps.
* NEWS: Update with a backward-compatibility warning.
* src/rule.c (convert_to_pattern): If a suffix rule has dependencies,
do not create a pattern rule for it.  According to the manual suffix
rules with prerequisites are treated as normal targets.
* tests/scrips/features/suffixrules: Create some regression tests for
.SUFFIXES and suffix rules.
2018-09-15 15:08:29 -04:00
Paul Smith
05769ca009 [SV 54233] Preserve higher command_state values on also_make targets.
If multiple pattern rules have the same pattern as also-make targets
and we attempt to run them at the same time, we might downgrade the
command state from 'running' to 'deps_running'; this will prevent
that also_make from being considered complete causing make to wait
forever for it to finish.

Ensure that set_command_state never downgrades the state of a target.

* src/file.c (set_command_state): Don't downgrade command_state.
* src/filedef.h (struct file): Document the order prerequisite.
* test/scripts/features/patternrules: Test the behavior.
2018-08-04 19:07:59 -04:00
Paul Smith
f9ba22e029 * tests/scripts/functions/wildcard: [SV 52018] Test dangling symlink. 2018-08-04 17:35:10 -04:00
Paul Smith
a9975756d0 * tests/scripts/features/archives: [SV 54395] Test long archive names. 2018-08-04 17:02:25 -04:00
Paul Smith
9ff4d6af92 * lib/glob.c (glob_in_dir): [SV 53465] Allow symlinks to directories.
Fix from Rich Felker <bugdal@aerifal.cx> on the musl mailing list.
* tests/scripts/functions/wildcard: Create a regression test for this.
2018-08-04 14:26:10 -04:00