remove compare_revs.sh, as it's very crutchy and unstable, not suitable for serious testing

This commit is contained in:
Egor Aristov 2025-02-23 14:26:29 +03:00
parent 1cd1310803
commit f56dc77e5a
3 changed files with 2 additions and 82 deletions

2
.gitignore vendored
View File

@ -2,6 +2,8 @@
/trash/
/todo.md
/.env.dev
/test_tasks/
/compare_revs.sh
/task*.json
/screenshot*.png
node_modules

View File

@ -1,69 +0,0 @@
#!/usr/bin/env bash
# Copy project to temp directory and then reset it to HEAD to capture output of last commited version
# Then go back to current dir, capture output of current working tree
# Compare outputs for several tasks, notify if differ
# Caveats: this test uses real websites and parsing tasks - so it's not idempotent.
# I should think about better solution
set -e
old_dir=$(mktemp -d)
cur_dir=$(pwd)
task_dir=$cur_dir/test_tasks
trap "echo cleaning up && rm -rf $old_dir && echo done" EXIT
echo "Copying project to $old_dir"
time rsync -ar --exclude "node_modules" $cur_dir/ $old_dir
cd $old_dir
git reset --hard HEAD
cd -
failed=0
for task in $task_dir/*; do
echo "Task $task"
old_out=$(mktemp)
echo "Old version output: $old_out"
cur_out=$(mktemp)
echo "Cur version output: $cur_out"
set +e
cd $old_dir
rm -f $old_dir/screenshot.png
sleep 2
go run github.com/egor3f/rssalchemy/cmd/extractor -o $old_out "$task"
if [ $? != 0 ]; then
echo "Failed to run old version"
cat $old_out
exit 1
fi
cd -
sleep 2
go run github.com/egor3f/rssalchemy/cmd/extractor -o $cur_out "$task"
if [ $? != 0 ]; then
echo "Failed to run new version"
cat $cur_out
exit 1
fi
set -e
if [ "$(cat $old_out)" != "$(cat $cur_out)" ]; then
echo "Output differ for $task. To inspect use: "
echo "diff -u $old_out $cur_out"
failed=$((failed + 1))
if [ -f $old_dir/screenshot.png ]; then
cp $old_dir/screenshot.png $cur_dir/screenshot_old.png
echo Screenshot of old version output copied to cwd
fi
fi
done
echo "-----------"
total=$(ls -1q $task_dir/* | wc -l)
echo "Failed: $failed of $total"
if [ $failed > 0 ]; then
exit 1
fi

View File

@ -1,13 +0,0 @@
{
"TaskType": "extract",
"URL": "https://vombat.su/new/all",
"SelectorPost": "div.post-body",
"SelectorTitle": "h1 a",
"SelectorLink": "h1 a",
"SelectorDescription": "div.post-content-block p",
"SelectorAuthor": "a:has(\u003e span.post-author)",
"SelectorCreated": "div:nth-of-type(1) \u003e div:nth-of-type(1) \u003e div:nth-of-type(1) \u003e div:nth-of-type(2)",
"SelectorContent": "div.post-content-block",
"SelectorEnclosure": "article img.object-contain",
"Headers": {}
}