Commit graph

272 commits

Author SHA1 Message Date
rillig
4b6f71331d regress/buildlink-transform: clean up code 2020-05-09 22:42:37 +00:00
rillig
1160a208a2 regress/buildlink-transform: repair most of the regression test
This test is for the old compiler wrapper.
Using it with the cwrappers from 2014 makes several test cases fail.
2020-05-09 22:39:53 +00:00
rillig
93a22f4c24 regress/replace-interpreter: fix package installation 2020-05-09 22:13:30 +00:00
rillig
eb5c389de5 regress/make-shell: add missing variable for the shell test 2020-05-09 21:50:49 +00:00
rillig
3f5ee343d1 regress/ignore-tools: remove
This regression test has been broken for a long time now.  It tested the
_TOOLS_OPSYS_INCOMPAT variable, which does not exist anymore.
2020-05-09 21:48:59 +00:00
rillig
825bbe2a20 regress/replace-interpreter: ensure order of targets 2020-05-09 18:25:28 +00:00
rillig
e21ea1b833 regress/infra-unittests: parse command line options [-kv] [-f filter] 2020-05-09 17:41:08 +00:00
rillig
a864fd9c2e regress/infra-unittests: indent here-documents 2020-05-09 17:10:38 +00:00
rillig
e4719c2d8a mk/subst.mk: allow identity substitutions with escaped dots
This fixes the build of converters/help2man in SUBST_NOOP_OK=no mode.
2020-05-06 06:14:56 +00:00
rillig
a669b77182 regress/infra-unittests: add tests for portability checks
Files like Makefile.am and configure.ac are usually not used during a
build, therefore there's no point in checking these for shell portability
issues.
2020-05-05 06:11:29 +00:00
rillig
78ff56665f mk/check/check-portability: opt-in for newer portability checks
There are a few portability checks that have been existing for years.
Later additions need an opt-in phase to avoid breaking existing usages.

https://mail-index.netbsd.org/tech-pkg/2020/05/04/msg023084.html
2020-05-05 05:55:25 +00:00
rillig
80ac4ecc53 mk/check/check-portability: fix error message when no patches are found 2020-05-04 21:48:18 +00:00
rillig
4b2126055f mk/check/check-portability: skip X.in if X is patched
A commonly occuring scenario is that a package patches the configure
script, but that the corresponding configure.in contains shell code that
is not portable.  In cases like these, configure.in is typically not used
during the build, therefore there is no need to check it for portability.

This also applies to all other combinations where a file is patched and
the corresponding file.in contains unportable shell code.
2020-05-04 21:32:48 +00:00
rillig
ca48570fea regress/check-portability: fix regression test for added line numbers
The line numbers were added to the output in check-portability.awk r1.12.
2020-05-04 20:29:26 +00:00
rillig
ff016ffa31 mk/help: do not treat continuation lines as textual comments 2020-05-03 09:51:07 +00:00
rillig
4e2bff9c98 mk/help: only list help topics that have associated keywords 2020-05-03 08:49:16 +00:00
rillig
16f52645ce regress/infra-unittests: demonstrate wrong help topics without keywords 2020-05-03 08:42:22 +00:00
rillig
4bdd3e5255 regress/tools-platform: document which shell pkgsrc uses 2020-05-03 07:38:50 +00:00
rillig
8a67ee54d2 regress/tools: reduce the number of backslashes in the code 2020-05-02 08:07:28 +00:00
rillig
d161c9cb8c regress/tools: adjust COMMENT 2020-05-02 08:03:17 +00:00
rillig
0ce31b3a1e regress: move tests for platform tools to tools-platform 2020-05-02 07:24:31 +00:00
rillig
f7a84dcc8b regress/infra-unittests: add more tests for subst.mk
Having quotes around the sed commands does not change their meaning.
These quotes must not lead to syntax errors when parsing the shell
command.  This happened in mk/subst.mk r1.91 because the double quote was
accidentally escaped.
2020-05-02 06:48:59 +00:00
rillig
ad23776a43 mk/subst.mk: fix shell parse error for special sed expressions
The escaping inside the backticks had been wrong.  Because of this,
parentheses and semicolons were interpreted as shell syntax.

