Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First try of converting tests to tsht #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/bower_components
/node_modules
npm-debug.log
test/.tsht
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: bash

script: ./test/tsht
47 changes: 47 additions & 0 deletions test/backend.tsht
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env tsht
PORT=9091
SAMPLE_URL="http://example.org/fileadmin/digi/445442158/thumbs/445442158_0126.jpg"
SAMPLE_THUMB="example/fileadmin/digi/445442158/thumbs/445442158_0126.jpg"
SAMPLE_CORR="example/ocr-corrections/digi/445442158/gt/0126/correction.html"
SAMPLE_COMM="example/ocr-corrections/digi/445442158/gt/0126/anmerkungen.txt"

# rm request log files, samples, start the server, wait a second, see if it's still running
start_server() {
rm -f dist/log/* $SAMPLE_COMM $SAMPLE_CORR
plackup --port=$PORT ../app.psgi & SERVER_PID=$!
sleep 1
ps -p "$SERVER_PID" 2>/dev/null
}

stop_server() {
kill "$SERVER_PID" && true
cat dist/log/ocr-gt-tools.log
}

# # Test history
# test_history() {
# curl -i "http://localhost:$PORT/ocr-gt-tools.cgi?action=history"
# [[ "$(wc -l dist/log/request.log|cut -d' ' -f1)" = "1" ]];
# }

# Test create
test_create() {
[[ ! -e $SAMPLE_CORR ]];
curl -i "http://localhost:$PORT/ocr-gt-tools.cgi?action=create&imageUrl=$SAMPLE_URL"
[[ -e $SAMPLE_CORR ]];
}


# -x Trace steps
# -e exit on first non-null return value
set -e

# Stop the server for failing tests
trap stop_server EXIT

start_server

# test_create
# test_history

stop_server
22 changes: 22 additions & 0 deletions test/tsht
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Unless TSHTLIB is already set
if [[ -z "$TSHTLIB" ]];then

# Set TSHTLIB to the `.tshs` directory relative to this script
TSHTLIB="$(cd "$(dirname "$0")" && pwd)/.tsht"

# Unless TSHTLIB exists, try to clone it
if [[ ! -e "$TSHTLIB" ]];then
echo "# $TSHTLIB does not exist, cloning"
git clone --depth 1 'http://github.com/kba/tsht' "$TSHTLIB"
if [[ ! -d "$TSHTLIB" ]];then
echo "Failed to clone tsht framework!"
exit 201
fi
fi
fi

# Export TSHTLIB and execute the test-runner
export TSHTLIB
exec "$TSHTLIB/tsht-runner.sh" "$@"