Skip to content
This repository has been archived by the owner on Nov 10, 2018. It is now read-only.

Commit

Permalink
linux: Add tests.sh to validate fontconfig
Browse files Browse the repository at this point in the history
For #29
  • Loading branch information
13rac1 committed Apr 14, 2016
1 parent d17da30 commit 7fe53fc
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
36 changes: 36 additions & 0 deletions linux/expected-results.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Font: sans
Vera.ttf: "Bitstream Vera Sans" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"

Font: sans-serif
Vera.ttf: "Bitstream Vera Sans" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"

Font: serif
VeraSe.ttf: "Bitstream Vera Serif" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"

Font: mono
VeraMono.ttf: "Bitstream Vera Sans Mono" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"

Font: monospace
VeraMono.ttf: "Bitstream Vera Sans Mono" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"

Font: Bitstream Vera Sans
Vera.ttf: "Bitstream Vera Sans" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"

Font: Bitstream Vera Serif
VeraSe.ttf: "Bitstream Vera Serif" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"

Font: Bitstream Vera Sans Mono
VeraMono.ttf: "Bitstream Vera Sans Mono" "Roman"
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"

Font: Emoji One Color
EmojiOneColor-SVGinOT.ttf: "Emoji One Color" "Regular"
Vera.ttf: "Bitstream Vera Sans" "Roman"

49 changes: 49 additions & 0 deletions linux/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
# Tests of fontconfig configuration for Bitstream Vera and Emoji One Color.
#
# The first two lines of the results of fc-match for each font request are
# are compared to known correct results. Any differences are shown.

# The test result file
TMP=current-results.test
# The expected test result file
EXPECTED=expected-results.test

FONTS[0]='sans'
FONTS[1]="sans-serif"
FONTS[2]="serif"
FONTS[3]="mono"
FONTS[4]="monospace"
FONTS[5]="Bitstream Vera Sans"
FONTS[6]="Bitstream Vera Serif"
FONTS[7]="Bitstream Vera Sans Mono"
FONTS[8]="Emoji One Color"

rm -f $TMP

# Run fc-match against all font values
for FONT in "${FONTS[@]}"; do
echo "Font: $FONT" >> $TMP
fc-match -s "$FONT" | head -n2 >> $TMP
echo >> $TMP
done

# Create expected results if missing, aka delete to update.
if [ ! -f $EXPECTED ]; then
cp $TMP $EXPECTED
echo "Fontconfig tests: UPDATE"
exit 1
fi
# Compare current results to expected results
echo diff $TMP $EXPECTED
diff -yt $TMP $EXPECTED
RESULT=$?
rm $TMP

if [ $RESULT -eq 0 ]; then
echo "Fontconfig tests: PASS"
exit 0
else
echo "Fontconfig tests: FAIL"
exit 1
fi

0 comments on commit 7fe53fc

Please sign in to comment.