aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-10-13 11:02:41 -0700
committerNirbheek Chauhan <nirbheek@centricular.com>2021-01-06 14:52:26 +0530
commit589dbb0ee6e1e77384c2697da07c17a289bdcebe (patch)
tree7197509b0c5e2676d60ccf9fa501e64f59007c1e
parent030f1287e65073c3d521322abd874b1a902d7538 (diff)
downloadmeson-589dbb0ee6e1e77384c2697da07c17a289bdcebe.zip
meson-589dbb0ee6e1e77384c2697da07c17a289bdcebe.tar.gz
meson-589dbb0ee6e1e77384c2697da07c17a289bdcebe.tar.bz2
run_unittests: use textwrap.dedent
So that editors that can fold code (vim, vscode, etc) can correctly fold functions, instead of getting confused by code that doesn't follow the current indention. Also, it makes the code easier to read.
-rw-r--r--mesonbuild/build.py9
-rwxr-xr-xrun_unittests.py51
-rw-r--r--test cases/failing/76 link with shared module on osx/test.json2
3 files changed, 34 insertions, 28 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 78292f2..36d4e19 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1359,11 +1359,12 @@ You probably should put it in link_with instead.''')
for link_target in self.link_targets:
if isinstance(link_target, SharedModule):
if self.environment.machines[self.for_machine].is_darwin():
- raise MesonException('''target links against shared modules.
-This is not permitted on OSX''')
+ raise MesonException(
+ 'target links against shared modules. This is not permitted on OSX')
else:
- mlog.warning('''target links against shared modules. This is not
-recommended as it is not supported on some platforms''')
+ mlog.warning('target links against shared modules. This '
+ 'is not recommended as it is not supported on some '
+ 'platforms')
return
class Generator:
diff --git a/run_unittests.py b/run_unittests.py
index 85292d1..9081cfb 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -2942,20 +2942,22 @@ class AllPlatformTests(BasePlatformTests):
# the source tree leads to all kinds of trouble.
with tempfile.TemporaryDirectory() as project_dir:
with open(os.path.join(project_dir, 'meson.build'), 'w') as ofile:
- ofile.write('''project('disttest', 'c', version : '1.4.3')
-e = executable('distexe', 'distexe.c')
-test('dist test', e)
-subproject('vcssub', required : false)
-subproject('tarballsub', required : false)
-''')
+ ofile.write(textwrap.dedent('''\
+ project('disttest', 'c', version : '1.4.3')
+ e = executable('distexe', 'distexe.c')
+ test('dist test', e)
+ subproject('vcssub', required : false)
+ subproject('tarballsub', required : false)
+ '''))
with open(os.path.join(project_dir, 'distexe.c'), 'w') as ofile:
- ofile.write('''#include<stdio.h>
+ ofile.write(textwrap.dedent('''\
+ #include<stdio.h>
-int main(int argc, char **argv) {
- printf("I am a distribution test.\\n");
- return 0;
-}
-''')
+ int main(int argc, char **argv) {
+ printf("I am a distribution test.\\n");
+ return 0;
+ }
+ '''))
xz_distfile = os.path.join(self.distdir, 'disttest-1.4.3.tar.xz')
xz_checksumfile = xz_distfile + '.sha256sum'
zip_distfile = os.path.join(self.distdir, 'disttest-1.4.3.zip')
@@ -3614,8 +3616,8 @@ int main(int argc, char **argv) {
"""
tdir = os.path.join(self.unit_test_dir, '30 shared_mod linking')
out = self.init(tdir)
- msg = ('''WARNING: target links against shared modules. This is not
-recommended as it is not supported on some platforms''')
+ msg = ('WARNING: target links against shared modules. This is not '
+ 'recommended as it is not supported on some platforms')
self.assertIn(msg, out)
def test_ndebug_if_release_disabled(self):
@@ -7264,16 +7266,18 @@ class LinuxlikeTests(BasePlatformTests):
testdir = os.path.join(self.unit_test_dir, '61 identity cross')
nativefile = tempfile.NamedTemporaryFile(mode='w')
- nativefile.write('''[binaries]
-c = ['{0}']
-'''.format(os.path.join(testdir, 'build_wrapper.py')))
+ nativefile.write(textwrap.dedent('''\
+ [binaries]
+ c = ['{0}']
+ '''.format(os.path.join(testdir, 'build_wrapper.py'))))
nativefile.flush()
self.meson_native_file = nativefile.name
crossfile = tempfile.NamedTemporaryFile(mode='w')
- crossfile.write('''[binaries]
-c = ['{0}']
-'''.format(os.path.join(testdir, 'host_wrapper.py')))
+ crossfile.write(textwrap.dedent('''\
+ [binaries]
+ c = ['{0}']
+ '''.format(os.path.join(testdir, 'host_wrapper.py'))))
crossfile.flush()
self.meson_cross_file = crossfile.name
@@ -7286,9 +7290,10 @@ c = ['{0}']
'CC_FOR_BUILD': '"' + os.path.join(testdir, 'build_wrapper.py') + '"',
}
crossfile = tempfile.NamedTemporaryFile(mode='w')
- crossfile.write('''[binaries]
-c = ['{0}']
-'''.format(os.path.join(testdir, 'host_wrapper.py')))
+ crossfile.write(textwrap.dedent('''\
+ [binaries]
+ c = ['{0}']
+ '''.format(os.path.join(testdir, 'host_wrapper.py'))))
crossfile.flush()
self.meson_cross_file = crossfile.name
# TODO should someday be explicit about build platform only here
diff --git a/test cases/failing/76 link with shared module on osx/test.json b/test cases/failing/76 link with shared module on osx/test.json
index 4e2856f..0a32674 100644
--- a/test cases/failing/76 link with shared module on osx/test.json
+++ b/test cases/failing/76 link with shared module on osx/test.json
@@ -1,7 +1,7 @@
{
"stdout": [
{
- "line": "test cases/failing/76 link with shared module on osx/meson.build:8:0: ERROR: target links against shared modules."
+ "line": "test cases/failing/76 link with shared module on osx/meson.build:8:0: ERROR: target links against shared modules. This is not permitted on OSX"
}
]
}