<pkg>.passthru.tests
is the place for test cases for a package in the form of a derivation set, and some of them test the binary functionality of the package. In terms of dependency platforms, they are the reverse-nativeBuildInputs
of this package.
For example, we may add a test case for pkgs.hello
that tests the execution of
set -eu -o pipefail
HELLO_OUTPUT="$(hello)"
[[ "$HELLO_OUTPUT" == "Hello,world!" ]]
When buildPlatform == hostPlatform
, it could be
{ lib
, stdenv
, runCommandLocal
, ...
}:
stdenv.mkDerivation (finalAttrs: {
# ...
passthru.tests.run = runCommandLocal "test-hello-run" {
nativeBuildInputs = [ finalAttrs.finalPackage ];
} ''
set -eu -o pipefail
HELLO_OUTPUT="$(hello)"
[[ "$HELLO_OUTPUT" == "Hello,world!" ]]
'';
})
How should it be when we consider the situation of cross compilation?