mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
octavePackages.buildOctavePackage: add env, nativeBuildInputs args for pkg test
This commit is contained in:
parent
be7cfa781b
commit
4398adf72e
4 changed files with 29 additions and 2 deletions
|
|
@ -76,6 +76,17 @@ See [Symbolic](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/oct
|
|||
`requiredOctavePackages`
|
||||
: This is a special dependency that ensures the specified Octave packages are dependent on others, and are made available simultaneously when loading them in Octave.
|
||||
|
||||
### Testing Octave packages {#sssec-testing-octave-packages}
|
||||
|
||||
Octave packages built using the `buildOctavePackage` function do not have a `checkPhase` or `installCheckPhase`.
|
||||
Instead, the tests `testOctaveBuildEnv` and `testOctavePkgTests` are added to the package's `passthru.tests`.
|
||||
|
||||
`passthru.tests.testOctaveBuildEnv` tests whether the package can be used by `octave.withPackages` successfully.
|
||||
|
||||
`passthru.tests.testOctavePkgTests` runs a `pkg test` command for the package.
|
||||
If the package needs additional inputs to successfully run the tests, the `nativeOctavePkgTestInputs` attribute can be specified.
|
||||
If the package needs environment variables to be set to successfully run the tests, ensure that `__structuredAttrs = true;` in the package, then set the environment variables you need in `octavePkgTestEnv` (which should be an attrset where the key is the name of the variable and the value is its value (as a string)).
|
||||
|
||||
### Installing Octave Packages {#sssec-installing-octave-packages}
|
||||
|
||||
By default, the `buildOctavePackage` function does _not_ install the requested package into Octave for use.
|
||||
|
|
|
|||
|
|
@ -695,6 +695,9 @@
|
|||
"footnote-stdenv-find-inputs-location.__back.0": [
|
||||
"index.html#footnote-stdenv-find-inputs-location.__back.0"
|
||||
],
|
||||
"sssec-testing-octave-packages": [
|
||||
"index.html#sssec-testing-octave-packages"
|
||||
],
|
||||
"strictflexarrays1": [
|
||||
"index.html#strictflexarrays1"
|
||||
],
|
||||
|
|
|
|||
|
|
@ -46,6 +46,11 @@
|
|||
# requiredOctavePackages are ALSO installed into octave.
|
||||
requiredOctavePackages ? [ ],
|
||||
|
||||
# Dependencies and `env` for octave package tests,
|
||||
# which are run with .passthru.tests.testOctavePkgTests
|
||||
nativeOctavePkgTestInputs ? [ ],
|
||||
octavePkgTestEnv ? { },
|
||||
|
||||
preBuild ? "",
|
||||
|
||||
meta ? { },
|
||||
|
|
@ -74,6 +79,7 @@ let
|
|||
# itself, causing everything to fail.
|
||||
attrs' = removeAttrs attrs [
|
||||
"nativeBuildInputs"
|
||||
"nativeOctavePkgTestInputs"
|
||||
"passthru"
|
||||
];
|
||||
in
|
||||
|
|
@ -143,7 +149,9 @@ stdenv.mkDerivation (
|
|||
testOctaveBuildEnv = (octave.withPackages (os: [ finalAttrs.finalPackage ])).overrideAttrs (old: {
|
||||
name = "${finalAttrs.name}-pkg-install";
|
||||
});
|
||||
testOctavePkgTests = callPackage ./run-pkg-test.nix { } finalAttrs.finalPackage;
|
||||
testOctavePkgTests = callPackage ./run-pkg-test.nix {
|
||||
inherit nativeOctavePkgTestInputs octavePkgTestEnv;
|
||||
} finalAttrs.finalPackage;
|
||||
}
|
||||
// passthru.tests or { };
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
{
|
||||
octave,
|
||||
runCommand,
|
||||
nativeOctavePkgTestInputs,
|
||||
octavePkgTestEnv,
|
||||
}:
|
||||
package:
|
||||
|
||||
|
|
@ -8,7 +10,10 @@ runCommand "${package.name}-pkg-test"
|
|||
{
|
||||
nativeBuildInputs = [
|
||||
(octave.withPackages (os: [ package ]))
|
||||
];
|
||||
]
|
||||
++ nativeOctavePkgTestInputs;
|
||||
|
||||
env = octavePkgTestEnv;
|
||||
}
|
||||
''
|
||||
{ octave-cli --eval 'pkg test ${package.pname}' || touch FAILED_ERRCODE; } \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue