Incorporate suggestions
- land `HelloWorld.agda` and `TrivialBackend.hs` in files - replace `runCommand` by `stdenvNoCC.mkDerivation` - refactor asserts
This commit is contained in:
5
nixos/tests/agda/files/HelloWorld.agda
Normal file
5
nixos/tests/agda/files/HelloWorld.agda
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{-# OPTIONS --guardedness #-}
|
||||||
|
open import IO
|
||||||
|
open import Level
|
||||||
|
|
||||||
|
main = run {0ℓ} (putStrLn "Hello World!")
|
||||||
6
nixos/tests/agda/files/TrivialBackend.hs
Normal file
6
nixos/tests/agda/files/TrivialBackend.hs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
module Main where
|
||||||
|
|
||||||
|
import Agda.Main ( runAgda )
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = runAgda []
|
||||||
@@ -2,34 +2,25 @@
|
|||||||
let
|
let
|
||||||
mainProgram = "agda-trivial-backend";
|
mainProgram = "agda-trivial-backend";
|
||||||
|
|
||||||
hello-world = pkgs.writeText "hello-world" ''
|
hello-world = ./files/HelloWorld.agda;
|
||||||
{-# OPTIONS --guardedness #-}
|
|
||||||
open import IO
|
|
||||||
open import Level
|
|
||||||
|
|
||||||
main = run {0ℓ} (putStrLn "Hello World!")
|
agda-trivial-backend = pkgs.stdenvNoCC.mkDerivation {
|
||||||
'';
|
name = "trivial-backend";
|
||||||
agda-trivial-backend =
|
meta = { inherit mainProgram; };
|
||||||
pkgs.runCommand "trivial-backend"
|
version = "${pkgs.haskellPackages.Agda.version}";
|
||||||
{
|
src = ./files/TrivialBackend.hs;
|
||||||
version = "${pkgs.haskellPackages.Agda.version}";
|
buildInputs = [
|
||||||
meta.mainProgram = "${mainProgram}";
|
(pkgs.haskellPackages.ghcWithPackages (pkgs: [ pkgs.Agda ]))
|
||||||
buildInputs = [ (pkgs.haskellPackages.ghcWithPackages (pkgs: [ pkgs.Agda ])) ];
|
];
|
||||||
}
|
dontUnpack = true;
|
||||||
''
|
buildPhase = ''
|
||||||
cat << EOF > Main.hs
|
ghc $src -o ${mainProgram}
|
||||||
module Main where
|
'';
|
||||||
|
installPhase = ''
|
||||||
import Agda.Main ( runAgda )
|
mkdir -p $out/bin
|
||||||
|
cp ${mainProgram} $out/bin
|
||||||
main :: IO ()
|
'';
|
||||||
main = runAgda []
|
};
|
||||||
EOF
|
|
||||||
|
|
||||||
ghc Main.hs -o ${mainProgram}
|
|
||||||
mkdir -p $out/bin
|
|
||||||
cp ${mainProgram} $out/bin
|
|
||||||
'';
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
name = "agda-trivial-backend";
|
name = "agda-trivial-backend";
|
||||||
@@ -58,14 +49,16 @@ in
|
|||||||
testScript = ''
|
testScript = ''
|
||||||
# agda executable is not present
|
# agda executable is not present
|
||||||
machine.fail("agda --version")
|
machine.fail("agda --version")
|
||||||
|
# backend is present
|
||||||
|
text = machine.succeed("${mainProgram} --help")
|
||||||
|
assert "${mainProgram}" in text
|
||||||
# Hello world
|
# Hello world
|
||||||
machine.succeed(
|
machine.succeed(
|
||||||
"cp ${hello-world} HelloWorld.agda"
|
"cp ${hello-world} HelloWorld.agda"
|
||||||
)
|
)
|
||||||
machine.succeed("${mainProgram} -l standard-library -i . -c HelloWorld.agda")
|
machine.succeed("${mainProgram} -l standard-library -i . -c HelloWorld.agda")
|
||||||
# Check execution
|
# Check execution
|
||||||
assert "Hello World!" in machine.succeed(
|
text = machine.succeed("./HelloWorld")
|
||||||
"./HelloWorld"
|
assert "Hello World!" in text, f"HelloWorld does not run properly: output was {text}"
|
||||||
), "HelloWorld does not run properly"
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user