factor: add hello-world test
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
# Builds hello-world Factor application using buildFactorApplication & verifies
|
||||
# source-to-binary that the resulting app prints "Hello, $NAME" depending on
|
||||
# `--name` flag.
|
||||
{
|
||||
lib,
|
||||
runCommandLocal,
|
||||
buildFactorApplication,
|
||||
buildFactorVocab,
|
||||
}:
|
||||
|
||||
let
|
||||
fs = lib.fileset;
|
||||
|
||||
factorFilter =
|
||||
file:
|
||||
lib.lists.any file.hasExt [
|
||||
"factor"
|
||||
"txt"
|
||||
];
|
||||
|
||||
version = "0-test";
|
||||
|
||||
vocab = buildFactorVocab {
|
||||
inherit version;
|
||||
pname = "hello";
|
||||
src = fs.toSource {
|
||||
root = ./extra;
|
||||
fileset = fs.difference (fs.fileFilter factorFilter ./extra/hello) ./extra/hello/cli;
|
||||
};
|
||||
vocabName = "hello";
|
||||
};
|
||||
|
||||
app = buildFactorApplication {
|
||||
inherit version;
|
||||
pname = "hello-cli";
|
||||
src = fs.toSource {
|
||||
root = ./extra;
|
||||
fileset = fs.fileFilter factorFilter ./extra/hello/cli;
|
||||
};
|
||||
vocabName = "hello.cli";
|
||||
binName = "hello";
|
||||
extraVocabs = [ vocab ];
|
||||
};
|
||||
in
|
||||
runCommandLocal "assert-factor-hello-world"
|
||||
{
|
||||
env.expected = "Hello, Nixpkgs";
|
||||
}
|
||||
''
|
||||
output="$(${lib.getExe app} --name "Nixpkgs")"
|
||||
if [ "$output" != "$expected" ]; then
|
||||
echo "FAIL: expected “$expected”; got “$output”" >&2
|
||||
exit 1
|
||||
fi
|
||||
touch "$out"
|
||||
''
|
||||
@@ -0,0 +1 @@
|
||||
toastal
|
||||
@@ -0,0 +1 @@
|
||||
toastal
|
||||
@@ -0,0 +1,13 @@
|
||||
! SPDX-License-Identifier: 0BSD
|
||||
USING: command-line combinators io kernel namespaces sequences hello ;
|
||||
|
||||
IN: hello.cli
|
||||
|
||||
: main ( -- )
|
||||
command-line get {
|
||||
{ [ dup empty? ] [ drop "world" ] }
|
||||
{ [ dup first "--name" = not ] [ drop "world" ] }
|
||||
[ second ]
|
||||
} cond greet ;
|
||||
|
||||
MAIN: main
|
||||
@@ -0,0 +1,7 @@
|
||||
! SPDX-License-Identifier: 0BSD
|
||||
USING: io namespaces sequences ;
|
||||
|
||||
IN: hello
|
||||
|
||||
: greet ( name -- )
|
||||
"Hello, " prepend print ;
|
||||
@@ -2,6 +2,9 @@
|
||||
lib,
|
||||
stdenv,
|
||||
makeWrapper,
|
||||
runCommandLocal,
|
||||
buildFactorApplication,
|
||||
buildFactorVocab,
|
||||
buildEnv,
|
||||
copyDesktopItems,
|
||||
makeDesktopItem,
|
||||
@@ -220,6 +223,16 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
extraVocabs
|
||||
vocabTree
|
||||
;
|
||||
tests = {
|
||||
hello-world = import ./test/hello-world {
|
||||
inherit
|
||||
lib
|
||||
runCommandLocal
|
||||
buildFactorApplication
|
||||
buildFactorVocab
|
||||
;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
meta = factor-unwrapped.meta // {
|
||||
|
||||
Reference in New Issue
Block a user