about summary refs log tree commit diff
path: root/nixpkgs/pkgs/test
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-01-15 10:30:44 +0000
committerAlyssa Ross <hi@alyssa.is>2021-01-15 10:30:44 +0000
commite0794be8a0d11e90461e5a9c85012a36b93ec976 (patch)
treeefd9cbc55ea3322867bf601c4d536758a3dd5fcc /nixpkgs/pkgs/test
parent3538874082ded7647b1ccec0343c7c1e882cfef3 (diff)
parent1a57d96edd156958b12782e8c8b6a374142a7248 (diff)
downloadnixlib-e0794be8a0d11e90461e5a9c85012a36b93ec976.tar
nixlib-e0794be8a0d11e90461e5a9c85012a36b93ec976.tar.gz
nixlib-e0794be8a0d11e90461e5a9c85012a36b93ec976.tar.bz2
nixlib-e0794be8a0d11e90461e5a9c85012a36b93ec976.tar.lz
nixlib-e0794be8a0d11e90461e5a9c85012a36b93ec976.tar.xz
nixlib-e0794be8a0d11e90461e5a9c85012a36b93ec976.tar.zst
nixlib-e0794be8a0d11e90461e5a9c85012a36b93ec976.zip
Merge commit '1a57d96edd156958b12782e8c8b6a374142a7248'
Diffstat (limited to 'nixpkgs/pkgs/test')
-rw-r--r--nixpkgs/pkgs/test/default.nix8
-rw-r--r--nixpkgs/pkgs/test/haskell-documentationTarball/default.nix17
-rw-r--r--nixpkgs/pkgs/test/install-shell-files/default.nix125
-rw-r--r--nixpkgs/pkgs/test/rust-sysroot/default.nix60
-rw-r--r--nixpkgs/pkgs/test/texlive/default.nix66
5 files changed, 276 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/test/default.nix b/nixpkgs/pkgs/test/default.nix
index c248eebaec39..f45e981cff07 100644
--- a/nixpkgs/pkgs/test/default.nix
+++ b/nixpkgs/pkgs/test/default.nix
@@ -23,10 +23,13 @@ with pkgs;
   stdenv-inputs = callPackage ./stdenv-inputs { };
 
   haskell-shellFor = callPackage ./haskell-shellFor { };
+  haskell-documentationTarball = callPackage ./haskell-documentationTarball { };
 
   cc-multilib-gcc = callPackage ./cc-wrapper/multilib.nix { stdenv = gccMultiStdenv; };
   cc-multilib-clang = callPackage ./cc-wrapper/multilib.nix { stdenv = clangMultiStdenv; };
 
+  install-shell-files = callPackage ./install-shell-files {};
+
   kernel-config = callPackage ./kernel.nix {};
 
   ld-library-path = callPackage ./ld-library-path {};
@@ -35,9 +38,14 @@ with pkgs;
 
   cross = callPackage ./cross {};
 
+  rustCustomSysroot = callPackage ./rust-sysroot {};
+  buildRustCrate = callPackage ../build-support/rust/build-rust-crate/test { };
+
   nixos-functions = callPackage ./nixos-functions {};
 
   patch-shebangs = callPackage ./patch-shebangs {};
 
+  texlive = callPackage ./texlive {};
+
   writers = callPackage ../build-support/writers/test.nix {};
 }
