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