Switching to $(...) command substitution removes the need for quoting
some of the characters and makes the whole command simpler to understand.
Doing the escaping for the backticks command properly would have involved
lots of special cases.

The $(...) command substitution was used sparingly in pkgsrc up to now
because some older or broken shells do not support it.  Since these
shells do not end up as the shell that runs the commands from Makefiles,
that's not a problem.
2020-05-02 05:52:09 +00:00
rillig
b51e961dae mk/subst.mk: fix typo in diagnostic 2020-05-01 19:53:48 +00:00
rillig
e1805813ab regress/make-shell: reuse the shell tests from the platform tests 2020-05-01 19:40:27 +00:00
rillig
0011322d94 regress/make-shell: add another test case for broken Solaris /bin/sh 2020-05-01 19:28:15 +00:00
rillig
5f77889349 regress/make-shell: regression test for the shell used by devel/bmake 2020-05-01 19:16:47 +00:00
rillig
063bbedf6b regress: add tools-platform/ for testing the platform tools
Right now, the tests in regress/tools are a mixture of testing the pkgsrc
infrastructure in mk/tools and the tools provided by the platforms.
These don't go well together, therefore the tests for the platform tools
will be migrated here.
2020-05-01 18:37:59 +00:00
rillig
b3df1a4978 regress/infra-unittests: fix syntax error in test.subr
ShellCheck complained about a parse error in the empty functions, which
agrees with the shell grammar given in IEEE 1003.1, both the 2004 Edition
and the 2018 Edition.
2020-05-01 14:14:12 +00:00
rillig
d834a09e98 mk/subst.mk: switch command substitution back to backticks
To work properly, the $(...) should have been $$(...).

In pkgsrc the command substitution is usually done via `backticks`, for
compatibility with /bin/sh from Solaris.  To fix the shell parse errors,
the special characters are properly escaped inside the command
substitution.
2020-05-01 06:42:32 +00:00
rillig
ac62ef6aaf mk/subst.mk: fix combination of SUBST_FILTER_CMD with SUBST_NOOP_OK=no
Since SUBST_FILTER_CMD is a shell command, it may contain arbitrary
characters.  The condition in mk/subst.mk that tested whether
SUBST_FILTER_CMD was the default filter command was evaluated at run
time.  In such an evaluation, the variables (lhs and rhs) are fully
expanded before parsing the condition.  This means that these variables
must not contain quotes or unquoted condition operators.

Exactly this situation came up in one of the regression tests.  The
quoted "0-9" was copied verbatimly into the condition, including the
quotes.  The resulting condition was:

	"tr -d "0-9"" == "LC_ALL=C /usr/bin/sed "

This produced a syntax error because of the left-hand side. Adding a :Q
modifier would have helped for the left-hand side, but this would have
been necessary for the right-hand side as well.  Since an empty SUBST_SED
is defined not to "contain only identity substitutions", the first
condition can simply be removed.

The whole condition in the shell program had not worked anyway since it
expanded to either "[ true ]" or to "[ false ]", and both of these
commands exited successfully.
2020-04-29 22:46:42 +00:00
rillig
4bafb8759a mk/subst.mk: allow identity substitutions in SUBST_NOOP_OK=no mode
There are several cases where patterns like s|man|${PKGMANDIR}| appear in
SUBST_SED.  Up to now, these had been categorized as no-ops and required
extra code to make the package build when SUBST_NOOP_OK was set to "no".

This was against the original intention of SUBST_NOOP_OK, which was to
find outdated substitution patterns that do not occur in SUBST_FILES
anymore, most often because the packages have been updated since.

