Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 52 additions & 39 deletions e2e/bats/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,60 @@
, use_ic_ref ? false
}:
let
e2e = lib.noNixFiles (lib.gitOnlySource ../../. ./.);
lib = pkgs.lib;
sources = pkgs.sources;
inherit (pkgs) lib;

inputs = with pkgs; [
bats
bash
coreutils
diffutils
curl
findutils
gnugrep
gnutar
gzip
jq
netcat
ps
python3
procps
which
dfx.standalone
] ++ lib.optional use_ic_ref ic-ref;
in
isBatsTest = fileName: type: lib.hasSuffix ".bash" fileName && type == "regular";

builtins.derivation {
name = "e2e-tests";
system = pkgs.stdenv.system;
PATH = pkgs.lib.makeSearchPath "bin" inputs;
BATSLIB = sources.bats-support;
builder =
pkgs.writeScript "builder.sh" ''
#!${pkgs.stdenv.shell}
set -eo pipefail
here = ./.;

# We want $HOME/.cache to be in a new temporary directory.
export HOME=$(mktemp -d -t dfx-e2e-home-XXXX)
mkBatsTest = fileName:
let
name = lib.removeSuffix ".bash" fileName;
in
lib.nameValuePair name (
pkgs.runCommandNoCC "e2e-test-${name}${lib.optionalString use_ic_ref "-use_ic_ref"}" {
nativeBuildInputs = with pkgs; [
bats
diffutils
curl
findutils
gnugrep
gnutar
gzip
jq
netcat
ps
python3
procps
which
dfx.standalone
] ++ lib.optional use_ic_ref ic-ref;
BATSLIB = pkgs.sources.bats-support;
USE_IC_REF = use_ic_ref;
utils = lib.gitOnlySource ../../. ./utils;
assets = lib.gitOnlySource ../../. ./assets;
test = here + "/${fileName}";
} ''
export HOME=$(pwd)

export USE_IC_REF=${if use_ic_ref then "1" else ""}
ln -s $utils utils
ln -s $assets assets
ln -s $test test

# Timeout of 10 minutes is enough for now. Reminder; CI might be running with
# less resources than a dev's computer, so e2e might take longer.
timeout --preserve-status 3600 bats --recursive ${e2e}/* | tee $out
'';
} // { meta = {}; }
# Timeout of 10 minutes is enough for now. Reminder; CI might be running with
# less resources than a dev's computer, so e2e might take longer.
timeout --preserve-status 3600 bats test | tee $out
''
);
in
builtins.listToAttrs
(
builtins.map mkBatsTest
(
lib.attrNames
(
lib.filterAttrs isBatsTest
(builtins.readDir here)
)
)
)