blob: b01e39c75f7052721a8cc1aaf8b631031b68f85e [file] [log] [blame]
c-parsons166ff5e2019-09-11 12:04:15 -04001#!/usr/bin/env bash
2# Copyright 2019 The Bazel Authors. All rights reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16# Renerates most Stardoc golden files for Stardoc golden tests.
17#
18# When run, every golden file which is changed as a result of this script should
19# be manually examined and *heavily* scrutinized, as this usually indicates a large
20# in-place change of core rendering functionality of Stardoc.
21
22set -eu
23
24# Some tests cannot be automatically regenerated using this script, as they don't fall under the normal
25# golden test pattern
26EXCLUDED_TESTS="namespace_test_with_whitelist|proto_format_test|multi_level_namespace_test_with_whitelist|local_repository_test"
27echo "** Querying for tests..."
28regen_targets=$(bazel query //test:all | grep regenerate_with_jar | grep -vE "$EXCLUDED_TESTS")
29
30echo "** Building goldens..."
31bazel build $regen_targets
32
33echo "** Copying goldens..."
34for regen_target in $regen_targets; do
35 base_target_name=$(echo $regen_target | sed 's/\/\/test://g')
36 testdata_pkg_name=$(echo $base_target_name | sed 's/regenerate_with_jar_//g' | sed 's/_golden//g')
37 out_file="bazel-bin/test/${base_target_name}.out"
c-parsons59458dc2019-10-10 16:22:07 -040038 cp $out_file "test/testdata/${testdata_pkg_name}/golden.md"
c-parsons166ff5e2019-09-11 12:04:15 -040039done
40
41echo "** Files copied."
42echo "Please note that not all golden files are correctly copied by this script."
43echo "You may want to manually run:"
44echo ""
45echo "bazel test //test:all"
46echo ""
47echo "...and manually update tests which are still broken."