From efa2e1e75166f59b45f4d46979725f0447f9c2cd Mon Sep 17 00:00:00 2001 From: Tom Limoncelli <6293917+tlimoncelli@users.noreply.github.com> Date: Tue, 2 Dec 2025 10:46:28 -0500 Subject: [PATCH] DEV: Add tool to reset js/parse_tests data (#3874) # Issue Add tool to reset js/parse_tests data gets out of date easily. Manually updating it sucks. # Resolution Publish a script that copies the "actual" data to the "want" data. DO NOT CHECK IN THE RESULTS WITHOUT CAREFUL REVIEW. --- bin/fix_js_parse_tests.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 bin/fix_js_parse_tests.sh diff --git a/bin/fix_js_parse_tests.sh b/bin/fix_js_parse_tests.sh new file mode 100755 index 000000000..bb605d85b --- /dev/null +++ b/bin/fix_js_parse_tests.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# fix_js_parse_tests.sh -- Fix up the pkg/js/parse_tests "want" files. +# +# DO NOT use this without carefully checking the output. You could +# accidentally codify bad test data and commit it to the repo. +# +# Useful bash/zsh alias: +# alias fixjsparse='"$(git rev-parse --show-toplevel)/bin/fix_js_parse_tests.sh"' + +set -e + +cd $(git rev-parse --show-toplevel) +cd pkg/js +find . -type f -name \*.ACTUAL -print -delete +go test -count=1 ./... || true +cd parse_tests +fmtjson *.json *.json.ACTUAL +for i in *.ACTUAL ; do f=$(basename $i .ACTUAL) ; mv $i $f ; done