From f56dc77e5ae490fbfae7234b00b7fc225136071f Mon Sep 17 00:00:00 2001 From: Egor Aristov Date: Sun, 23 Feb 2025 14:26:29 +0300 Subject: [PATCH] remove compare_revs.sh, as it's very crutchy and unstable, not suitable for serious testing --- .gitignore | 2 ++ compare_revs.sh | 69 ------------------------------------------ test_tasks/vombat.json | 13 -------- 3 files changed, 2 insertions(+), 82 deletions(-) delete mode 100644 compare_revs.sh delete mode 100644 test_tasks/vombat.json diff --git a/.gitignore b/.gitignore index ad9281f..141d1b3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ /trash/ /todo.md /.env.dev +/test_tasks/ +/compare_revs.sh /task*.json /screenshot*.png node_modules diff --git a/compare_revs.sh b/compare_revs.sh deleted file mode 100644 index 3de1780..0000000 --- a/compare_revs.sh +++ /dev/null @@ -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 diff --git a/test_tasks/vombat.json b/test_tasks/vombat.json deleted file mode 100644 index 6a3b79c..0000000 --- a/test_tasks/vombat.json +++ /dev/null @@ -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": {} -}