From 0e6045864cdae4ec8f05ee28e12573533ad38c0f Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Thu, 23 Feb 2017 11:46:30 +0530 Subject: [PATCH] tests: Use #!/usr/bin/env python3 for all scripts We automatically convert that to use sys.executable now which is always available on all platforms (because we're running with it). On some platforms like NetBSD, `python` doesn't exist, and you must use a specific python version. On most other distros, `python` is Python 2, and we don't want to depend on that. Closes https://github.com/mesonbuild/meson/issues/695 All these scripts were being used as `find_program()`, so we do not lose any test coverage by doing this. --- test cases/common/105 find program path/program.py | 2 +- test cases/common/107 postconf/postconf.py | 2 +- test cases/common/108 postconf with args/postconf.py | 2 +- test cases/common/113 generatorcustom/catter.py | 2 +- test cases/common/113 generatorcustom/gen.py | 2 +- test cases/common/118 allgenerate/converter.py | 2 +- test cases/common/129 object only target/obj_generator.py | 2 +- .../common/131 custom target directory install/docgen.py | 2 +- .../common/133 configure file in generator/src/gen.py | 2 +- test cases/common/134 generated llvm ir/copyfile.py | 2 +- test cases/common/135 generated assembly/copyfile.py | 2 +- test cases/common/48 test args/tester.py | 2 +- test cases/common/58 run target/check_exists.py | 2 +- test cases/common/58 run target/converter.py | 2 +- test cases/common/58 run target/fakeburner.py | 2 +- test cases/common/58 run target/meson.build | 6 ++++-- test cases/common/60 install script/myinstall.py | 2 +- test cases/common/60 install script/src/myinstall.py | 2 +- .../common/61 custom target source output/generator.py | 2 +- test cases/common/64 custom header generator/makeheader.py | 2 +- test cases/common/65 multiple generators/mygen.py | 2 +- test cases/common/72 build always/version_gen.py | 2 +- .../76 configure file in custom target/src/mycompiler.py | 2 +- test cases/common/77 external test program/mytest.py | 2 +- test cases/common/78 ctarget dependency/gen1.py | 2 +- test cases/common/78 ctarget dependency/gen2.py | 2 +- test cases/common/93 private include/stlib/compiler.py | 2 +- test cases/common/95 dep fallback/gensrc.py | 2 +- .../common/95 dep fallback/subprojects/boblib/genbob.py | 2 +- test cases/common/98 gen extra/srcgen.py | 2 +- test cases/frameworks/7 gnome/resources-data/meson.build | 4 +++- 31 files changed, 36 insertions(+), 32 deletions(-) diff --git a/test cases/common/105 find program path/program.py b/test cases/common/105 find program path/program.py index b91071862..2ebc56419 100644 --- a/test cases/common/105 find program path/program.py +++ b/test cases/common/105 find program path/program.py @@ -1,3 +1,3 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 print("Found") diff --git a/test cases/common/107 postconf/postconf.py b/test cases/common/107 postconf/postconf.py index 9a23cfaf2..950c7064a 100644 --- a/test cases/common/107 postconf/postconf.py +++ b/test cases/common/107 postconf/postconf.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os diff --git a/test cases/common/108 postconf with args/postconf.py b/test cases/common/108 postconf with args/postconf.py index 3ed0450cc..cef7f790f 100644 --- a/test cases/common/108 postconf with args/postconf.py +++ b/test cases/common/108 postconf with args/postconf.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys, os diff --git a/test cases/common/113 generatorcustom/catter.py b/test cases/common/113 generatorcustom/catter.py index a79b7395a..198fa98e2 100755 --- a/test cases/common/113 generatorcustom/catter.py +++ b/test cases/common/113 generatorcustom/catter.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys diff --git a/test cases/common/113 generatorcustom/gen.py b/test cases/common/113 generatorcustom/gen.py index f9efb477d..c1e34ed6c 100755 --- a/test cases/common/113 generatorcustom/gen.py +++ b/test cases/common/113 generatorcustom/gen.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys diff --git a/test cases/common/118 allgenerate/converter.py b/test cases/common/118 allgenerate/converter.py index cc2c5749b..f8e2ca05a 100755 --- a/test cases/common/118 allgenerate/converter.py +++ b/test cases/common/118 allgenerate/converter.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys diff --git a/test cases/common/129 object only target/obj_generator.py b/test cases/common/129 object only target/obj_generator.py index f0239b44e..a33872aac 100755 --- a/test cases/common/129 object only target/obj_generator.py +++ b/test cases/common/129 object only target/obj_generator.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Mimic a binary that generates an object file (e.g. windres). diff --git a/test cases/common/131 custom target directory install/docgen.py b/test cases/common/131 custom target directory install/docgen.py index 4d80124de..245f37035 100644 --- a/test cases/common/131 custom target directory install/docgen.py +++ b/test cases/common/131 custom target directory install/docgen.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os import sys diff --git a/test cases/common/133 configure file in generator/src/gen.py b/test cases/common/133 configure file in generator/src/gen.py index 5bccece12..99b7cddb9 100755 --- a/test cases/common/133 configure file in generator/src/gen.py +++ b/test cases/common/133 configure file in generator/src/gen.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys diff --git a/test cases/common/134 generated llvm ir/copyfile.py b/test cases/common/134 generated llvm ir/copyfile.py index da503e27c..ff42ac359 100644 --- a/test cases/common/134 generated llvm ir/copyfile.py +++ b/test cases/common/134 generated llvm ir/copyfile.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys import shutil diff --git a/test cases/common/135 generated assembly/copyfile.py b/test cases/common/135 generated assembly/copyfile.py index da503e27c..ff42ac359 100644 --- a/test cases/common/135 generated assembly/copyfile.py +++ b/test cases/common/135 generated assembly/copyfile.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys import shutil diff --git a/test cases/common/48 test args/tester.py b/test cases/common/48 test args/tester.py index c3c1edce7..0b4010ab9 100755 --- a/test cases/common/48 test args/tester.py +++ b/test cases/common/48 test args/tester.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys diff --git a/test cases/common/58 run target/check_exists.py b/test cases/common/58 run target/check_exists.py index 62cbe2398..b6fc967eb 100755 --- a/test cases/common/58 run target/check_exists.py +++ b/test cases/common/58 run target/check_exists.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os import sys diff --git a/test cases/common/58 run target/converter.py b/test cases/common/58 run target/converter.py index 9f47ba552..8dd31fe2f 100644 --- a/test cases/common/58 run target/converter.py +++ b/test cases/common/58 run target/converter.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys diff --git a/test cases/common/58 run target/fakeburner.py b/test cases/common/58 run target/fakeburner.py index 7f505d6bd..da3d0ac1e 100755 --- a/test cases/common/58 run target/fakeburner.py +++ b/test cases/common/58 run target/fakeburner.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from __future__ import print_function diff --git a/test cases/common/58 run target/meson.build b/test cases/common/58 run target/meson.build index 8a06490b5..a1c5ad8ab 100644 --- a/test cases/common/58 run target/meson.build +++ b/test cases/common/58 run target/meson.build @@ -19,15 +19,17 @@ hex = custom_target('exe.hex', ], ) +fakeburner = find_program('fakeburner.py') + # These emulates the Arduino flasher application. It sandwiches the filename inside # a packed argument. Thus we need to declare it manually. run_target('upload', - command : ['fakeburner.py', 'x:@0@:y'.format(exe.full_path())], + command : [fakeburner, 'x:@0@:y'.format(exe.full_path())], depends : exe, ) run_target('upload2', - command : ['fakeburner.py', 'x:@0@:y'.format(hex.full_path())], + command : [fakeburner, 'x:@0@:y'.format(hex.full_path())], depends : hex, ) diff --git a/test cases/common/60 install script/myinstall.py b/test cases/common/60 install script/myinstall.py index 969aba58e..812561e0e 100644 --- a/test cases/common/60 install script/myinstall.py +++ b/test cases/common/60 install script/myinstall.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os import sys diff --git a/test cases/common/60 install script/src/myinstall.py b/test cases/common/60 install script/src/myinstall.py index d8a5714ac..3b7ce37d4 100644 --- a/test cases/common/60 install script/src/myinstall.py +++ b/test cases/common/60 install script/src/myinstall.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import os import sys diff --git a/test cases/common/61 custom target source output/generator.py b/test cases/common/61 custom target source output/generator.py index 42532ca5d..3464b0a85 100755 --- a/test cases/common/61 custom target source output/generator.py +++ b/test cases/common/61 custom target source output/generator.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys, os diff --git a/test cases/common/64 custom header generator/makeheader.py b/test cases/common/64 custom header generator/makeheader.py index 0c5a228bf..f15683447 100644 --- a/test cases/common/64 custom header generator/makeheader.py +++ b/test cases/common/64 custom header generator/makeheader.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # NOTE: this file does not have the executable bit set. This tests that # Meson can automatically parse shebang lines. diff --git a/test cases/common/65 multiple generators/mygen.py b/test cases/common/65 multiple generators/mygen.py index 020a38906..99dc33136 100755 --- a/test cases/common/65 multiple generators/mygen.py +++ b/test cases/common/65 multiple generators/mygen.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys, os diff --git a/test cases/common/72 build always/version_gen.py b/test cases/common/72 build always/version_gen.py index 3973e6128..d7b01ca1a 100755 --- a/test cases/common/72 build always/version_gen.py +++ b/test cases/common/72 build always/version_gen.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys, os, subprocess diff --git a/test cases/common/76 configure file in custom target/src/mycompiler.py b/test cases/common/76 configure file in custom target/src/mycompiler.py index e1750f8d9..b00c862db 100644 --- a/test cases/common/76 configure file in custom target/src/mycompiler.py +++ b/test cases/common/76 configure file in custom target/src/mycompiler.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys diff --git a/test cases/common/77 external test program/mytest.py b/test cases/common/77 external test program/mytest.py index 7cdaf09a2..9947773f7 100755 --- a/test cases/common/77 external test program/mytest.py +++ b/test cases/common/77 external test program/mytest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from __future__ import print_function diff --git a/test cases/common/78 ctarget dependency/gen1.py b/test cases/common/78 ctarget dependency/gen1.py index f920e538e..0fa6ea1eb 100755 --- a/test cases/common/78 ctarget dependency/gen1.py +++ b/test cases/common/78 ctarget dependency/gen1.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import time, sys diff --git a/test cases/common/78 ctarget dependency/gen2.py b/test cases/common/78 ctarget dependency/gen2.py index fc60e1eb2..b087b02cc 100755 --- a/test cases/common/78 ctarget dependency/gen2.py +++ b/test cases/common/78 ctarget dependency/gen2.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys, os from glob import glob diff --git a/test cases/common/93 private include/stlib/compiler.py b/test cases/common/93 private include/stlib/compiler.py index 0555c1675..98dbe46fa 100755 --- a/test cases/common/93 private include/stlib/compiler.py +++ b/test cases/common/93 private include/stlib/compiler.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys, os diff --git a/test cases/common/95 dep fallback/gensrc.py b/test cases/common/95 dep fallback/gensrc.py index da503e27c..ff42ac359 100644 --- a/test cases/common/95 dep fallback/gensrc.py +++ b/test cases/common/95 dep fallback/gensrc.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys import shutil diff --git a/test cases/common/95 dep fallback/subprojects/boblib/genbob.py b/test cases/common/95 dep fallback/subprojects/boblib/genbob.py index 7da323382..34af7790e 100644 --- a/test cases/common/95 dep fallback/subprojects/boblib/genbob.py +++ b/test cases/common/95 dep fallback/subprojects/boblib/genbob.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys diff --git a/test cases/common/98 gen extra/srcgen.py b/test cases/common/98 gen extra/srcgen.py index 86fd698f8..8988cd92f 100755 --- a/test cases/common/98 gen extra/srcgen.py +++ b/test cases/common/98 gen extra/srcgen.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys import argparse diff --git a/test cases/frameworks/7 gnome/resources-data/meson.build b/test cases/frameworks/7 gnome/resources-data/meson.build index fd8cb0a2a..9458c2d90 100644 --- a/test cases/frameworks/7 gnome/resources-data/meson.build +++ b/test cases/frameworks/7 gnome/resources-data/meson.build @@ -1,5 +1,7 @@ subdir('subdir') +python3 = import('python3').find_python() + fake_generator_script = ''' import os, sys assert os.path.exists(sys.argv[1]), "File %s not found" % sys.argv[1] @@ -11,6 +13,6 @@ print("This is a generated resource.") res3_txt = custom_target('res3.txt', input: 'res3.txt.in', output: 'res3.txt', - command: ['python3', '-c', fake_generator_script, '@INPUT@'], + command: [python3, '-c', fake_generator_script, '@INPUT@'], capture: true, )