The identity substitutions do appear in the files, they just don't change
them.  Typical cases are for PKGMANDIR, DEVOSSAUDIO, PREFIX, and these
variables may well be different in another pkgsrc setup.  These patterns
are therefore excluded from the SUBST_NOOP_OK check.
2020-04-29 18:33:56 +00:00
rillig
19dc5714ff regress/make-quoting: demonstrate that the ancient bugs have been fixed 2020-04-26 13:11:17 +00:00
rillig
a79a16c5ea regress/make-quoting: replace obsolete _PKG_SILENT with RUN 2020-04-26 12:59:28 +00:00
rillig
1a4cff42cf regress/infra-unittests: bring files into normal form 2020-04-26 12:46:33 +00:00
rillig
2efb021f39 regress/infra-unittests: add tests for patch(1) 2020-04-26 12:46:01 +00:00
rillig
6f096dea69 regress/infra-unittests: add test for subst.mk with unreadable file 2020-04-26 12:21:39 +00:00
rillig
5a278be828 mk/subst.mk: warn about all noop patterns before erroring out 2020-04-23 19:30:29 +00:00
rillig
aef7a2d723 mk/subst.mk: omit ./ for sanely named files, quote filename patterns 2020-04-23 19:16:49 +00:00
rillig
e5c5b9dd0c regress/infra-unittests: ensure that subst.mk preserves the x bit 2020-04-23 18:52:55 +00:00
rillig
bc31ec4ea6 regress/infra-unittests: add more tests for subst.mk 2020-04-23 18:30:37 +00:00
rillig
058d3e5132 mk/subst.mk: document that SUBST_VARS does not support dollar 2020-04-18 15:04:34 +00:00
rillig
434300ee2a regress/infra-unittests: remove accidental file copying 2020-04-18 14:06:06 +00:00
rillig
2bacc5cd9b mk/subst.mk: make error message for filename pattern easier readable 2020-04-18 12:59:42 +00:00
rillig
2a5426f9ce mk/subst.mk: avoid undefined behavior in regular expressions
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html
says in section 9.3.2 BRE Ordinary Characters that only very few
characters may be preceded with a backslash.

As a side effect, this change allows parentheses in the variable names
listed in SUBST_VARS (even if that will never happen in practice).

The reason that the regression test had not replaced VAR.[] before was
simply that this variable had not been listed in SUBST_VARS.
2020-04-18 12:21:10 +00:00
rillig
c7a475a5e0 regress/infra-unittests: add example tests for mk/help/help.awk
There are many more scenarios that need test cases, but this is a start.
2020-03-30 06:40:53 +00:00
rillig
5ae9338639 regress/infra-unittests: add test for SUBST_FILES without effect 2020-03-28 12:08:28 +00:00
rillig
b17ebc4cec regress/infra-unittests: rewrite documentation, adjust code a little
The documentation now starts with a high-level introduction instead of
listing only the details.

The name of the function test_file had to be changed since the old name
was not expressive enough. Same for the variable real_pkgsrcdir.
2020-03-27 22:56:29 +00:00
rillig
f2cbf3686f regress/infra-unittests: add more tests for mk/extract/extract
These tests demonstrate that it is not easy to exclude only one top-level
directory from being extracted, using the example of lang/gcc*, which has
a top-level directory contrib/ that contains shell programs with
non-portable code, but the same archive also contains libjava/contrib, and
that should still be extracted.
2020-03-27 21:41:33 +00:00
rillig
83a0097b05 regress/infra-unittests: add test for not extracting certain files 2020-03-25 07:47:10 +00:00
rillig
b885ff75ea mk/subst.mk: ignore directories in SUBST_FILES
Seen in multimedia/libmp4v2, where a pattern also matches the CVS
directory from the distfiles.
2020-03-22 13:19:50 +00:00
rillig
4d12683e99 mk/subst.mk: use the same severity for all messages
The severity now depends only on the setting of SUBST_NOOP_OK. Right now
this means that some former warnings will be reported as info only, but
that will change after switching the default of SUBST_NOOP_OK after
2020Q1. Then they will all be reported as warnings, followed by the final
error saying that the pattern has no effect.

