Add scripts for smoke test

This commit is contained in:
Rotzbua 2023-03-04 21:08:11 +01:00
parent dbfdc46269
commit 3934d2854d
No known key found for this signature in database
GPG Key ID: C69022D529C17845
8 changed files with 165 additions and 21 deletions

2
.gitattributes vendored
View File

@ -1 +1,3 @@
*.py text eol=lf
*.sh text eol=lf
*.svg text eol=lf

1
.gitignore vendored
View File

@ -16,3 +16,4 @@ documentation/src/generators.inc
*.ipynb_checkpoints
venv/
.vscode/
test_data/

View File

@ -1,21 +0,0 @@
#!/usr/bin/env bash
BOXES=../scripts/boxes
set -x
$BOXES closedbox --x=50 --y=50 --h=70 --output=closedbox.svg
$BOXES hingebox --x=50 --y=50 --h=70 --output=hingebox.svg
$BOXES castle --output=castle.svg
$BOXES drillbox --output=drillbox.svg
$BOXES flexbox --x=70 --y=100 --h=50 --radius=20 --output=flexbox.svg
$BOXES flexbox2 --x=70 --y=100 --h=50 --radius=20 --output=flexbox2.svg
$BOXES flexbox3 --x=70 --y=100 --z=50 --h=8 --radius=30 --output=flexbox3.svg
$BOXES folder --x=165 --y=240 --h=20 --r=10 --output=folder.svg
#$BOXES lamp --x=50 --y=50 --r=10 --output=lamp.svg
$BOXES magazinefile --output=magazinefile.svg
#$BOXES printer --output=printer.svg
#$BOXES Silverwaree --output=silverwarebox.svg
#$BOXES traylayout --x=4 --y=4 --output=traylayout.txt
$BOXES traylayout2 --input=traylayout.txt --h=50 --hi=40 --output=traylayout.svg
$BOXES trayinsert --sx=70:100:70 --sy=100*3 --h=50 --output=trayinsert.svg
$BOXES typetray --sx=70:100:70 --sy=100*3 --h=60 --hi=50 --output=typetray.svg

24
scripts/clean_svg.sh Normal file
View File

