From 69ca8f5b544f700210d9f18613311bcce3c2e37a Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 12 Oct 2016 19:44:40 +0530 Subject: [PATCH 1/2] meson.py: Always resolve full path to meson.py There is no reason to not always do this. Without this, we end up with a relative path to meson.py in build.ninja files when meson.py is launched using subprocess.Popen and friends from the meson source root. This was causing the unittests to intermittently fail when regen was getting invoked by the pic test. Funnily enough, this only happened when run via ./run_tests.py because __file__ was 'run_unittests.py' in that (as opposed to './run_unittests.py') case which made os.path.dirname(__file__) be '', and the os.path.split test in meson.py thought that meson.py was invoked via PATH. --- meson.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/meson.py b/meson.py index 4d8a26979..8c223e588 100755 --- a/meson.py +++ b/meson.py @@ -18,10 +18,8 @@ from mesonbuild import mesonmain import sys, os def main(): - launcher = sys.argv[0] - # resolve the command path if not launched from $PATH - if os.path.split(launcher)[0]: - launcher = os.path.realpath(launcher) + # Always resolve the command path so Ninja can find it for regen, tests, etc. + launcher = os.path.realpath(sys.argv[0]) return mesonmain.run(launcher, sys.argv[1:]) if __name__ == '__main__': From 7307f6a5c84c507ae8801405d1d1ee1b68151edd Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 12 Oct 2016 20:22:04 +0530 Subject: [PATCH 2/2] unittests/pic: Actually test that setting b_staticpic works The previous test was tautological for the second half because: a) b_staticpic=true is the default b) We weren't refetching the compdb --- run_unittests.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/run_unittests.py b/run_unittests.py index 5cd7d0f63..9ea9e237b 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest, os, sys, shutil +import unittest, os, sys, shutil, time import subprocess import re, json import tempfile @@ -77,9 +77,15 @@ class LinuxlikeTests(unittest.TestCase): self.init(testdir) compdb = self.get_compdb() self.assertTrue('-fPIC' in compdb[0]['command']) - self.setconf('-Db_staticpic=true') + # This is needed to increase the difference between build.ninja's + # timestamp and coredata.dat's timestamp due to a Ninja bug. + # https://github.com/ninja-build/ninja/issues/371 + time.sleep(1) + self.setconf('-Db_staticpic=false') + # Regenerate build self.build() - self.assertFalse('-fPIC' not in compdb[0]['command']) + compdb = self.get_compdb() + self.assertTrue('-fPIC' not in compdb[0]['command']) if __name__ == '__main__': unittest.main()