summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/meson/meson/0004-Prettifying-some-output-with-pathlib.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/meson/meson/0004-Prettifying-some-output-with-pathlib.patch')
-rw-r--r--meta/recipes-devtools/meson/meson/0004-Prettifying-some-output-with-pathlib.patch188
1 files changed, 188 insertions, 0 deletions
diff --git a/meta/recipes-devtools/meson/meson/0004-Prettifying-some-output-with-pathlib.patch b/meta/recipes-devtools/meson/meson/0004-Prettifying-some-output-with-pathlib.patch
new file mode 100644
index 0000000000..e75633beb9
--- /dev/null
+++ b/meta/recipes-devtools/meson/meson/0004-Prettifying-some-output-with-pathlib.patch
@@ -0,0 +1,188 @@
1From 253ab5bf6d6d925abcf625b72f5fcacf99be13bd Mon Sep 17 00:00:00 2001
2From: Niklas Claesson <nicke.claesson@gmail.com>
3Date: Wed, 18 Apr 2018 15:25:03 +0200
4Subject: [PATCH] Prettifying some output with pathlib
5
6This is a backport required in order to make
70005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch apply.
8
9Upstream-Status: Accepted [https://github.com/mesonbuild/meson/pull/3423]
10Should be in the 0.47.0 release.
11
12Signed-off-by: Martin Kelly <mkelly@xevo.com>
13---
14 run_cross_test.py | 6 ++++--
15 run_project_tests.py | 51 +++++++++++++++++++++++++++++----------------------
16 2 files changed, 33 insertions(+), 24 deletions(-)
17
18diff --git a/run_cross_test.py b/run_cross_test.py
19index e285e218..71914028 100755
20--- a/run_cross_test.py
21+++ b/run_cross_test.py
22@@ -22,13 +22,15 @@ Not part of the main test suite because of two reasons:
23
24 Eventually migrate to something fancier.'''
25
26-import sys, os
27+import sys
28+import os
29+from pathlib import Path
30
31 from run_project_tests import gather_tests, run_tests, StopException, setup_commands
32 from run_project_tests import failing_logs
33
34 def runtests(cross_file):
35- commontests = [('common', gather_tests('test cases/common'), False)]
36+ commontests = [('common', gather_tests(Path('test cases', 'common')), False)]
37 try:
38 (passing_tests, failing_tests, skipped_tests) = run_tests(commontests, 'meson-cross-test-run', ['--cross', cross_file])
39 except StopException:
40diff --git a/run_project_tests.py b/run_project_tests.py
41index 8c02a9ee..3c516240 100755
42--- a/run_project_tests.py
43+++ b/run_project_tests.py
44@@ -14,14 +14,22 @@
45 # See the License for the specific language governing permissions and
46 # limitations under the License.
47
48-from glob import glob
49 import itertools
50-import os, subprocess, shutil, sys, signal
51+import os
52+import subprocess
53+import shutil
54+import sys
55+import signal
56 from io import StringIO
57 from ast import literal_eval
58 from enum import Enum
59 import tempfile
60-from mesonbuild import build, environment, mesonlib, mlog, mtest
61+from pathlib import Path, PurePath
62+from mesonbuild import build
63+from mesonbuild import environment
64+from mesonbuild import mesonlib
65+from mesonbuild import mlog
66+from mesonbuild import mtest
67 from mesonbuild.mesonlib import stringlistify, Popen_safe
68 from mesonbuild.coredata import backendlist
69 import argparse
70@@ -198,7 +206,7 @@ def validate_install(srcdir, installdir, compiler, env):
71
72 def log_text_file(logfile, testdir, stdo, stde):
73 global stop, executor, futures
74- logfile.write('%s\nstdout\n\n---\n' % testdir)
75+ logfile.write('%s\nstdout\n\n---\n' % testdir.as_posix())
76 logfile.write(stdo)
77 logfile.write('\n\n---\n\nstderr\n\n---\n')
78 logfile.write(stde)
79@@ -245,11 +253,11 @@ def run_test_inprocess(testdir):
80 sys.stderr = mystderr = StringIO()
81 old_cwd = os.getcwd()
82 os.chdir(testdir)
83- test_log_fname = 'meson-logs/testlog.txt'
84+ test_log_fname = Path('meson-logs', 'testlog.txt')
85 try:
86 returncode_test = mtest.run(['--no-rebuild'])
87- if os.path.exists(test_log_fname):
88- test_log = open(test_log_fname, errors='ignore').read()
89+ if test_log_fname.exists():
90+ test_log = test_log_fname.open(errors='ignore').read()
91 else:
92 test_log = ''
93 returncode_benchmark = mtest.run(['--no-rebuild', '--benchmark', '--logbase', 'benchmarklog'])
94@@ -318,9 +326,8 @@ def _run_test(testdir, test_build_dir, install_dir, extra_args, compiler, backen
95 gen_args += [testdir, test_build_dir] + flags + test_args + extra_args
96 (returncode, stdo, stde) = run_configure(meson_command, gen_args)
97 try:
98- logfile = os.path.join(test_build_dir, 'meson-logs/meson-log.txt')
99- with open(logfile, encoding='utf-8', errors='ignore') as f:
100- mesonlog = f.read()
101+ logfile = Path(test_build_dir, 'meson-logs', 'meson-log.txt')
102+ mesonlog = logfile.open(errors='ignore', encoding='utf-8').read()
103 except Exception:
104 mesonlog = no_meson_log_msg
105 gen_time = time.time() - gen_start
106@@ -390,11 +397,11 @@ def _run_test(testdir, test_build_dir, install_dir, extra_args, compiler, backen
107 return TestResult(validate_install(testdir, install_dir, compiler, builddata.environment),
108 BuildStep.validate, stdo, stde, mesonlog, gen_time, build_time, test_time)
109
110-def gather_tests(testdir):
111- tests = [t.replace('\\', '/').split('/', 2)[2] for t in glob(testdir + '/*')]
112+def gather_tests(testdir: Path):
113+ tests = [t.name for t in testdir.glob('*')]
114 testlist = [(int(t.split()[0]), t) for t in tests]
115 testlist.sort()
116- tests = [os.path.join(testdir, t[1]) for t in testlist]
117+ tests = [testdir / t[1] for t in testlist]
118 return tests
119
120 def have_d_compiler():
121@@ -517,7 +524,7 @@ def detect_tests_to_run():
122 ('fpga', 'fpga', shutil.which('yosys') is None),
123 ('frameworks', 'frameworks', False),
124 ]
125- gathered_tests = [(name, gather_tests('test cases/' + subdir), skip) for name, subdir, skip in all_tests]
126+ gathered_tests = [(name, gather_tests(Path('test cases', subdir)), skip) for name, subdir, skip in all_tests]
127 return gathered_tests
128
129 def run_tests(all_tests, log_name_base, extra_args):
130@@ -566,18 +573,18 @@ def _run_tests(all_tests, log_name_base, extra_args):
131 for t in test_cases:
132 # Jenkins screws us over by automatically sorting test cases by name
133 # and getting it wrong by not doing logical number sorting.
134- (testnum, testbase) = os.path.split(t)[-1].split(' ', 1)
135+ (testnum, testbase) = t.name.split(' ', 1)
136 testname = '%.3d %s' % (int(testnum), testbase)
137 should_fail = False
138 if name.startswith('failing'):
139 should_fail = name.split('failing-')[1]
140- result = executor.submit(run_test, skipped, t, extra_args, system_compiler, backend, backend_flags, commands, should_fail)
141+ result = executor.submit(run_test, skipped, t.as_posix(), extra_args, system_compiler, backend, backend_flags, commands, should_fail)
142 futures.append((testname, t, result))
143 for (testname, t, result) in futures:
144 sys.stdout.flush()
145 result = result.result()
146- if (result is None) or (('MESON_SKIP_TEST' in result.stdo) and (skippable(name, t))):
147- print(yellow('Skipping:'), t)
148+ if (result is None) or (('MESON_SKIP_TEST' in result.stdo) and (skippable(name, t.as_posix()))):
149+ print(yellow('Skipping:'), t.as_posix())
150 current_test = ET.SubElement(current_suite, 'testcase', {'name': testname,
151 'classname': name})
152 ET.SubElement(current_test, 'skipped', {})
153@@ -585,7 +592,7 @@ def _run_tests(all_tests, log_name_base, extra_args):
154 else:
155 without_install = "" if len(install_commands) > 0 else " (without install)"
156 if result.msg != '':
157- print(red('Failed test{} during {}: {!r}'.format(without_install, result.step.name, t)))
158+ print(red('Failed test{} during {}: {!r}'.format(without_install, result.step.name, t.as_posix())))
159 print('Reason:', result.msg)
160 failing_tests += 1
161 if result.step == BuildStep.configure and result.mlog != no_meson_log_msg:
162@@ -597,7 +604,7 @@ def _run_tests(all_tests, log_name_base, extra_args):
163 failing_logs.append(result.stdo)
164 failing_logs.append(result.stde)
165 else:
166- print('Succeeded test%s: %s' % (without_install, t))
167+ print('Succeeded test%s: %s' % (without_install, t.as_posix()))
168 passing_tests += 1
169 conf_time += result.conftime
170 build_time += result.buildtime
171@@ -641,7 +648,7 @@ def check_format():
172
173 def check_meson_commands_work():
174 global backend, meson_command, compile_commands, test_commands, install_commands
175- testdir = 'test cases/common/1 trivial'
176+ testdir = PurePath('test cases', 'common', '1 trivial').as_posix()
177 with AutoDeletedDir(tempfile.mkdtemp(prefix='b ', dir='.')) as build_dir:
178 print('Checking that configuring works...')
179 gen_cmd = mesonlib.meson_command + [testdir, build_dir] + backend_flags
180@@ -706,7 +713,7 @@ if __name__ == '__main__':
181 except UnicodeError:
182 print(l.encode('ascii', errors='replace').decode(), '\n')
183 for name, dirs, skip in all_tests:
184- dirs = (os.path.basename(x) for x in dirs)
185+ dirs = (x.name for x in dirs)
186 for k, g in itertools.groupby(dirs, key=lambda x: x.split()[0]):
187 tests = list(g)
188 if len(tests) != 1: