build_file.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #!/usr/bin/python
  2. # Copyright (C) 2006. Vladimir Prus
  3. # Copyright (C) 2008. Jurko Gospodnetic
  4. # Distributed under the Boost Software License, Version 1.0.
  5. # (See accompanying file LICENSE.txt or copy at
  6. # https://www.bfgroup.xyz/b2/LICENSE.txt)
  7. # Tests that we explicitly request a file (not target) to be built by
  8. # specifying its name on the command line.
  9. import BoostBuild
  10. ###############################################################################
  11. #
  12. # test_building_file_from_specific_project()
  13. # ------------------------------------------
  14. #
  15. ###############################################################################
  16. def test_building_file_from_specific_project():
  17. t = BoostBuild.Tester(use_test_config=False)
  18. t.write("jamroot.jam", """\
  19. exe hello : hello.cpp ;
  20. exe hello2 : hello.cpp ;
  21. build-project sub ;
  22. """)
  23. t.write("hello.cpp", "int main() {}\n")
  24. t.write("sub/jamfile.jam", """
  25. exe hello : hello.cpp ;
  26. exe hello2 : hello.cpp ;
  27. exe sub : hello.cpp ;
  28. """)
  29. t.write("sub/hello.cpp", "int main() {}\n")
  30. t.run_build_system(["sub", t.adjust_suffix("hello.obj")])
  31. t.expect_output_lines("*depends on itself*", False)
  32. t.expect_addition("sub/bin/$toolset/debug*/hello.obj")
  33. t.expect_nothing_more()
  34. t.cleanup()
  35. ###############################################################################
  36. #
  37. # test_building_file_from_specific_target()
  38. # -----------------------------------------
  39. #
  40. ###############################################################################
  41. def test_building_file_from_specific_target():
  42. t = BoostBuild.Tester(use_test_config=False)
  43. t.write("jamroot.jam", """\
  44. exe hello1 : hello1.cpp ;
  45. exe hello2 : hello2.cpp ;
  46. exe hello3 : hello3.cpp ;
  47. """)
  48. t.write("hello1.cpp", "int main() {}\n")
  49. t.write("hello2.cpp", "int main() {}\n")
  50. t.write("hello3.cpp", "int main() {}\n")
  51. t.run_build_system(["hello1", t.adjust_suffix("hello1.obj")])
  52. t.expect_addition("bin/$toolset/debug*/hello1.obj")
  53. t.expect_nothing_more()
  54. t.cleanup()
  55. ###############################################################################
  56. #
  57. # test_building_missing_file_from_specific_target()
  58. # -------------------------------------------------
  59. #
  60. ###############################################################################
  61. def test_building_missing_file_from_specific_target():
  62. t = BoostBuild.Tester(use_test_config=False)
  63. t.write("jamroot.jam", """\
  64. exe hello1 : hello1.cpp ;
  65. exe hello2 : hello2.cpp ;
  66. exe hello3 : hello3.cpp ;
  67. """)
  68. t.write("hello1.cpp", "int main() {}\n")
  69. t.write("hello2.cpp", "int main() {}\n")
  70. t.write("hello3.cpp", "int main() {}\n")
  71. obj = t.adjust_suffix("hello2.obj")
  72. t.run_build_system(["hello1", obj], status=1)
  73. t.expect_output_lines("don't know how to make*" + obj)
  74. t.expect_nothing_more()
  75. t.cleanup()
  76. ###############################################################################
  77. #
  78. # test_building_multiple_files_with_different_names()
  79. # ---------------------------------------------------
  80. #
  81. ###############################################################################
  82. def test_building_multiple_files_with_different_names():
  83. t = BoostBuild.Tester(use_test_config=False)
  84. t.write("jamroot.jam", """\
  85. exe hello1 : hello1.cpp ;
  86. exe hello2 : hello2.cpp ;
  87. exe hello3 : hello3.cpp ;
  88. """)
  89. t.write("hello1.cpp", "int main() {}\n")
  90. t.write("hello2.cpp", "int main() {}\n")
  91. t.write("hello3.cpp", "int main() {}\n")
  92. t.run_build_system([t.adjust_suffix("hello1.obj"), t.adjust_suffix(
  93. "hello2.obj")])
  94. t.expect_addition("bin/$toolset/debug*/hello1.obj")
  95. t.expect_addition("bin/$toolset/debug*/hello2.obj")
  96. t.expect_nothing_more()
  97. t.cleanup()
  98. ###############################################################################
  99. #
  100. # test_building_multiple_files_with_the_same_name()
  101. # -------------------------------------------------
  102. #
  103. ###############################################################################
  104. def test_building_multiple_files_with_the_same_name():
  105. t = BoostBuild.Tester(use_test_config=False)
  106. t.write("jamroot.jam", """\
  107. exe hello : hello.cpp ;
  108. exe hello2 : hello.cpp ;
  109. build-project sub ;
  110. """)
  111. t.write("hello.cpp", "int main() {}\n")
  112. t.write("sub/jamfile.jam", """
  113. exe hello : hello.cpp ;
  114. exe hello2 : hello.cpp ;
  115. exe sub : hello.cpp ;
  116. """)
  117. t.write("sub/hello.cpp", "int main() {}\n")
  118. t.run_build_system([t.adjust_suffix("hello.obj")])
  119. t.expect_output_lines("*depends on itself*", False)
  120. t.expect_addition("bin/$toolset/debug*/hello.obj")
  121. t.expect_addition("sub/bin/$toolset/debug*/hello.obj")
  122. t.expect_nothing_more()
  123. t.cleanup()
  124. ###############################################################################
  125. #
  126. # main()
  127. # ------
  128. #
  129. ###############################################################################
  130. test_building_file_from_specific_project()
  131. test_building_file_from_specific_target()
  132. test_building_missing_file_from_specific_target()
  133. test_building_multiple_files_with_different_names()
  134. test_building_multiple_files_with_the_same_name()