From b2441c52a4b2b1547d4b09ca70a2382cc2de0b51 Mon Sep 17 00:00:00 2001 From: Mark Dacek Date: Wed, 4 Oct 2023 16:12:00 +0000 Subject: Revert "Revert "Modify symlink_forest to rerun when soong_build has changed."" This reverts commit aa5cc2cd6af5da7c65914500fc6e11c6a130060c. Reason for revert: Fixed the bug in the original draft. There was an error in how we compared the file's MTime to the file's contents. Bug: 300288299 Test: presubmits Test: build/soong/tests/run_integration_tests.sh Change-Id: I9e53432c0842c0b9fc13fe20d30ce9af37640c7f --- tests/run_integration_tests.sh | 1 + tests/symlink_forest_rerun_test.sh | 43 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100755 tests/symlink_forest_rerun_test.sh (limited to 'tests') diff --git a/tests/run_integration_tests.sh b/tests/run_integration_tests.sh index 223baa4ac..8045591b4 100755 --- a/tests/run_integration_tests.sh +++ b/tests/run_integration_tests.sh @@ -10,6 +10,7 @@ TOP="$(readlink -f "$(dirname "$0")"/../../..)" "$TOP/build/soong/tests/persistent_bazel_test.sh" "$TOP/build/soong/tests/soong_test.sh" "$TOP/build/soong/tests/stale_metrics_files_test.sh" +"$TOP/build/soong/tests/symlink_forest_rerun_test.sh" "$TOP/prebuilts/build-tools/linux-x86/bin/py3-cmd" "$TOP/build/bazel/ci/rbc_dashboard.py" aosp_arm64-userdebug # The following tests build against the full source tree and don't rely on the diff --git a/tests/symlink_forest_rerun_test.sh b/tests/symlink_forest_rerun_test.sh new file mode 100755 index 000000000..74e779ecf --- /dev/null +++ b/tests/symlink_forest_rerun_test.sh @@ -0,0 +1,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 -- cgit v1.2.3-59-g8ed1b