forked from bitc/hdevtools
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test framework and some really simple tests
- Loading branch information
Showing
9 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Child where | ||
|
||
import Parent | ||
|
||
child :: String | ||
child = "child of " ++ parent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Parent where | ||
|
||
parent :: String | ||
parent = "parent" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-- Sample Module used for testing | ||
|
||
-- This module should cause a compilation error: | ||
-- | ||
-- Sample2.hs:9:1: parse error (possibly incorrect indentation) | ||
|
||
module SampleError where | ||
|
||
a = foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Sample Module used for testing | ||
|
||
-- This module contains no errors or warnings | ||
module Sample1 where | ||
|
||
increment :: Int -> Int | ||
increment x = x + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
SOCK=`mktemp -u` | ||
|
||
$HDEVTOOLS check --socket=$SOCK Child.hs | ||
|
||
PARENT=`$HDEVTOOLS modulefile --socket=$SOCK Parent` | ||
|
||
[ "$PARENT" = "./Parent.hs" ] | ||
|
||
$HDEVTOOLS --socket=$SOCK --stop-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
ALL_TESTS="\ | ||
test_start_stop.sh \ | ||
test_simple_check.sh \ | ||
test_sample_error.sh \ | ||
test_module_file.sh \ | ||
" | ||
|
||
if [ ! $HDEVTOOLS ] | ||
then | ||
echo 'You must set the HDEVTOOLS environment variable to the path of the hdevtools binary' | ||
exit 1 | ||
fi | ||
|
||
case "$HDEVTOOLS" in | ||
*/*) | ||
# Convert relative path to absolute: | ||
export HDEVTOOLS=`pwd`/$HDEVTOOLS | ||
esac | ||
|
||
echo $HDEVTOOLS | ||
|
||
if [ $# -ne 0 ] | ||
then | ||
TESTS=$* | ||
else | ||
TESTS=$ALL_TESTS | ||
echo 'Running All Tests' | ||
fi | ||
|
||
echo '------------------------------------------------------------------------' | ||
|
||
cd `dirname $0` | ||
|
||
ERRORS=0 | ||
for i in $TESTS | ||
do | ||
echo $i | ||
echo | ||
if sh $i | ||
then | ||
echo 'Test OK' | ||
else | ||
echo 'Test FAILED' | ||
ERRORS=`expr $ERRORS + 1` | ||
fi | ||
echo '------------------------------------------------------------------------' | ||
done | ||
|
||
if [ $ERRORS = 0 ] | ||
then | ||
echo 'All Tests OK' | ||
else | ||
echo $ERRORS 'FAILED Tests' | ||
fi | ||
exit $ERRORS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
SOCK=`mktemp -u` | ||
|
||
EXPECTED_ERRORS='SampleError.hs:9:5: Not in scope: `foo'\''' | ||
|
||
if ERRORS=`$HDEVTOOLS check --socket=$SOCK SampleError.hs` | ||
then | ||
false | ||
elsh | ||
[ "$ERRORS" = "$EXPECTED_ERRORS" ] | ||
fi | ||
|
||
$HDEVTOOLS --socket=$SOCK --stop-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
SOCK=`mktemp -u` | ||
|
||
ERRORS=`$HDEVTOOLS check --socket=$SOCK Simple.hs` | ||
|
||
[ -z "$ERRORS" ] | ||
|
||
$HDEVTOOLS --socket=$SOCK --stop-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
SOCK=`mktemp -u` | ||
|
||
echo '> Starting the server' | ||
$HDEVTOOLS --socket=$SOCK --start-server | ||
|
||
echo '> Checking status' | ||
$HDEVTOOLS --socket=$SOCK --status | ||
|
||
echo '> Checking that the socket file exists' | ||
if [ ! -S $SOCK ]; then false; fi | ||
|
||
echo '> Stopping the server' | ||
$HDEVTOOLS --socket=$SOCK --stop-server | ||
|
||
echo '> Checking that the socket file no longer exists' | ||
if [ -e $SOCK ]; then false; fi |