summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2023-06-30 14:55:45 -0700
committerEli Schwartz <eschwartz93@gmail.com>2023-07-25 15:50:21 -0400
commitc30cdfc4b056c2638779bf126b70fd5f6bbaac29 (patch)
tree9d852e94036e7d49fbb4bcd7e1bb598925b5062f
parent9ae6e38e90d9a0ddcc1bb8a85eb04220f4976841 (diff)
downloadmeson-c30cdfc4b056c2638779bf126b70fd5f6bbaac29.tar.gz
unittests: use subtests for template tests
Which gives more exact errors
-rw-r--r--unittests/allplatformstests.py51
1 files changed, 26 insertions, 25 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index b4bf3714a..4b20529d0 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -2231,31 +2231,32 @@ class AllPlatformTests(BasePlatformTests):
for lang in langs:
for target_type in ('executable', 'library'):
- if is_windows() and lang == 'fortran' and target_type == 'library':
- # non-Gfortran Windows Fortran compilers do not do shared libraries in a Fortran standard way
- # see "test cases/fortran/6 dynamic"
- fc = detect_compiler_for(env, 'fortran', MachineChoice.HOST, True)
- if fc.get_id() in {'intel-cl', 'pgi'}:
- continue
- # test empty directory
- with tempfile.TemporaryDirectory() as tmpdir:
- self._run(self.meson_command + ['init', '--language', lang, '--type', target_type],
- workdir=tmpdir)
- self._run(self.setup_command + ['--backend=ninja', 'builddir'],
- workdir=tmpdir)
- self._run(ninja,
- workdir=os.path.join(tmpdir, 'builddir'))
- # test directory with existing code file
- if lang in {'c', 'cpp', 'd'}:
- with tempfile.TemporaryDirectory() as tmpdir:
- with open(os.path.join(tmpdir, 'foo.' + lang), 'w', encoding='utf-8') as f:
- f.write('int main(void) {}')
- self._run(self.meson_command + ['init', '-b'], workdir=tmpdir)
- elif lang in {'java'}:
- with tempfile.TemporaryDirectory() as tmpdir:
- with open(os.path.join(tmpdir, 'Foo.' + lang), 'w', encoding='utf-8') as f:
- f.write('public class Foo { public static void main() {} }')
- self._run(self.meson_command + ['init', '-b'], workdir=tmpdir)
+ with self.subTest(f'Language: {lang}; type: {target_type}'):
+ if is_windows() and lang == 'fortran' and target_type == 'library':
+ # non-Gfortran Windows Fortran compilers do not do shared libraries in a Fortran standard way
+ # see "test cases/fortran/6 dynamic"
+ fc = detect_compiler_for(env, 'fortran', MachineChoice.HOST, True)
+ if fc.get_id() in {'intel-cl', 'pgi'}:
+ continue
+ # test empty directory
+ with tempfile.TemporaryDirectory() as tmpdir:
+ self._run(self.meson_command + ['init', '--language', lang, '--type', target_type],
+ workdir=tmpdir)
+ self._run(self.setup_command + ['--backend=ninja', 'builddir'],
+ workdir=tmpdir)
+ self._run(ninja,
+ workdir=os.path.join(tmpdir, 'builddir'))
+ # test directory with existing code file
+ if lang in {'c', 'cpp', 'd'}:
+ with tempfile.TemporaryDirectory() as tmpdir:
+ with open(os.path.join(tmpdir, 'foo.' + lang), 'w', encoding='utf-8') as f:
+ f.write('int main(void) {}')
+ self._run(self.meson_command + ['init', '-b'], workdir=tmpdir)
+ elif lang in {'java'}:
+ with tempfile.TemporaryDirectory() as tmpdir:
+ with open(os.path.join(tmpdir, 'Foo.' + lang), 'w', encoding='utf-8') as f:
+ f.write('public class Foo { public static void main() {} }')
+ self._run(self.meson_command + ['init', '-b'], workdir=tmpdir)
def test_compiler_run_command(self):
'''