mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
tcl.tclRequiresCheckHook: init (#500462)
This commit is contained in:
commit
6384aa87d2
9 changed files with 86 additions and 4 deletions
|
|
@ -52,3 +52,35 @@ Its use is documented in `pkgs/development/tcl-modules/by-name/README.md`.
|
|||
|
||||
All Tcl applications reside elsewhere.
|
||||
In case a package is used as both a library and an application (for example `expect`), it should be defined in `tcl-packages.nix`, with an alias elsewhere.
|
||||
|
||||
### Using tclRequiresCheck {#using-tclrequirescheck}
|
||||
|
||||
Although unit tests are highly preferred to validate correctness of a package, not
|
||||
all packages have test suites that can be run easily, and some have none at all.
|
||||
To help ensure the package still works, [`tclRequiresCheck`](#using-tclrequirescheck) can attempt to `package require`
|
||||
the listed modules.
|
||||
|
||||
```nix
|
||||
{
|
||||
tclRequiresCheck = [
|
||||
"json"
|
||||
"doctools"
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
roughly translates to:
|
||||
|
||||
```nix
|
||||
{
|
||||
preDist = ''
|
||||
TCLLIBPATH="$out/lib $TCLLIBPATH"
|
||||
tclsh <<<'exit [catch {package require json; package require doctools}]'
|
||||
'';
|
||||
}
|
||||
```
|
||||
|
||||
However, this is done in its own phase, and not dependent on whether [`doCheck = true;`](#var-stdenv-doCheck).
|
||||
|
||||
This can also be useful in verifying that the package doesn't assume commonly
|
||||
present packages (e.g. `tcllib`).
|
||||
|
|
|
|||
|
|
@ -755,6 +755,9 @@
|
|||
"typst-package-scope-and-usage": [
|
||||
"index.html#typst-package-scope-and-usage"
|
||||
],
|
||||
"using-tclrequirescheck": [
|
||||
"index.html#using-tclrequirescheck"
|
||||
],
|
||||
"var-go-buildTestBinaries": [
|
||||
"index.html#var-go-buildTestBinaries"
|
||||
],
|
||||
|
|
|
|||
|
|
@ -142,6 +142,16 @@ let
|
|||
};
|
||||
} ./tcl-package-hook.sh
|
||||
) { };
|
||||
tclRequiresCheckHook = callPackage (
|
||||
{ buildPackages }:
|
||||
makeSetupHook {
|
||||
name = "tcl-requires-check-hook";
|
||||
propagatedBuildInputs = [ buildPackages.makeBinaryWrapper ];
|
||||
meta = {
|
||||
inherit (meta) maintainers platforms;
|
||||
};
|
||||
} ./tcl-requires-check-hook.sh
|
||||
) { };
|
||||
# verify that Tcl's clock library can access tzdata
|
||||
tests.tzdata = runCommand "${pname}-test-tzdata" { } ''
|
||||
${baseInterp}/bin/tclsh <(echo "set t [clock scan {2004-10-30 05:00:00} \
|
||||
|
|
|
|||
|
|
@ -53,10 +53,15 @@ let
|
|||
// {
|
||||
|
||||
buildInputs = buildInputs ++ [ tcl.tclPackageHook ];
|
||||
nativeBuildInputs = nativeBuildInputs ++ [
|
||||
makeWrapper
|
||||
tcl
|
||||
];
|
||||
nativeBuildInputs =
|
||||
nativeBuildInputs
|
||||
++ [
|
||||
makeWrapper
|
||||
tcl
|
||||
]
|
||||
++ lib.optionals (stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
|
||||
tcl.tclRequiresCheckHook
|
||||
];
|
||||
propagatedBuildInputs = propagatedBuildInputs ++ [ tcl ];
|
||||
|
||||
env = {
|
||||
|
|
|
|||
17
pkgs/development/interpreters/tcl/tcl-requires-check-hook.sh
Normal file
17
pkgs/development/interpreters/tcl/tcl-requires-check-hook.sh
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Setup hook for checking whether Tcl requires succeed
|
||||
echo "Sourcing tcl-requires-check-hook.sh"
|
||||
|
||||
tclRequiresCheckPhase () {
|
||||
echo "Executing tclRequiresCheckPhase"
|
||||
|
||||
if [ -n "$tclRequiresCheck" ]; then
|
||||
echo "Check whether the following packages can be required: $tclRequiresCheck"
|
||||
export TCLLIBPATH="$out/lib $TCLLIBPATH" # Redundant if tcl-package-hook is also used
|
||||
tclsh <<<'exit [catch {foreach req $env(tclRequiresCheck) {package require $req}}]'
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -z "${dontUseTclRequiresCheck-}" ]; then
|
||||
echo "Using tclRequiresCheckPhase"
|
||||
preDistPhases+=" tclRequiresCheckPhase"
|
||||
fi
|
||||
|
|
@ -62,6 +62,8 @@ tcl.mkTclDerivation rec {
|
|||
${lib.optionalString stdenv.hostPlatform.isDarwin "tclWrapperArgs+=(--prefix DYLD_LIBRARY_PATH : $out/lib/expect${version})"}
|
||||
'';
|
||||
|
||||
tclRequiresCheck = [ "Expect" ];
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"dev"
|
||||
|
|
|
|||
|
|
@ -19,6 +19,15 @@ mkTclDerivation rec {
|
|||
|
||||
buildFlags = [ "all" ] ++ lib.optional withCritcl "critcl";
|
||||
|
||||
# Tcllib contains a huge amount of Tcl packages:
|
||||
# https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/toc.md
|
||||
# We sample a small amount of popular ones.
|
||||
tclRequiresCheck = [
|
||||
"struct::graph"
|
||||
"doctools"
|
||||
"json"
|
||||
];
|
||||
|
||||
meta = {
|
||||
homepage = "https://core.tcl-lang.org/tcllib/";
|
||||
description = "Tcl-only library of standard routines for Tcl";
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ mkTclDerivation rec {
|
|||
done
|
||||
'';
|
||||
|
||||
tclRequiresCheck = [ "tclreadline" ];
|
||||
|
||||
meta = {
|
||||
description = "GNU readline for interactive tcl shells";
|
||||
homepage = "https://github.com/flightaware/tclreadline";
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ mkTclDerivation rec {
|
|||
"--with-ssl-dir=${openssl.dev}"
|
||||
];
|
||||
|
||||
tclRequiresCheck = [ "tls" ];
|
||||
|
||||
meta = {
|
||||
homepage = "https://core.tcl-lang.org/tcltls/index";
|
||||
description = "OpenSSL / RSA-bsafe Tcl extension";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue