mirror of
https://github.com/idris-lang/Idris-dev.git
synced 2024-10-05 02:18:13 +03:00
Regression test for infinite regress in executor
This test will fail if laziness doesn't prevent infinite recursion in the executor. It's implemented using `expect` instead of `timeout` in the hope that it will make life easier for non-GNU systems.
This commit is contained in:
parent
25c135233f
commit
ce414b82a6
@ -6,6 +6,8 @@ before_install:
|
||||
- sudo apt-get install -qq libghc-unordered-containers-dev libghc-mtl-dev libghc-network-dev libghc-xml-dev libghc-transformers-dev libghc-text-dev libghc-utf8-string-dev libghc-vector-dev libghc-split-dev libghc-ansi-terminal-dev libghc-ansi-wl-pprint-dev
|
||||
# trifecta dependencies
|
||||
- sudo apt-get install -qq libghc-blaze-builder-dev libghc-blaze-html-dev libghc-data-lens-dev libghc-bifunctors-dev libghc-hashable-dev libghc-semigroups-dev libghc-semigroupoids-dev libghc-parallel-dev libghc-comonad-dev libghc-terminfo-dev libghc-keys-dev
|
||||
# test dependency
|
||||
- sudo apt-get install -qq expect
|
||||
install:
|
||||
- cabal install -f FFI -f LLVM --only-dependencies --enable-tests
|
||||
before_script:
|
||||
|
2
test/reg039/expected
Normal file
2
test/reg039/expected
Normal file
@ -0,0 +1,2 @@
|
||||
Type checking ./reg039.idr
|
||||
[3, 2, 1]
|
12
test/reg039/reg039.idr
Normal file
12
test/reg039/reg039.idr
Normal file
@ -0,0 +1,12 @@
|
||||
module LazyExec
|
||||
|
||||
-- The regression that this tests for is broken laziness in the executor.
|
||||
|
||||
covering
|
||||
countdown : Int -> Lazy (List Int)
|
||||
countdown n = if n > 0
|
||||
then (n :: countdown (n-1))
|
||||
else []
|
||||
|
||||
go : IO ()
|
||||
go = putStrLn $ show (Force (countdown 3))
|
26
test/reg039/run
Executable file
26
test/reg039/run
Executable file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# From http://unix.stackexchange.com/questions/43340/how-to-introduce-timeout-for-shell-scripting
|
||||
# Executes command with a timeout
|
||||
# Params:
|
||||
# $1 timeout in seconds
|
||||
# $2 command
|
||||
# Returns 1 if timed out 0 otherwise
|
||||
timeout() {
|
||||
|
||||
time=$1
|
||||
|
||||
# start the command in a subshell to avoid problem with pipes
|
||||
# (spawn accepts one command)
|
||||
command="/bin/sh -c \"$2\""
|
||||
|
||||
expect -c "set echo \"-noecho\"; set timeout $time; spawn -noecho $command; expect timeout { exit 1 } eof { exit 0 }"
|
||||
|
||||
if [ $? = 1 ] ; then
|
||||
echo "Timeout after ${time} seconds"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
timeout 60 "idris $@ --nocolour reg039.idr --exec go"
|
||||
rm -f reg039 *.ibc
|
Loading…
Reference in New Issue
Block a user