This change makes it easier to detect inconsistencies and outdated
definitions, for example by setting the global SUBST_NOOP_OK=no and
redefining WARNING_MSG to actuall fail.
2020-03-22 12:15:59 +00:00
rillig
e9be1468cd regress: migrate SUBST test to the other SUBST tests
In the old test code, the input and output data for each test case were
in different files. This was too far apart to relate them. In addition,
all test cases were merged into a single big test, which made it hard to
tell the topics apart.
2020-03-21 18:43:02 +00:00
rillig
8e82112864 mk/subst.mk: add global SUBST_SHOW_DIFF variable
This is useful in bulk builds or when trying to understand what happens
under the hood, since the SUBST code leaves no .orig files around.
2020-03-21 13:30:35 +00:00
rillig
f5ff99ee4e regress/infra-unittests: add more tests for subst.mk 2020-03-21 12:47:13 +00:00
rillig
68730ad3f1 mk/subst.mk: fix bmake warnings in case of duplicate SUBST classes 2020-03-21 12:22:31 +00:00
rillig
968d84b496 regress/infra-unittests: fix assertion --file-is-lines
It had compared the actual output with itself, instead of comparing it to
the expected output.
2020-03-21 06:53:18 +00:00
rillig
5fb2a28139 regress/infra-unittests: add tests for special characters in subst.mk 2020-03-20 21:27:04 +00:00
rillig
caf5567d50 show-all: fix output for list variables containing dollar characters
Before, variables containing dollar characters displayed so wrong that it
was hard to explain.

To fix the problem, I typed almost random characters into the code until
the output was exactly as expected. I still do not understand:

* why the list variables need 8 dollars to survive the @x@ loop,
* why the code only works if the dollars come from an external variable
  instead of being written inline,
* why the backslash in the :C modifier needs to be doubled.

Anyway, the output of "bmake show-all-extract" now contains the shell
variable $${extract_file}, just as it should. The dollars are now doubled
in the output and thereby match the source code from the Makefile
exactly.
2020-03-20 16:39:03 +00:00
rillig
2f3031cc27 regress/show-all: demonstrate wrong output of show-all
A real-life example of this pattern is EXTRACT_CMD_DEFAULT, which refers
to DOWNLOADED_DISTFILE, which is defined as "$${extract_file}".

Until mk/extract/extract.mk r1.40, that argument was discarded from the
output completely. With the surrounding quotes at least the quotes are
visible in the output of "bmake show-all-extract".
2020-03-20 15:45:12 +00:00
rillig
d1f0656e94 mk/subst.mk: evaluate SUBST_MESSAGE only once, and late
The default value of SUBST_MESSAGE is based on SUBST_FILES, and that
variable may use the :sh modifier to list files from WRKSRC, which may
not exist at load time.
2020-03-20 09:00:44 +00:00
rillig
5f9f5de3b2 regress/infra-unittests: restructure test infrastructure
Before, the first assertion failure quit immediately. This prevented
getting a complete picture of the situation that failed. Now the
assertions continue the test and fail at the very end.
2020-03-20 08:56:42 +00:00
rillig
59545c5e44 mk/subst.mk: fix early evaluation of SUBST_FILES
In the case of pkglocaledir, the SUBST_FILES are generated by a shell
command. That command assumes that the WRKDIR already exists. Therefore
SUBST_FILES must be evaluated as late as possible.

See mk/configure/replace-localedir.mk; an example package that fails is
devel/gettext-tools.
2020-03-20 06:17:48 +00:00
rillig
9f551a7b5a regress/infra-unittests: add more tests for subst.mk failures 2020-03-19 22:46:34 +00:00
rillig
7c75c44ec7 regress/pkg-options: remove obsolete _PKG_SILENT 2020-03-19 19:56:47 +00:00
rillig
9ca0fcba18 regress/infra-unittests: add tests for mk/subst.mk 2020-03-19 16:58:35 +00:00
rillig
538c9b877c mk/pkginstall/files: allow spaces in configuration file names
Fixes PR pkg/42191.
2020-02-11 01:59:30 +00:00
rillig
3d253ab785 mk/bsd.pkg.mk: support spaces in PATH directories
Fixes PR pkg/53959.
2020-02-09 22:39:20 +00:00
rillig
93997228c5 regress/path: demonstrate wrong handling of PATH directories with spaces
See PR pkg/53959.
2020-02-09 22:28:58 +00:00
rillig
7f191db6be mk/pkgformat: include only relevant ident strings in +BUILD_VERSION
Before, not only files containing an RCS Id were recorded in the
+BUILD_VERSION file but also files containing text that looked similar to
an RCS Id were recorded, even though these didn't contain any valuable
version information.

The effect was that before this change, pkgtools/pkglint was built over
and over again by the bulk builds since pbulk uses a different regular
expression for detecting modified files.