diff --git a/nixpkgs/pkgs/test/haskell-documentationTarball/default.nix b/nixpkgs/pkgs/test/haskell-documentationTarball/default.nix
new file mode 100644
index 000000000000..aec3dc41f268
--- /dev/null
+++ b/nixpkgs/pkgs/test/haskell-documentationTarball/default.nix
@@ -0,0 +1,17 @@
+{ pkgs, haskellPackages }:
+
+let
+  drv = haskellPackages.vector;
+  docs = pkgs.haskell.lib.documentationTarball drv;
+
+in pkgs.runCommand "test haskell.lib.documentationTarball" { } ''
+  tar xvzf "${docs}/${drv.name}-docs.tar.gz"
+
+  # Check for Haddock html
+  find "${drv.name}-docs" | grep -q "Data-Vector.html"
+
+  # Check for source html
+  find "${drv.name}-docs" | grep -q  "src/Data.Vector.html"
+
+  touch "$out"
+''
diff --git a/nixpkgs/pkgs/test/install-shell-files/default.nix b/nixpkgs/pkgs/test/install-shell-files/default.nix
new file mode 100644
index 000000000000..e3729c7d2504
--- /dev/null
+++ b/nixpkgs/pkgs/test/install-shell-files/default.nix
@@ -0,0 +1,125 @@
+{ stdenv, runCommandLocal, recurseIntoAttrs, installShellFiles }:
+
+let
+  runTest = name: env: buildCommand:
+    runCommandLocal "install-shell-files--${name}" ({
+      nativeBuildInputs = [ installShellFiles ];
+      meta.platforms = stdenv.lib.platforms.all;
+    } // env) buildCommand;
+in
+
+recurseIntoAttrs {
+  # installManPage
+
+  install-manpage = runTest "install-manpage" {} ''
+    mkdir -p doc
+    echo foo > doc/foo.1
+    echo bar > doc/bar.2.gz
+    echo baz > doc/baz.3
+
+    installManPage doc/*
+
+    cmp doc/foo.1 $out/share/man/man1/foo.1
+    cmp doc/bar.2.gz $out/share/man/man2/bar.2.gz
+    cmp doc/baz.3 $out/share/man/man3/baz.3
+  '';
+  install-manpage-outputs = runTest "install-manpage-outputs" {
+    outputs = [ "out" "man" "devman" ];
+  } ''
+    mkdir -p doc
+    echo foo > doc/foo.1
+    echo bar > doc/bar.3
+
+    installManPage doc/*
+
+    # assert they didn't go into $out
+    [[ ! -f $out/share/man/man1/foo.1 && ! -f $out/share/man/man3/bar.3 ]]
+
+    # foo.1 alone went into man
+    cmp doc/foo.1 ''${!outputMan:?}/share/man/man1/foo.1
+    [[ ! -f ''${!outputMan:?}/share/man/man3/bar.3 ]]
+
+    # bar.3 alone went into devman
+    cmp doc/bar.3 ''${!outputDevman:?}/share/man/man3/bar.3
+    [[ ! -f ''${!outputDevman:?}/share/man/man1/foo.1 ]]
+
+    touch $out
+  '';
+
+  # installShellCompletion
+
+  install-completion = runTest "install-completion" {} ''
+    echo foo > foo
+    echo bar > bar
+    echo baz > baz
+    echo qux > qux.zsh
+    echo quux > quux
+
+    installShellCompletion --bash foo bar --zsh baz qux.zsh --fish quux
+
+    cmp foo $out/share/bash-completion/completions/foo
+    cmp bar $out/share/bash-completion/completions/bar
+    cmp baz $out/share/zsh/site-functions/_baz
+    cmp qux.zsh $out/share/zsh/site-functions/_qux
+    cmp quux $out/share/fish/vendor_completions.d/quux
+  '';
+  install-completion-output = runTest "install-completion-output" {
+    outputs = [ "out" "bin" ];
+  } ''
+    echo foo > foo
+
+    installShellCompletion --bash foo
+
+    # assert it didn't go into $out
+    [[ ! -f $out/share/bash-completion/completions/foo ]]
+
+    cmp foo ''${!outputBin:?}/share/bash-completion/completions/foo
+
+    touch $out
+  '';
+  install-completion-name = runTest "install-completion-name" {} ''
+    echo foo > foo
+    echo bar > bar
+    echo baz > baz
+
+    installShellCompletion --bash --name foobar.bash foo --zsh --name _foobar bar --fish baz
+
+    cmp foo $out/share/bash-completion/completions/foobar.bash
+    cmp bar $out/share/zsh/site-functions/_foobar
+    cmp baz $out/share/fish/vendor_completions.d/baz
+  '';
+  install-completion-inference = runTest "install-completion-inference" {} ''
+    echo foo > foo.bash
+    echo bar > bar.zsh
+    echo baz > baz.fish
+
+    installShellCompletion foo.bash bar.zsh baz.fish
+
+    cmp foo.bash $out/share/bash-completion/completions/foo.bash
+    cmp bar.zsh $out/share/zsh/site-functions/_bar
+    cmp baz.fish $out/share/fish/vendor_completions.d/baz.fish
+  '';
+  install-completion-cmd = runTest "install-completion-cmd" {} ''
+    echo foo > foo.bash
+    echo bar > bar.zsh
+    echo baz > baz.fish
+    echo qux > qux.fish
+
+    installShellCompletion --cmd foobar --bash foo.bash --zsh bar.zsh --fish baz.fish --name qux qux.fish
+
+    cmp foo.bash $out/share/bash-completion/completions/foobar.bash
+    cmp bar.zsh $out/share/zsh/site-functions/_foobar
+    cmp baz.fish $out/share/fish/vendor_completions.d/foobar.fish
+    cmp qux.fish $out/share/fish/vendor_completions.d/qux
+  '';
+  install-completion-fifo = runTest "install-completion-fifo" {} ''
+    installShellCompletion \
+      --bash --name foo.bash <(echo foo) \
+      --zsh --name _foo <(echo bar) \
+      --fish --name foo.fish <(echo baz)
+
+    [[ $(<$out/share/bash-completion/completions/foo.bash) == foo ]] || { echo "foo.bash comparison failed"; exit 1; }
+    [[ $(<$out/share/zsh/site-functions/_foo) == bar ]] || { echo "_foo comparison failed"; exit 1; }
+    [[ $(<$out/share/fish/vendor_completions.d/foo.fish) == baz ]] || { echo "foo.fish comparison failed"; exit 1; }
+  '';
+}
diff --git a/nixpkgs/pkgs/test/rust-sysroot/default.nix b/nixpkgs/pkgs/test/rust-sysroot/default.nix
new file mode 100644
index 000000000000..3a786ad6f00b
--- /dev/null
+++ b/nixpkgs/pkgs/test/rust-sysroot/default.nix
@@ -0,0 +1,60 @@
+{ lib, rust, rustPlatform, fetchFromGitHub }:
+
+let
+  mkBlogOsTest = target: rustPlatform.buildRustPackage rec {
+    name = "blog_os-sysroot-test";
+
+    src = fetchFromGitHub {
+        owner = "phil-opp";
+        repo = "blog_os";
+        rev = "4e38e7ddf8dd021c3cd7e4609dfa01afb827797b";
+        sha256 = "0k9ipm9ddm1bad7bs7368wzzp6xwrhyfzfpckdax54l4ffqwljcg";
+    };
+
+    cargoSha256 = "1cbcplgz28yxshyrp2krp1jphbrcqdw6wxx3rry91p7hiqyibd30";
+
+    inherit target;
+
+    RUSTFLAGS = "-C link-arg=-nostartfiles";
+
+    # Tests don't work for `no_std`. See https://os.phil-opp.com/testing/
+    doCheck = false;
+
+    meta = with lib; {
+        description = "Test for using custom sysroots with buildRustPackage";
+        maintainers = with maintainers; [ aaronjanse ];
+        platforms = lib.platforms.x86_64;
+    };
+  };
+
+  # The book uses rust-lld for linking, but rust-lld is not currently packaged for NixOS.
+  # The justification in the book for using rust-lld suggests that gcc can still be used for testing:
+  # > Instead of using the platform's default linker (which might not support Linux targets),
+  # > we use the cross platform LLD linker that is shipped with Rust for linking our kernel.
+  # https://github.com/phil-opp/blog_os/blame/7212ffaa8383122b1eb07fe1854814f99d2e1af4/blog/content/second-edition/posts/02-minimal-rust-kernel/index.md#L157
+  targetContents = {
+    "llvm-target" = "x86_64-unknown-none";
+    "data-layout" = "e-m:e-i64:64-f80:128-n8:16:32:64-S128";
+    "arch" = "x86_64";
+    "target-endian" = "little";
+    "target-pointer-width" = "64";
+    "target-c-int-width" = "32";
+    "os" = "none";
+    "executables" = true;
+    "linker-flavor" = "gcc";
+    "panic-strategy" = "abort";
+    "disable-redzone" = true;
+    "features" = "-mmx,-sse,+soft-float";
+  };
+
+in {
+  blogOS-targetByFile = mkBlogOsTest (builtins.toFile "x86_64-blog_os.json" (builtins.toJSON targetContents));
+  blogOS-targetByNix = let
+    plat = lib.systems.elaborate { config = "x86_64-none"; } // {
+      rustc = {
+        config = "x86_64-blog_os";
+        platform = targetContents;
+      };
+    };
+    in mkBlogOsTest (rust.toRustTargetSpec plat);
+}
diff --git a/nixpkgs/pkgs/test/texlive/default.nix b/nixpkgs/pkgs/test/texlive/default.nix
new file mode 100644
index 000000000000..30d0026c848d
--- /dev/null
+++ b/nixpkgs/pkgs/test/texlive/default.nix
@@ -0,0 +1,66 @@
+{ runCommandNoCC, fetchurl, file, texlive }:
+
+{
+  chktex = runCommandNoCC "texlive-test-chktex" {
+    nativeBuildInputs = [
+      (with texlive; combine { inherit scheme-infraonly chktex; })
+    ];
+    input = builtins.toFile "chktex-sample.tex" ''
+      \documentclass{article}
+      \begin{document}
+        \LaTeX is great
+      \end{document}
+    '';
+  } ''
+    chktex -v -nall -w1 "$input" 2>&1 | tee "$out"
+    grep "One warning printed" "$out"
+  '';
+
+  # https://github.com/NixOS/nixpkgs/issues/75605
+  dvipng = runCommandNoCC "texlive-test-dvipng" {
+    nativeBuildInputs = [ file texlive.combined.scheme-medium ];
+    input = fetchurl {
+      name = "test_dvipng.tex";
+      url = "http://git.savannah.nongnu.org/cgit/dvipng.git/plain/test_dvipng.tex?id=b872753590a18605260078f56cbd6f28d39dc035";
+      sha256 = "1pjpf1jvwj2pv5crzdgcrzvbmn7kfmgxa39pcvskl4pa0c9hl88n";
+    };
+  } ''
+    cp "$input" ./document.tex
+
+    latex document.tex
+    dvipng -T tight -strict -picky document.dvi
+    for f in document*.png; do
+      file "$f" | tee output
+      grep PNG output
+    done
+
+    mkdir "$out"
+    mv document*.png "$out"/
+  '';
+
+  # https://github.com/NixOS/nixpkgs/issues/75070
+  dvisvgm = runCommandNoCC "texlive-test-dvisvgm" {
+    nativeBuildInputs = [ file texlive.combined.scheme-medium ];
+    input = builtins.toFile "dvisvgm-sample.tex" ''
+      \documentclass{article}
+      \begin{document}
+        mwe
+      \end{document}
+    '';
+  } ''
+    cp "$input" ./document.tex
+
+    latex document.tex
+    dvisvgm document.dvi -n -o document_dvi.svg
+    cat document_dvi.svg
+    file document_dvi.svg | grep SVG
+
+    pdflatex document.tex
+    dvisvgm -P document.pdf -n -o document_pdf.svg
+    cat document_pdf.svg
+    file document_pdf.svg | grep SVG
+
+    mkdir "$out"
+    mv document*.svg "$out"/
+  '';
+}