1#!/usr/bin/python 2 3# Copyright 2002 Dave Abrahams 4# Copyright 2003, 2004 Vladimir Prus 5# Distributed under the Boost Software License, Version 1.0. 6# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 7 8import BoostBuild 9import os.path 10import re 11 12 13def check_for_existing_boost_build_jam(t): 14 """ 15 This test depends on no boost-build.jam file existing in any of the 16 folders along the current folder's path. If it does exist, not only would 17 this test fail but it could point to a completely wrong Boost Build 18 installation, thus causing headaches when attempting to diagnose the 19 problem. That is why we explicitly check for this scenario. 20 21 """ 22 problem = find_up_to_root(t.workdir, "boost-build.jam") 23 if problem: 24 BoostBuild.annotation("misconfiguration", """\ 25This test expects to be run from a folder with no 'boost-build.jam' file in any 26of the folders along its path. 27 28Working folder: 29 '%s' 30 31Problematic boost-build.jam found at: 32 '%s' 33 34Please remove this file or change the test's working folder and rerun the test. 35""" % (t.workdir, problem)) 36 t.fail_test(1, dump_stdio=False, dump_stack=False) 37 38 39def find_up_to_root(folder, name): 40 last = "" 41 while last != folder: 42 candidate = os.path.join(folder, name) 43 if os.path.exists(candidate): 44 return candidate 45 last = folder 46 folder = os.path.dirname(folder) 47 48 49def match_re(actual, expected): 50 return re.match(expected, actual, re.DOTALL) != None 51 52 53t = BoostBuild.Tester(match=match_re, boost_build_path="", pass_toolset=0) 54t.set_tree("startup") 55check_for_existing_boost_build_jam(t) 56 57t.run_build_system(status=1, stderr= 58r"""Unable to load B2: could not find 'boost-build\.jam' 59.*Attempted search from .* up to the root at '.*'""") 60 61t.run_build_system(status=1, subdir="no-bootstrap1", 62 stderr= 63r"""Unable to load B2: could not find build system\. 64----------------------------------------------- 65.*attempted to load the build system by invoking 66.*'boost-build ;' 67.*but we were unable to find 'bootstrap\.jam' in the specified directory or in BOOST_BUILD_PATH:""") 68 69# Descend to a subdirectory which /does not/ contain a boost-build.jam file, 70# and try again to test the crawl-up behavior. 71t.run_build_system(status=1, subdir=os.path.join("no-bootstrap1", "subdir"), 72 stderr=r"Unable to load B2: could not find build system\." 73 r".*attempted to load the build system by invoking" 74 r".*'boost-build ;'" 75 r".*but we were unable to find 'bootstrap\.jam' in the specified directory or in BOOST_BUILD_PATH:") 76 77t.run_build_system(status=1, subdir="no-bootstrap2", 78 stderr=r"Unable to load B2: could not find build system\." 79 r".*attempted to load the build system by invoking" 80 r".*'boost-build \. ;'" 81 r".*but we were unable to find 'bootstrap\.jam' in the specified directory or in BOOST_BUILD_PATH:") 82 83t.run_build_system(status=1, subdir='no-bootstrap3', stderr= 84r"""Unable to load B2 85.*boost-build\.jam' was found.* 86However, it failed to call the 'boost-build' rule to indicate the location of the build system.""") 87 88# Test bootstrapping based on BOOST_BUILD_PATH. 89t.run_build_system(["-sBOOST_BUILD_PATH=../boost-root/build"], 90 subdir="bootstrap-env", stdout="build system bootstrapped") 91 92# Test bootstrapping based on an explicit path in boost-build.jam. 93t.run_build_system(subdir="bootstrap-explicit", 94 stdout="build system bootstrapped") 95 96t.cleanup() 97