blob: 74e779ecf702f793026c2b918cd8c93c82fad6c4 [file] [log] [blame]
Mark Dacekb2441c52023-10-04 16:12:00 +00001#!/bin/bash -eu
2
3set -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
8source "$(dirname "$0")/lib.sh"
9
10function test_symlink_forest_reruns {
11 setup
12
13 mkdir -p a
14 touch a/g.txt
15 cat > a/Android.bp <<'EOF'
16filegroup {
17 name: "g",
18 srcs: ["g.txt"],
19 }
20EOF
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
43scan_and_run_tests