mixed_mode_test.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash -eu
  2. set -o pipefail
  3. # This test exercises mixed builds where Soong and Bazel cooperate in building
  4. # Android.
  5. #
  6. # When the execroot is deleted, the Bazel server process will automatically
  7. # terminate itself.
  8. source "$(dirname "$0")/lib.sh"
  9. function test_bazel_smoke {
  10. setup
  11. run_soong bp2build
  12. run_bazel info --config=bp2build
  13. }
  14. function test_add_irrelevant_file {
  15. setup
  16. mkdir -p soong_tests/a/b
  17. touch soong_tests/a/b/c.txt
  18. cat > soong_tests/a/b/Android.bp <<'EOF'
  19. filegroup {
  20. name: "c",
  21. srcs: ["c.txt"],
  22. bazel_module: { bp2build_available: true },
  23. }
  24. EOF
  25. run_soong --bazel-mode-staging nothing
  26. if [[ ! -e out/soong/bp2build/soong_tests/a/b/BUILD.bazel ]]; then
  27. fail "BUILD.bazel not created"
  28. fi
  29. if [[ ! -e out/soong/build.ninja ]]; then
  30. fail "build.ninja not created"
  31. fi
  32. local mtime_build1=$(stat -c "%y" out/soong/bp2build/soong_tests/a/b/BUILD.bazel)
  33. local mtime_ninja1=$(stat -c "%y" out/soong/build.ninja)
  34. touch soong_tests/a/irrelevant.txt
  35. run_soong --bazel-mode-staging nothing
  36. local mtime_build2=$(stat -c "%y" out/soong/bp2build/soong_tests/a/b/BUILD.bazel)
  37. local mtime_ninja2=$(stat -c "%y" out/soong/build.ninja)
  38. if [[ "$mtime_build1" != "$mtime_build2" ]]; then
  39. fail "BUILD.bazel was generated"
  40. fi
  41. if [[ "$mtime_ninja1" != "$mtime_ninja2" ]]; then
  42. fail "build.ninja was regenerated"
  43. fi
  44. if [[ ! -e out/soong/workspace/soong_tests/a/irrelevant.txt ]]; then
  45. fail "new file was not symlinked"
  46. fi
  47. }
  48. scan_and_run_tests