Commit graph

219 commits

Author SHA1 Message Date
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