[ repl ] don't exit early on error
This commit is contained in:
@@ -20,12 +20,16 @@ for fn in tests/*.newt ; do
|
||||
echo "Compile failure mismatch for $fn"
|
||||
diff ${fn}.fail tmp/${bn}.compile
|
||||
failed=$((failed + 1))
|
||||
if [ $1 = "--fix" ]; then
|
||||
cp tmp/${bn}.compile ${fn}.fail
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
elif [ $cerr != "0" ]; then
|
||||
echo Compile failed for $fn
|
||||
failed=$((failed + 1))
|
||||
cat tmp/${bn}.compile
|
||||
|
||||
continue
|
||||
fi
|
||||
# if there is a golden file, run the code and compare output
|
||||
@@ -40,6 +44,9 @@ for fn in tests/*.newt ; do
|
||||
echo "Output mismatch for $fn"
|
||||
diff ${fn}.golden tmp/${bn}.out
|
||||
failed=$((failed + 1))
|
||||
if [ $1 = "--fix" ]; then
|
||||
cp tmp/${bn}.out ${fn}.golden
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -54,8 +54,7 @@ writeSource fn = do
|
||||
:: Nil)
|
||||
++ map (render 90 ∘ noAlt) docs
|
||||
(Right _) <- liftIO {M} $ writeFile fn src
|
||||
| Left err => exitFailure (show err)
|
||||
-- (Right _) <- chmodRaw fn 493 | Left err => exitFailure (show err)
|
||||
| Left err => throwError $ E (MkFC fn $ MkBounds 0 0 0 0) err
|
||||
pure MkUnit
|
||||
|
||||
|
||||
@@ -105,22 +104,22 @@ processModule importFC base stk qn@(QN ns nm) = do
|
||||
modifyTop [modules := updateMap modns (emptyModCtx "") top.modules]
|
||||
let fn = (joinBy "/" (base :: ns)) ++ "/" ++ nm ++ ".newt"
|
||||
(Right src) <- liftIO {M} $ readFile fn
|
||||
| Left err => exitFailure "ERROR at \{show importFC}: error reading \{fn}: \{show err}"
|
||||
| Left err => throwError $ E importFC "error reading \{fn}: \{show err}"
|
||||
let (Right toks) = tokenise fn src
|
||||
| Left err => exitFailure (showError src err)
|
||||
| Left err => throwError err
|
||||
|
||||
let (Right ((nameFC, modName), ops, toks)) = partialParse fn parseModHeader top.ops toks
|
||||
| Left (err, toks) => exitFailure (showError src err)
|
||||
| Left (err, toks) => throwError err
|
||||
|
||||
log 1 $ \ _ => "scan imports for module \{modName}"
|
||||
let ns = split modName "."
|
||||
let (path, modName') = unsnoc $ split1 modName "."
|
||||
-- let bparts = split base "/"
|
||||
let (True) = qn == QN path modName'
|
||||
| _ => exitFailure "ERROR at \{show nameFC}: module name \{show modName} doesn't match file name \{show fn}"
|
||||
| _ => throwError $ E nameFC "module name \{show modName} doesn't match file name \{show fn}"
|
||||
|
||||
let (Right (imports, ops, toks)) = partialParse fn parseImports ops toks
|
||||
| Left (err, toks) => exitFailure (showError src err)
|
||||
| Left (err, toks) => throwError err
|
||||
|
||||
let importNames = map importToQN imports
|
||||
|
||||
@@ -176,7 +175,7 @@ processModule importFC base stk qn@(QN ns nm) = do
|
||||
|
||||
logMetas $ reverse $ listValues top.metaCtx.metas
|
||||
let (Nil) = top.errors
|
||||
| errors => exitFailure "Compile failed"
|
||||
| errors => throwError $ E importFC "Failed to compile module \{show qn}"
|
||||
pure src
|
||||
where
|
||||
tryProcessDecl : String -> List String → Decl -> M Unit
|
||||
@@ -200,7 +199,7 @@ showErrors fn src = do
|
||||
let (Nil) = top.errors
|
||||
| errors => do
|
||||
traverse (putStrLn ∘ showError src) errors
|
||||
exitFailure "Compile failed"
|
||||
throwError $ E (MkFC fn $ MkBounds 0 0 0 0) "Compile failed"
|
||||
pure MkUnit
|
||||
|
||||
invalidateModule : QName -> M Unit
|
||||
|
||||
@@ -7,4 +7,4 @@ ERROR at tests/BadAlt.newt:6:6--6:13: Prelude._:<_ not a constructor for (Prelud
|
||||
foo (xs :< x) = x
|
||||
^^^^^^^
|
||||
|
||||
Compile failed
|
||||
ERROR at :1:1--1:2: Failed to compile module BadAlt
|
||||
|
||||
@@ -6,4 +6,4 @@ ERROR at tests/Duplicate.newt:4:1--4:5: Duplicate.Left is already defined at tes
|
||||
data Either : U -> U -> U where
|
||||
^^^^
|
||||
|
||||
Compile failed
|
||||
ERROR at :1:1--1:2: Failed to compile module Duplicate
|
||||
|
||||
@@ -3,4 +3,4 @@ module Prelude
|
||||
module ErrMsg2
|
||||
ERROR at tests/ErrMsg2.newt:6:13--6:15: Expected '=>' at Keyword:->
|
||||
|
||||
Compile failed
|
||||
ERROR at :1:1--1:2: Failed to compile module ErrMsg2
|
||||
|
||||
@@ -18,4 +18,4 @@ ERROR at tests/ErrorDup.newt:9:7--9:10: Nat already declared
|
||||
class Nat where
|
||||
^^^
|
||||
|
||||
Compile failed
|
||||
ERROR at :1:1--1:2: Failed to compile module ErrorDup
|
||||
|
||||
@@ -6,4 +6,4 @@ ERROR at tests/LitConCase.newt:7:5--7:11: expected Prim.Int
|
||||
foo MkUnit = MkUnit
|
||||
^^^^^^
|
||||
|
||||
Compile failed
|
||||
ERROR at :1:1--1:2: Failed to compile module LitConCase
|
||||
|
||||
@@ -7,4 +7,4 @@ ERROR at tests/Possible.newt:6:5--6:8: possible constructors: [Prelude.Z, Prelud
|
||||
foo ()
|
||||
^^^
|
||||
|
||||
Compile failed
|
||||
ERROR at :1:1--1:2: Failed to compile module Possible
|
||||
|
||||
@@ -7,4 +7,4 @@ ERROR at tests/Quantity.newt:11:15--11:16: used erased value x$0 (FIXME FC may b
|
||||
bar {x} = foo x
|
||||
^
|
||||
|
||||
Compile failed
|
||||
ERROR at :1:1--1:2: Failed to compile module Quantity
|
||||
|
||||
Reference in New Issue
Block a user