The regular expression for unexpanded RCS Ids is added to record files
that have never been checked in to CVS, just to have them recorded and to
distinguish them from the final committed version.

See https://mail-index.netbsd.org/tech-pkg/2020/01/11/msg022489.html.
2020-01-15 20:11:11 +00:00
rillig
8b2c7d624a mk/pkgformat: include only relevant ident strings in +BUILD_VERSION
Before, not only files containing an RCS Id were recorded in the
+BUILD_VERSION file but also files containing text that looked similar to
an RCS Id were recorded, even though these didn't contain any valuable
version information.

The effect was that before this change, pkgtools/pkglint was built over
and over again by the bulk builds since pbulk uses a different regular
expression for detecting modified files.

The regular expression for unexpanded RCS Ids is added to record files
that have never been checked in to CVS, just to have them recorded and to
distinguish them from the final committed version.

See https://mail-index.netbsd.org/tech-pkg/2020/01/11/msg022489.html.
2020-01-15 20:03:10 +00:00
rillig
9e5c981f22 regress/plus_build_version: fix test 2020-01-15 19:37:24 +00:00
rillig
20ce8f0b79 regress/plus_build_version: document obvious uses of RCS Ids 2020-01-11 13:04:21 +00:00
rillig
bcedb05abc regress/plus_build_version: adjust the expanded RCS Ids
These values could not be guessed before the previous commit.
2020-01-11 12:26:37 +00:00
rillig
155c26548f regress/plus_build_version: RCS Id extraction for +BUILD_VERSION
In pkgtools/pkglint, there are several lines that look almost like RCS
Ids. Some parts of the pkgsrc infrastructure expand them and some others
don't. This needs to be fixed so that all parts of pkgsrc agree what is a
complete RCS Id and what isn't.

As long as that is not the case, pbulk unnecessarily builds pkglint over
and over again, even if nothing changed. There are probably other
unintended side effects as well that just haven't been discovered or
considered grave enough.
2020-01-11 12:24:32 +00:00
rillig
7fb2cc5c7b regress: remove Makefile
The regress/ directory does not contain pkgsrc packages, therefore it
should not be listed as a SUBDIR in the top-level Makefile.

This wrong impression could be caused because most of the regression
tests have a Makefile that looks like an actual package Makefile. But
this alone doesn't mean that these are packages. The only relevant file
for a regression test is the spec file. If that test uses a package
Makefile or not is an implementation detail of each test.
2020-01-11 11:09:35 +00:00
rillig
f2a99a9dbc regress/make-env-phases: fix test by ignoring changes to *FLAGS
The CPPFLAGS, CFLAGS, CXXFLAGS and LDFLAGS differ between the build phase
and the install phase. It's only a minor difference but may still
influence packages that use these flags at install time, even though they
shouldn't.

For now just document that the flags differ.
2019-12-17 16:01:28 +00:00
wiz
86a6754eff regress/Makefile: add reasons for commenting out entries 2019-12-12 04:35:21 +00:00
wiz
4222b21e25 regress: comment out two directories without Makefiles 2019-12-08 10:22:09 +00:00
rillig
9a544993f5 regress/check-perms: add test for broken CHECK_PERMS_AUTOFIX
The variable CHECK_PERMS_AUTOFIX has been existing since 2006 but is not
used in any package. This may be because it is not helpful in any way.
When a package sets this variables to yes, the permission errors are not
silently fixed, but the build still fails instead. This behavior is not
useful in any way and thus needs to be fixed.

