When testing on Travis, verify that tools/build was run
This is done by routing the generation of HTML into a temporary directory, and checking its diff agains the existing public/ when running tests. Fixes #237
This commit is contained in:
26
tools/build
26
tools/build
@@ -15,5 +15,27 @@ tools/format
|
||||
verbose && echo "Measuring line lengths..."
|
||||
tools/measure
|
||||
|
||||
verbose && echo "Generating HTML..."
|
||||
tools/generate
|
||||
# SITE_DIR is the final location where we want generated content to be
|
||||
SITE_DIR="public"
|
||||
|
||||
# GENERATE_DIR is where the content will be generated initially
|
||||
GENERATE_DIR="$(mktemp -d)"
|
||||
|
||||
function cleanup() {
|
||||
rm -rf "$GENERATE_DIR"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
verbose && echo "Generating HTML to $GENERATE_DIR..."
|
||||
tools/generate $GENERATE_DIR
|
||||
|
||||
# In TESTING mode, make sure that the generated content is identical to
|
||||
# what's already in SITE_DIR. If a difference is found, this script exits
|
||||
# with an error.
|
||||
if [[ ! -z "$TESTING" ]]; then
|
||||
echo "Comparing $GENERATE_DIR with $SITE_DIR..."
|
||||
diff -r "$GENERATE_DIR" "$SITE_DIR"
|
||||
fi
|
||||
|
||||
verbose && echo "Copying $GENERATE_DIR to $SITE_DIR"
|
||||
cp -rf "${GENERATE_DIR}/." "$SITE_DIR"
|
||||
|
||||
Reference in New Issue
Block a user