Commit Graph

11 Commits

Author SHA1 Message Date
Eli Schwartz 2acb6ee79e
unittests: allow test commands to suppress returning stderr
Add better logging of commands by printing stdout and stderr separately,
if relevant. Also while we are at it, print the actual command being
run.
2022-06-13 17:17:53 -04:00
Nirbheek Chauhan 2512c25c0b ninja backend: Fix usage of same constants file for native and cross
For example:
```
meson builddir \
        --native-file vs2019-paths.txt \
        --native-file vs2019-win-x64.txt \
        --cross-file vs2019-paths.txt \
        --cross-file vs2019-win-arm64.txt
```
This was causing the error:

> ERROR: Multiple producers for Ninja target "/path/to/vs2019-paths.txt". Please rename your targets.

Fix it by using a set() when generating the list of regen files, and
add a test for it too.
2022-01-30 02:13:42 +05:30
Nirbheek Chauhan faf79f4539 Add a test for the --vsenv meson setup option
The tests and the unittests both unconditionally call setup_vsenv()
because all tests are run using the backend commands directly: ninja,
msbuild, etc.

There's no way to undo this vs env setup, so the only way to test that
--vsenv works is by:

1. Removing all paths in PATH that provide ninja
2. Changing setup_vsenv(force=True) to forcibly set-up a new vsenv
   when MESON_FORCE_VSENV_FOR_UNITTEST is set
3. Mock-patching build_command, test_command, install_command to use
   `meson` instead of `ninja`
4. Asserting that 'Activating VS' is in the output for all commands
5. Ensure that compilation works because ninja is picked up from the
   vs env.

I manually checked that this test actually does fail when the previous
commit is reverted.
2022-01-16 23:42:19 +05:30
Eli Schwartz 751f84405e
pyupgrade --py37-plus 2022-01-10 18:36:56 -05:00
Nirbheek Chauhan 04ae1cfb79 Fix cygwin test failure due to shortpath usage
Two tests are failing on Cygwin because the argument is passed as
a long-path and the Path is ending up as a short-path:

AllPlatformTests.test_run_target_files_path

  Traceback (most recent call last):
    File "/cygdrive/d/a/meson/meson/test cases/common/51 run target/check-env.py", line 22, in <module>
      assert build_root == env_build_root
  AssertionError

SubprojectsCommandTests.test_purge

  >       self.assertEqual(deleting(out), sorted([
              str(self.subprojects_dir / 'redirect.wrap'),
              str(self.subprojects_dir / 'sub_file'),
              str(self.subprojects_dir / 'sub_git'),
          ]))
  E       AssertionError: Lists differ: ['/cygdrive/c/Users/runneradmin/AppData/Local/Temp/tmpeaa2a49[205 chars]git'] != ['/cygdrive/c/Users/RUNNER~1/AppData/Local/Temp/tmpeaa2a49z/s[196 chars]git']

  [...]

  ['/cygdrive/c/Users/runneradmin/AppData/Local/Temp/tmpeaa2a49z/src/subprojects/redirect.wrap',
                      ^^^^^^^^^^^
  ['/cygdrive/c/Users/RUNNER~1/AppData/Local/Temp/tmpeaa2a49z/src/subprojects/redirect.wrap',
                      ^^^^^^^^

The fix is to not use the tempdir for all tests, but only for tests
that check the mode.
2021-10-31 19:22:36 +05:30
Dylan Baker 30202a2402 compilers/rust: Add support for clippy
Clippy is a compiler wrapper for rust that provides an extra layer of
linting. It's quite popular, but unfortunately doesn't provide the
output of the compiler that it's wrapping in it's output, so we don't
detect that clippy is rustc. This small patch adds a new compiler class
(that is the Rustc class with a different id) and the necessary logic to
detect that clippy is in fact rustc)

Fixes: #8767
2021-09-24 18:48:48 -07:00
Dylan Baker 5fe03cf8d9 unittests/base: Allow init method to fail
This adds a new keyword argument to the init method, `allow_fail`. When
set to True (default is False) then a failure to configure is not an
error, and output is still returned. This can be useful for cases where
we expect initialization to fail, and want to check the output.
2021-08-16 16:21:51 -07:00
Dylan Baker 310d7d13f4 unittests/base: Move code out of the try block of a try/except statement
There are two problems with having this in the try/except block. The
first is that both of the if statements will raise, and the except
statement cathces `Exception`, so it catches these two cases, prints a
message that we either don't want or already printed, then re-raises.
2021-08-16 16:21:51 -07:00
Dylan Baker 7daed5faf8 unittests/baseplatform: don't double print on error 2021-08-16 16:21:51 -07:00
Eli Schwartz 59d4f771d2
editorconfig: add setting to trim trailing whitespace
and clean up all outstanding issues

Skip 'test cases/common/141 special characters/meson.build' since it
intentionally uses trailing newlines.
2021-08-15 09:36:18 -04:00
Xavier Claessens 7eb4c23156 Split run_unittests.py file 2021-07-26 15:19:13 -04:00