Skip to content

Commit

Permalink
tectonic: implement passthru.tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bryango committed Dec 20, 2023
1 parent f3af548 commit 105a6b5
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
66 changes: 66 additions & 0 deletions pkgs/tools/typesetting/tectonic/tests.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# This package provides `tectonic.passthru.tests`.

{ lib
, fetchFromGitHub
, runCommand
, tectonic
, curl
, cacert
}:

let
/*
Currently, the test files are only fully available from the `dev` branch of
`biber`. If https://github.com/plk/biber/pull/467 is merged and released,
we can obtain the test files from `texlive.pkgs.biber.texsource`. For now,
we fetch the test files directly from GitHub.
*/
biber-dev-source = fetchFromGitHub {
owner = "plk";
repo = "biber";
rev = "dev";
hash = "sha256-GfNV4wbRXHn5qCYhrf3C9JPP1ArLAVSrJF+3iIJmYPI=";
};
testfiles = "${biber-dev-source}/testfiles";

notice = builtins.toFile "tectonic-offline-notice" ''
# To fetch tectonic's web bundle, the tests require internet access,
# which is not available in a build sandbox. To run the tests, try:
# `nix-build --no-sandbox --attr tectonic.passthru.tests`
'';
buildInputs = [ curl cacert tectonic ];
checkInternet = ''
if curl --head "${tectonic.TECTONIC_WEB_BUNDLE_LOCKED}"; then
: # continue to the tests defined below
else
cat "${notice}"
cp "${notice}" "$out"
exit # bail out gracefully
fi
'';

in
{
biber = runCommand "tectonic-biber-test.pdf" {
inherit buildInputs;
} ''
${checkInternet}
# import the test files
cp "${testfiles}"/* .
# tectonic caches in the $HOME directory, so set it to $PWD
export HOME=$PWD
tectonic -X compile ./test.tex
mv ./test.pdf $out
'';

workspace = runCommand "tectonic-workspace-test" {
inherit buildInputs;
} ''
${checkInternet}
tectonic -X new $out
cat $out/Tectonic.toml
'';
}
2 changes: 2 additions & 0 deletions pkgs/tools/typesetting/tectonic/wrapper.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ lib
, tectonic-unwrapped
, biber-for-tectonic
, callPackage
}:

tectonic-unwrapped.overrideAttrs (prevAttrs: {
Expand All @@ -16,6 +17,7 @@ tectonic-unwrapped.overrideAttrs (prevAttrs: {
passthru = {
unwrapped = tectonic-unwrapped;
biber = biber-for-tectonic;
tests = callPackage ./tests.nix { };
};

# tectonic runs biber when it detects it needs to run it, see:
Expand Down

0 comments on commit 105a6b5

Please sign in to comment.