-
Notifications
You must be signed in to change notification settings - Fork 12
/
test_lib
executable file
·32 lines (23 loc) · 1.46 KB
/
test_lib
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
#!/bin/zsh
# Run tests across all test files, and report what has changed in a pretty way.
# Test metadata files are stored in $TEST_FILES_DIR (./jsons) directory: those
# are JSON files that contain Bandcamp release metadata.
#
# You can use 'url2json -s <release-url>' to create such testing file for your
# release of choice.
# It extracts the relevant metadata saves it in './jsons' directory under
# the filename that resembles that release URL (where slashes are replaced by
# underscores).
TESTS_DIR=lib_tests
TEST_FILES_DIR=jsons
before=${1:?Previous revision required as 1st arg}
after=${2:?Current/target revision required as 2nd arg}
print >&2 "Base: $before, target: $after"
poe test-files --no-summary -n4 --base $before --target $after
jq 'if .original_artist == .artist then .artist else "\(.original_artist) -> \(.artist)" end' -r $TESTS_DIR/$after/*.json(^-@) >$TESTS_DIR/artist-$after
jq '(.album // .title) as $name | if .original_name == $name then $name else "\(.original_name) -> \($name)" end' -r $TESTS_DIR/$after/*.json(^-@) >$TESTS_DIR/album-$after
jq '.catalognum // ""' -r $TESTS_DIR/$after/*.json(^-@) >$TESTS_DIR/catalognum-$after
jq '(.tracks // [.])[] | if .track_alt then "\(.track_alt). " else "" end + "\(.artist) - \(.title)"' -r $TESTS_DIR/$after/*.json(^-@) -r >$TESTS_DIR/tracks-$after
for type in album artist catalognum tracks; do
git diff --unified=0 --no-index --color-words $TESTS_DIR/$type-$before $TESTS_DIR/$type-$after | grep -v '@@ -'
done