c-parsons | 166ff5e | 2019-09-11 12:04:15 -0400 | [diff] [blame] | 1 | #!/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 | |
| 22 | set -eu |
| 23 | |
| 24 | # Some tests cannot be automatically regenerated using this script, as they don't fall under the normal |
| 25 | # golden test pattern |
| 26 | EXCLUDED_TESTS="namespace_test_with_whitelist|proto_format_test|multi_level_namespace_test_with_whitelist|local_repository_test" |
| 27 | echo "** Querying for tests..." |
| 28 | regen_targets=$(bazel query //test:all | grep regenerate_with_jar | grep -vE "$EXCLUDED_TESTS") |
| 29 | |
| 30 | echo "** Building goldens..." |
| 31 | bazel build $regen_targets |
| 32 | |
| 33 | echo "** Copying goldens..." |
| 34 | for 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-parsons | 59458dc | 2019-10-10 16:22:07 -0400 | [diff] [blame] | 38 | cp $out_file "test/testdata/${testdata_pkg_name}/golden.md" |
c-parsons | 166ff5e | 2019-09-11 12:04:15 -0400 | [diff] [blame] | 39 | done |
| 40 | |
| 41 | echo "** Files copied." |
| 42 | echo "Please note that not all golden files are correctly copied by this script." |
| 43 | echo "You may want to manually run:" |
| 44 | echo "" |
| 45 | echo "bazel test //test:all" |
| 46 | echo "" |
| 47 | echo "...and manually update tests which are still broken." |