startup_v2.py 3.4 KB

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