#!/bin/bash set -e SOURCE="${BASH_SOURCE[0]}" while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" SOURCE="$(readlink "$SOURCE")" [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located done DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" TARGET_DIR="$DIR/public" "${DIR}"/setup-theme.sh ERROR_COUNT=0 incErrorCount () { ERROR_COUNT=$((ERROR_COUNT + 1)) } cleanBuildHugo () { rm -rf $TARGET_DIR cd "$DIR" && hugo } fail () { incErrorCount echo "$1" echo "Exiting now..." exit 1 } failButContinue () { incErrorCount echo "! $1" } testFolderAndContinue () { if [ ! -d "$1" ]; then failButContinue "Expected '$(realpath --relative-to="$TARGET_DIR" "$1")' but does not exist" fi } testContentAndContinue () { local FILE FILE=$2 local TEST_CONTENT TEST_CONTENT=$1 local OUT set +e OUT=$(grep -w "$TEST_CONTENT" "$FILE") set -e if [[ -z $OUT ]]; then failButContinue "Expected to find '$TEST_CONTENT' in file '$(realpath --relative-to="$TARGET_DIR" "$FILE")'" fi } cleanBuildHugo if [ ! -d "$TARGET_DIR" ]; then fail "Compile failed - '$TARGET_DIR' does not exist" fi if [ ! -d "$TARGET_DIR" ]; then failButContinue "Expected '$TARGET_DIR' but does not exist" fi echo "# Umlauts tests" testFolderAndContinue "$TARGET_DIR/author/ä-ß+" testFolderAndContinue "$TARGET_DIR/article/täst" testFolderAndContinue "$TARGET_DIR/de/article/täst" testFolderAndContinue "$TARGET_DIR/categories/täst++" testFolderAndContinue "$TARGET_DIR/de/categories/täst++" testFolderAndContinue "$TARGET_DIR/tags/c++" testFolderAndContinue "$TARGET_DIR/de/tags/c++" testFolderAndContinue "$TARGET_DIR/tags/tästing++" testFolderAndContinue "$TARGET_DIR/de/tags/tästing++" # article/täst [en] echo "## Testing article/täst [en]" testContentAndContinue 'Täst++' "$TARGET_DIR/article/täst/index.html" testContentAndContinue 'ä ß+' "$TARGET_DIR/article/täst/index.html" testContentAndContinue 'C++' "$TARGET_DIR/article/täst/index.html" testContentAndContinue 'tästing++' "$TARGET_DIR/article/täst/index.html" testContentAndContinue 'de' "$TARGET_DIR/article/täst/index.html" testContentAndContinue 'Umlauts Täst++' "$TARGET_DIR/article/täst/index.html" testContentAndContinue '

This is a umlauts-test in Quotes äüöß++

' "$TARGET_DIR/quote/index.html" testContentAndContinue 'Täst++ (2)' "$TARGET_DIR/article/täst/index.html" # article/täst [de] echo "## Testing article/täst [de]" testContentAndContinue 'Täst++' "$TARGET_DIR/de/article/täst/index.html" testContentAndContinue 'ä ß+' "$TARGET_DIR/de/article/täst/index.html" testContentAndContinue 'C++' "$TARGET_DIR/de/article/täst/index.html" testContentAndContinue 'tästing++' "$TARGET_DIR/de/article/täst/index.html" testContentAndContinue 'en' "$TARGET_DIR/de/article/täst/index.html" testContentAndContinue 'de Umlauts Täst++' "$TARGET_DIR/de/article/täst/index.html" testContentAndContinue '

de This is a umlauts-test in quotes äüöß++

' "$TARGET_DIR/de/quote/index.html" testContentAndContinue 'Täst++ (2)' "$TARGET_DIR/de/article/täst/index.html" # quote/täst-quote [en] echo "## Testing quote/täst-quote [en]" testContentAndContinue ' ä ß+ ' "$TARGET_DIR/quote/täst-quote/index.html" # quote/täst-quote [de] echo "## Testing quote/täst-quote [de]" testContentAndContinue ' ä ß+ ' "$TARGET_DIR/de/quote/täst-quote/index.html" echo "# Build stability test" BUILD_COUNT=100 for ((i=0; i /dev/null rm -rf "$TARGET_DIR$i" mv "$TARGET_DIR" "$TARGET_DIR$i" done DIFF_OUT="" set +e for ((i=1; i