Skip to content

Commit

Permalink
Problem: raco test <directory> mkdirs $HOME
Browse files Browse the repository at this point in the history
This breaks when you're running inside a Nix derivation.

Solution: Discover each *.rkt file ourselves, and run raco test on one at a time.

Also discovered that raco test on anything requiring (gui/*) expects
to talk to X, and crashes. Filter those out.
  • Loading branch information
clacke committed Aug 15, 2018
1 parent 705b03e commit 60eb8f1
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ pkgs {
};

# fractalide/racket2nix#78 workaround
# I considered just flattening, but fractalide/racket2nix#156

# This simple addition works because fractalide happens to depend on all of
# compiler-lib's dependencies (because it happens to depend on compiler-lib).
Expand All @@ -59,10 +58,27 @@ pkgs {
racketBuildInputs = builtins.filter (input: input.name != "compiler-lib") oldAttrs.racketBuildInputs;
});

fractalide-tests = self.runCommand "fractalide-tests" {
buildInputs = [ fractalide-tests-pkg.env ];
fractalide-tests = let
# parallel cannot quite handle full inline bash, and destroys quoting, so we can't use bash -c

racoTest = builtins.toFile "raco-test.sh" ''
racket -l- raco test "$@" |&
grep -v -e "warning: tool .* registered twice" -e "@[(]test-responsible"
exit ''${PIPESTATUS[0]}
'';
in self.runCommand "fractalide-tests" {
buildInputs = [ fractalide-tests-pkg.env self.parallel ];
inherit racoTest;
} ''
racket -l- raco test ${fractalide-tests-pkg.env}/share/racket/pkgs/*/modules/rkt/rkt-fbp/agents
# If we do raco test <directory> the discovery process will try to mkdir $HOME.
# If we allow raco test to run on anything in agents/gui it will fail because
# requiring gui fails on headless.
find ${fractalide-tests-pkg.env}/share/racket/pkgs/*/modules/rkt/rkt-fbp/agents \
'(' -name gui -prune ')' -o '(' -name '*.rkt' -print ')' |
parallel -n 1 -j ''${NIX_BUILD_CORES:-1} bash $racoTest |
tee $out
exit ''${PIPESTATUS[1]}
'';
})
];
Expand Down

0 comments on commit 60eb8f1

Please sign in to comment.