In https://github.com/geany/geany/pull/4013 I forgot to add a unit test for meson.
However, when I tried to add it now (naming the test file `meson.build`), I got the following in `meson.build.log`: ``` Unknown filetype extension for "/tmp/tmp.XJrc9S8Suo/test.build.tags". ```
The reason is that unlike other filetypes, the Meson configuration in `filetype_extensions.conf` doesn't start with `*.` but instead the whole filename is used: ``` Meson=meson.build;meson.options;meson_options.txt; ```
The unit test runner creates test files starting with `test`, followed by the filetype extension and this doesn't match what's in `filetype_extensions.conf`.
What should we do about it?
A simple (but ugly) way would be to add some `*.meson_unittest` extension to `filetype_extensions.conf` which we would use for the unit test but which wouldn't be used in real life.
Not less ugly but more temporary: can we maybe extend the pattern list in the `filetype_extensions.conf` used for the unittests on the fly? I.e. using `sed` or so to only add a special unittest pattern during execution of the test suite. This way it would not be in the repository and not in releases.
On the other hand, this adds another piece of hidden magic.
can we maybe extend the pattern list in the filetype_extensions.conf used for the unittests on the fly?
We'd have to update `filetype_extensions.conf`, run unit tests, and then revert back to the original `filetype_extensions.conf`. If someone interrupts the unit test by Ctrl+C, the original version wouldn't be restored which makes this approach a little fragile.
Not less ugly but more temporary:
There's always the option of a very elegant and permanent solution - not to have a unit test for meson at all :-)
can we maybe extend the pattern list in the filetype_extensions.conf used for the unittests on the fly?
We'd have to update `filetype_extensions.conf`, run unit tests, and then revert back to the original `filetype_extensions.conf`. If someone interrupts the unit test by Ctrl+C, the original version wouldn't be restored which makes this approach a little fragile.
True that. All other ideas coming to my mind are even more fragile or hacky or too complicated or all.
Not less ugly but more temporary:
There's always the option of a very elegant and permanent solution - not to have a unit test for meson at all :-)
:) In the end, it might be a viable option when comparing costs and benefits.
can we maybe extend the pattern list in the filetype_extensions.conf used for the unittests on the fly?
We'd have to update `filetype_extensions.conf`, run unit tests, and then revert back to the original `filetype_extensions.conf`. If someone interrupts the unit test by Ctrl+C, the original version wouldn't be restored which makes this approach a little fragile.
No, the filetype_extension.conf used in the unittests is already a copy in a custom directory -- the goal being installing a "vanilla" confdir, and IIRC back in the days the layout of the source *data/* directory wasn't fitting.
Anyway, it's a mere matter of doing something like this: ```diff diff --git a/tests/ctags/runner.sh b/tests/ctags/runner.sh index e03beda09..775654006 100755 --- a/tests/ctags/runner.sh +++ b/tests/ctags/runner.sh @@ -14,7 +14,10 @@ trap 'rm -rf "$TMPDIR"' EXIT # related configuration files mkdir -p "$CONFDIR" || exit 99 mkdir -p "$CONFDIR/filedefs/" || exit 99 -cp "${top_srcdir:-../..}"/data/filetype_extensions.conf "$CONFDIR" || exit 99 +# Add *.Filetype_unittest extension so we can match filetypes for which there +# are no extension patterns, like e.g. Meson. +sed 's/^([^=[]{1,})(=[^;]{1,}(;[^;]{1,})*);*$/\1\2;*.\1_unittest;/' \ + < "${top_srcdir:-../..}"/data/filetype_extensions.conf > "$CONFDIR/filetype_extensions.conf" || exit 99 cp "${top_srcdir:-../..}"/data/filedefs/filetypes.* "$CONFDIR/filedefs/" || exit 99
shift ```
It's indeed not very pretty, but it would do the job with relatively little effort, and no impact on "real" config. Yes it add one layer of magic, but aren't shell script here for this? 😁
I can prepare a PR if you're happy enough with this.
PS: yes, I know about `sed -r` and `+` quantifier, but IIRC macos's sed doesn't, so I tried to be portable. Testing on oddball tollting welcome.
No, the filetype_extension.conf used in the unittests is already a copy in a custom directory
Thanks for clarifying this, I didn't know that.
Anyway, it's a mere matter of `+sed 's/^([^=[]{1,})(=[^;]{1,}(;[^;]{1,})*);*$/\1\2;*.\1_unittest;/' ` `+ < "${top_srcdir:-../..}"/data/filetype_extensions.conf > "$CONFDIR/filetype_extensions.conf" || exit 99`
:-)
I can prepare a PR if you're happy enough with this.
I didn't even try to understand the sed, I believe your "mere matter" implementation :-). Please go ahead with the PR.
github-comments@lists.geany.org