-
Notifications
You must be signed in to change notification settings - Fork 45
/
update-stardoc-tests.sh
executable file
·73 lines (65 loc) · 2.65 KB
/
update-stardoc-tests.sh
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bash
# Copyright 2019 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Renerates most Stardoc golden files for Stardoc golden tests.
#
# When run, every golden file which is changed as a result of this script should
# be manually examined and *heavily* scrutinized, as this usually indicates a large
# in-place change of core rendering functionality of Stardoc.
set -eu
function run_buildozer () {
# buildozer uses return code 3 to signal a no-op, so we can't use "set -e"
set +e
buildozer "$@"
ret=$?
set -e
if [[ $ret != 0 && $ret != 3 ]]; then
return $ret
fi
}
function update_non_manual_tests () {
echo "** Querying for non-manual tests..."
regenerate $(${BAZEL} query "kind(sh_binary, //test:all) - attr(tags, manual, //test:all)" | grep _regenerate)
}
function update_manual_tests_with_tag () {
local manual_tag="$1"; shift
echo "** Querying for tests tagged \"${manual_tag}\", \"manual\" using 'USE_BAZEL_VERSION=${USE_BAZEL_VERSION:-} ${BAZEL}' $@ ..."
BUILD_FLAGS="$@" regenerate $(${BAZEL} query "attr(tags, ${manual_tag}, attr(tags, manual, kind(sh_binary, //test:all)))" | grep _regenerate)
}
function regenerate () {
echo "** Regenerating and copying goldens..."
local run_cmd="run ${BUILD_FLAGS:-}"
for regen_target in $@; do
if [[ -z ${USE_BAZEL_VERSION:-} ]]; then
echo "** Running '${BAZEL} ${run_cmd} ${regen_target}' ..."
else
echo "** Running 'USE_BAZEL_VERSION=${USE_BAZEL_VERSION} ${BAZEL} ${run_cmd} ${regen_target}' BAZEL_BUILD_FLAGS ..."
fi
${BAZEL} ${run_cmd} "${regen_target}"
done
}
# Allow users to override the bazel command with e.g. bazelisk.
: "${BAZEL:=bazelisk}"
update_non_manual_tests
update_manual_tests_with_tag "noenable_bzlmod" --noenable_bzlmod
USE_BAZEL_VERSION="7.2.0" update_manual_tests_with_tag "bazel_7_2"
USE_BAZEL_VERSION="8.0.0-pre.20240603.2" update_manual_tests_with_tag "bazel_8"
echo "** Files copied."
echo "Please note that not all golden files are correctly copied by this script."
echo "You may want to manually run:"
echo ""
echo "${BAZEL} test //test:all"
echo ""
echo "...and manually update tests which are still broken."