Skip to content

Commit bb37a45

Browse files
committed
test(replay): regenerate_expected script
Only to be used when making sweeping format changes
1 parent b48c97d commit bb37a45

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
# regenerate_expected.sh - Regenerate all .expected.json files from test data
3+
4+
set -e
5+
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
PROJECT_ROOT="$SCRIPT_DIR/../.."
8+
cd "$PROJECT_ROOT"
9+
10+
echo "This will regenerate all .expected.json files in tests/data/"
11+
echo "This will overwrite existing expected files."
12+
echo ""
13+
read -p "Are you sure you want to continue? (y/N) " -n 1 -r
14+
echo ""
15+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
16+
echo "Aborted."
17+
exit 1
18+
fi
19+
20+
echo ""
21+
echo "Regenerating all .expected.json files..."
22+
echo "=========================================="
23+
24+
for data_file in tests/data/*.json; do
25+
if [[ "$data_file" == *.expected.json ]]; then
26+
continue
27+
fi
28+
29+
expected_file="${data_file%.json}.expected.json"
30+
echo "Processing: $data_file -> $expected_file"
31+
32+
nvim --headless -u tests/manual/init_replay.lua \
33+
"+ReplayLoad $data_file" \
34+
"+ReplayAll 0" \
35+
"+lua vim.defer_fn(function() vim.cmd('ReplaySave $expected_file') vim.cmd('qall!') end, 200)" 2>&1 | grep -v "^$"
36+
done
37+
38+
echo ""
39+
echo "=========================================="
40+
echo "Done! Regenerated $(ls tests/data/*.expected.json | wc -l | tr -d ' ') expected files"

0 commit comments

Comments
 (0)