testsuite: Test gtk4-builder-tool simplify --replace

Run all gtk4-builder-tool test with and without --replace.
This improves test coverage for gtk4-builder-tool
This commit is contained in:
Matthias Clasen 2020-11-01 10:33:53 -05:00
parent cb018ec047
commit b0b00d49d2
2 changed files with 30 additions and 2 deletions

View File

@ -7,13 +7,14 @@ TEST_RESULT_DIR=${TEST_RESULT_DIR:-/tmp}
shopt -s nullglob shopt -s nullglob
TESTS=( "$TEST_DATA_DIR"/*.ui ) TESTS=( "$TEST_DATA_DIR"/*.ui )
echo "1..${#TESTS[*]}" echo "1..$((2 * ${#TESTS[*]}))"
I=1 I=1
for t in ${TESTS[*]}; do for t in ${TESTS[*]}; do
name=$(basename $t .ui) name=$(basename $t .ui)
expected="$TEST_DATA_DIR/$name.expected" expected="$TEST_DATA_DIR/$name.expected"
result="$TEST_RESULT_DIR/$name.out" result="$TEST_RESULT_DIR/$name.out"
result2="$TEST_RESULT_DIR/$name.out2"
diff="$TEST_RESULT_DIR/$name.diff" diff="$TEST_RESULT_DIR/$name.diff"
ref="$TEST_RESULT_DIR/$name.ref" ref="$TEST_RESULT_DIR/$name.ref"
@ -28,4 +29,17 @@ for t in ${TESTS[*]}; do
fi fi
I=$((I+1)) I=$((I+1))
cp $t $result2
$GTK_BUILDER_TOOL simplify --3to4 --replace $result2 2>/dev/null
if diff -u "$expected" "$result2" > "$diff"; then
echo "ok $I $name (--replace)"
rm "$diff"
else
echo "not ok $I $name (--replace)"
cp "$expected" "$ref"
fi
I=$((I+1))
done done

View File

@ -7,13 +7,14 @@ TEST_RESULT_DIR=${TEST_RESULT_DIR:-/tmp}
shopt -s nullglob shopt -s nullglob
TESTS=( "$TEST_DATA_DIR"/*.ui ) TESTS=( "$TEST_DATA_DIR"/*.ui )
echo "1..${#TESTS[*]}" echo "1..$((2 * ${#TESTS[*]}))"
I=1 I=1
for t in ${TESTS[*]}; do for t in ${TESTS[*]}; do
name=$(basename $t .ui) name=$(basename $t .ui)
expected="$TEST_DATA_DIR/$name.expected" expected="$TEST_DATA_DIR/$name.expected"
result="$TEST_RESULT_DIR/$name.out" result="$TEST_RESULT_DIR/$name.out"
result2="$TEST_RESULT_DIR/$name.out2"
diff="$TEST_RESULT_DIR/$name.diff" diff="$TEST_RESULT_DIR/$name.diff"
ref="$TEST_RESULT_DIR/$name.ref" ref="$TEST_RESULT_DIR/$name.ref"
@ -28,4 +29,17 @@ for t in ${TESTS[*]}; do
fi fi
I=$((I+1)) I=$((I+1))
cp $t $result2
$GTK_BUILDER_TOOL simplify --replace $result2 2>/dev/null
if diff -u "$expected" "$result2" > "$diff"; then
echo "ok $I $name (--replace)"
rm "$diff"
else
echo "not ok $I $name (--replace)"
cp "$expected" "$ref"
fi
I=$((I+1))
done done