aboutsummaryrefslogtreecommitdiff
path: root/tests/symlink_forest_rerun_test.sh
blob: 74e779ecf702f793026c2b918cd8c93c82fad6c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash -eu

set -o pipefail

# Tests that symlink forest will replant if soong_build has changed
# Any change to the build system should trigger a rerun

source "$(dirname "$0")/lib.sh"

function test_symlink_forest_reruns {
  setup

  mkdir -p a
  touch a/g.txt
  cat > a/Android.bp <<'EOF'
filegroup {
    name: "g",
    srcs: ["g.txt"],
  }
EOF

  run_soong g

  mtime=`cat out/soong/workspace/soong_build_mtime`
  # rerun with no changes - ensure that it hasn't changed
  run_soong g
  newmtime=`cat out/soong/workspace/soong_build_mtime`
  if [[ ! "$mtime" == "$mtime" ]]; then
     fail "symlink forest reran when it shouldn't have"
  fi

  # change exit codes to force a soong_build rebuild.
  sed -i 's/os.Exit(1)/os.Exit(2)/g' build/soong/bp2build/symlink_forest.go

  run_soong g
  newmtime=`cat out/soong/workspace/soong_build_mtime`
  if [[ "$mtime" == "$newmtime" ]]; then
     fail "symlink forest did not rerun when it should have"
  fi

}

scan_and_run_tests