Mark Dacek | b2441c5 | 2023-10-04 16:12:00 +0000 | [diff] [blame^] | 1 | #!/bin/bash -eu |
| 2 | |
| 3 | set -o pipefail |
| 4 | |
| 5 | # Tests that symlink forest will replant if soong_build has changed |
| 6 | # Any change to the build system should trigger a rerun |
| 7 | |
| 8 | source "$(dirname "$0")/lib.sh" |
| 9 | |
| 10 | function test_symlink_forest_reruns { |
| 11 | setup |
| 12 | |
| 13 | mkdir -p a |
| 14 | touch a/g.txt |
| 15 | cat > a/Android.bp <<'EOF' |
| 16 | filegroup { |
| 17 | name: "g", |
| 18 | srcs: ["g.txt"], |
| 19 | } |
| 20 | EOF |
| 21 | |
| 22 | run_soong g |
| 23 | |
| 24 | mtime=`cat out/soong/workspace/soong_build_mtime` |
| 25 | # rerun with no changes - ensure that it hasn't changed |
| 26 | run_soong g |
| 27 | newmtime=`cat out/soong/workspace/soong_build_mtime` |
| 28 | if [[ ! "$mtime" == "$mtime" ]]; then |
| 29 | fail "symlink forest reran when it shouldn't have" |
| 30 | fi |
| 31 | |
| 32 | # change exit codes to force a soong_build rebuild. |
| 33 | sed -i 's/os.Exit(1)/os.Exit(2)/g' build/soong/bp2build/symlink_forest.go |
| 34 | |
| 35 | run_soong g |
| 36 | newmtime=`cat out/soong/workspace/soong_build_mtime` |
| 37 | if [[ "$mtime" == "$newmtime" ]]; then |
| 38 | fail "symlink forest did not rerun when it should have" |
| 39 | fi |
| 40 | |
| 41 | } |
| 42 | |
| 43 | scan_and_run_tests |