@ -0,0 +1,24 @@
#!/bin/bash
echo "Clean data by removing metadata."
if [[ $# -ne 1 ]]; then
echo "Usage: {folder}"
exit 1
fi
if [[ -n $1 ]]; then
FILES=$1
fi
if ! [[ -d $FILES ]]; then
echo "This folder does not exists: $FILES"
exit 1
fi
echo "Start cleaning folder: $FILES"
for f in "$FILES"/*
do
echo "Clean: $f"
## Remove changing lines.
grep -v -E "(<dc:date>|<dc:source>|Creation date|Command line)" "$f" > "$f.tmp" && mv -f "$f.tmp" "$f"
done
echo "Finished cleaning folder."

56
scripts/gen_compare.sh Normal file
View File

@ -0,0 +1,56 @@
#!/bin/bash
echo "Compares files in two folders."
if [[ $# -ne 2 ]]; then
echo "Usage: {folder_reference} {folder_comparison}"
exit 1
fi
if [[ -n $1 ]]; then
FILES1=$1
fi
if [[ -n $2 ]]; then
FILES2=$2
fi
if ! [[ -d $FILES1 ]]; then
echo "This folder does not exists: $FILES1"
exit 1
fi
if ! [[ -d $FILES2 ]]; then
echo "This folder does not exists: $FILES2"
exit 1
fi
echo "Start comparing folders."
echo "Reference: $FILES1"
echo "Comparison: $FILES2"
ERROR=false
for f in "$FILES1"/*; do
FILENAME="$(basename -- "$f")"
echo "Compare: $FILENAME"
f2="$FILES2"/"$FILENAME"
if ! [[ -f $f ]]; then
echo "This file does not exists: $f"
exit 1
fi
if ! [[ -f $f2 ]]; then
echo "This file does not exists: $f2"
exit 1
fi
# if cmp --silent -- "$f" "$f2"; then # Problems with line endings.
if diff -q --strip-trailing-cr -- "$f" "$f2"; then
echo "[OK] files equal."
else
echo "[ERROR] files differ."
diff --strip-trailing-cr -- "$f" "$f2"
ERROR=true
fi
done
if [ "$ERROR" == true ]; then
echo "[ERROR] At least one error has occurred."
exit 1
fi

37
scripts/gen_data.sh Normal file
View File

@ -0,0 +1,37 @@
#!/bin/bash
echo "Generate data."
if [[ $# -ne 1 ]]; then
echo "Usage: {folder}"
exit 1
fi
if [[ -n $1 ]]; then
OUT=$1
fi
echo "Target folder: ${OUT}"
if ! [[ -d $OUT ]]; then
echo "This folder does not exists! Create folder."
mkdir "$OUT"
fi
DIR=$(dirname -- "$0")
BOXES="$DIR"/boxes
set -x
$BOXES castle --output="${OUT}"/castle.svg
$BOXES closedbox --x=50 --y=50 --h=70 --output="${OUT}"/closedbox.svg
$BOXES drillbox --output="${OUT}"/drillbox.svg
$BOXES flexbox --x=70 --y=100 --h=50 --radius=20 --output="${OUT}"/flexbox.svg
$BOXES flexbox2 --x=70 --y=100 --h=50 --radius=20 --output="${OUT}"/flexbox2.svg
$BOXES flexbox3 --x=70 --y=100 --z=50 --h=8 --radius=30 --output="${OUT}"/flexbox3.svg
$BOXES folder --x=165 --y=240 --h=20 --output="${OUT}"/folder.svg
$BOXES hingebox --x=50 --y=50 --h=70 --output="${OUT}"/hingebox.svg
$BOXES lamp --x=50 --y=50 --radius=10 --output="${OUT}"/lamp.svg
$BOXES magazinefile --output="${OUT}"/magazinefile.svg
$BOXES silverware --output="${OUT}"/silverware.svg
$BOXES trayinsert --sx=70:100:70 --sy=100*3 --h=50 --output="${OUT}"/trayinsert.svg
$BOXES traylayout --sx=10*5 --sy=10*5 --output="${OUT}"/traylayout.txt
$BOXES traylayout2 --input="${OUT}"/traylayout.txt --h=50 --hi=40 --output="${OUT}"/traylayout2.svg
$BOXES typetray --sx=70:100:70 --sy=100*3 --h=60 --hi=50 --output="${OUT}"/typetray.svg

18
scripts/gen_examples.sh Normal file
View File

@ -0,0 +1,18 @@
#!/bin/bash
echo "Generate cleaned example data."
if [[ $# -ne 1 ]]; then
echo "Usage: {folder}"
exit 1
fi
if [[ -n $1 ]]; then
OUT=$1
fi
DIR=$(dirname -- "$0")
# Generate data.
bash "$DIR"/gen_data.sh "$OUT"
# Clean meta data.
bash "$DIR"/clean_svg.sh "$OUT"

27
scripts/run_smoke_test.sh Normal file
View File

@ -0,0 +1,27 @@
#!/bin/bash
echo "Generate current data and compare against reference data."
if [[ $# -ne 2 ]]; then
echo "Usage: {folder_reference} {folder_comparison}"
exit 1
fi
if [[ -n $1 ]]; then
FILES1=$1
fi
if [[ -n $2 ]]; then
FILES2=$2
fi
if ! [[ -d $FILES1 ]]; then
echo "This folder does not exists: $FILES1"
exit 1
fi
DIR=$(dirname -- "$0")
# Generate current data.
bash "$DIR"/gen_examples.sh "$FILES2"
# For sanity clean reference data.
bash "$DIR"/clean_svg.sh "$FILES1"
# Do the test.
bash "$DIR"/gen_compare.sh "$FILES1" "$FILES2"