See https://mail-index.netbsd.org/tech-pkg/2019/08/thread1.html#021828
2019-09-19 23:53:36 +00:00
rillig
7c3ef3e6ea lang/python: fix PYVERSSUFFIX escaping for print-PLIST
Before, the filename "3270" was wrongly replaced with "${PYVERSSUFFIX}"
since the version number "3.7", when interpreted as a regular expression,
matched that filename.
2019-07-17 18:34:16 +00:00
rillig
106ef90f5c regress/print-plist: fix syntax error after almost 15 years
The race for the oldest undiscovered pkgsrc bug still goes on. 15 years
is hard to beat, but definitely possible.
2019-07-17 17:56:22 +00:00
rillig
122d791da2 mk/tools: in the wrapper log, quote arguments containing = naturally 2019-05-22 20:47:05 +00:00
rillig
51148ded41 regress: add gnu-configure-strict to SUBDIRS 2019-05-04 15:17:39 +00:00
rillig
bc4f604de5 mk/configure: assist in finding unrecognized configure options
Instead of giving instructions, just to the work automatically as far as
it can be automated.
2019-05-04 15:16:50 +00:00
rillig
5b57509b90 regress/buildlink-libtool: fix failing test
The comment above that test was a copy-and-paste error. It got almost 15
years old.
2019-03-24 21:09:21 +00:00
rillig
4bfb903a41 regress/pkg-options: fix regression test for PKG_OPTIONS framework
Just a few changes in the wording, which have been introduced in 2007.
2019-03-24 20:57:59 +00:00
rillig
81a41d0b94 mk/tools: correctly quote arguments in the tool wrapper log
Before, the tool arguments were written to the log as plain strings. Now
the arguments are properly quoted, which makes it possible to replay the
commands by copying them from the .work.log file.

This only affects tools that are shell builtins (echo, true, false), get
additional arguments (mkdir -p) or define a custom TOOLS_SCRIPT
(pkg-config, to set an environment variable; or autotools). Tools that
are symlinked to the real tool are not affected.

The calls to the compiler are already properly logged since cwrappers
takes care of that. This commit therefore makes the log entries for the
compilers and the other tools more similar.
2019-03-24 11:29:19 +00:00
rillig
575f219e37 mk/tools: fix quoting when logging tool invocations
When a package or the infrastructure defined a tool with custom
TOOLS_ARGS or TOOLS_SCRIPT containing special characters, these could
lead to unintuitive interactions at the time when that tool invocation
was logged in the tool wrapper log. Some of the logging output ended up
on stdout, while some of the normal output ended up in the log, and parts
of the quoted arguments were even evaluated as shell commands.

The logging of the wrapped tool commands is not perfect yet, but at least
it's much more predictable now.
2019-03-24 08:40:07 +00:00
rillig
492beb29f5 regress/tools: show that TOOLS_SCRIPT is not always logged properly 2019-03-23 22:59:11 +00:00
rillig
70fd82fc7e regress/tools: demonstrate wrong shell quoting in the tools wrapper 2019-03-22 22:41:06 +00:00
rillig
23128f791d mk/tools: fix unintended filename expansion in the tool wrapper log file 2019-03-22 22:13:21 +00:00
rillig
32d0165e0f regress/tools: demonstrate wrong quoting in tools wrapper logging 2019-03-22 20:56:16 +00:00
rillig
40cf71365f regress/infra-unittests: add small framework for testing mk/ with mocks 2019-03-21 21:45:30 +00:00
rillig
ffb8542f3f regress/compiler: fix regression test 2019-03-17 12:20:09 +00:00
rillig
85d27b43fd mk/subst.mk: substitute embedded newlines, escape dots in variable names 2019-03-17 12:01:14 +00:00
rillig
ecd80128b4 regress/subst: demonstrate that SUBST_VARS doesn't pass newlines
Sure, it's an edge case and has not been necessary until now.
Nevertheless it's good to see how this can be done.

Variables having dots in their names are also not handled completely
correct. This also didn't occur in practice since the variable names
passed to SUBST_VARS are usually A-Za-z0-9_ only.
2019-03-17 11:28:13 +00:00
rillig
63399e8e1a regress/subst: enable regression test 2019-03-17 10:19:36 +00:00
rillig
9e31554ec7 regress/tools: clarify that only the NetBSD 7 shell exhibits this bug
The test has been changed again to fail since making the test pass would
mean this bug could later silently show up inside a large GNU configure
script where it would be impossible to find. Therefore, when using pkgsrc
on NetBSD 7, it is better to switch to another shell for doing pkgsrc
work.

The comment has been updated to be more accurate.
2018-12-05 19:01:40 +00:00
rillig
37529136f3 regress/tools: disable failing test on NetBSD
See bin/53754.
2018-11-30 19:55:26 +00:00