git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #154021 from lukegb/mercurialfull

mercurial: move tests to passthru.tests

commitbf2930306f8425761a641bf91fdb967dcfaf4b4e authorLuke Granger-Brown <git@lukegb.com> dateSat 8 Jan 2022, 16:36 (5 years ago) parentfae9012d69abfe
1 file changed+65−35
pkgs/applications/version-management/mercurial/default.nix+65−35
pkgs/applications/version-management/mercurial/default.nix+65−35
@@ -7,6 +7,7 @@
77, highlightSupport ? fullBuild
88, ApplicationServices
99# test dependencies
10+, runCommand
1011, unzip
1112, which
1213, sqlite
@@ -39,15 +40,6 @@ let
3940 } else null;
4041 cargoRoot = if rustSupport then "rust" else null;
4142
42− postPatch = ''
43− patchShebangs .
44−
45− for f in **/*.{py,c,t}; do
46− # not only used in shebangs
47− substituteAllInPlace "$f" '/bin/sh' '${stdenv.shell}'
48− done
49− '';
50−
5143 propagatedBuildInputs = lib.optional re2Support fb-re2
5244 ++ lib.optional gitSupport pygit2
5345 ++ lib.optional highlightSupport pygments;
@@ -63,31 +55,6 @@ let
6355 makeFlags = [ "PREFIX=$(out)" ]
6456 ++ lib.optional rustSupport "PURE=--rust";
6557
66− doCheck = stdenv.isLinux; # tests seem unstable on Darwin
67− checkInputs = [
68− unzip
69− which
70− sqlite
71− git
72− gnupg
73− ];
74− SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt"; # needed for git
75− checkPhase = ''
76− cat << EOF > tests/blacklists/nix
77− # tests enforcing "/usr/bin/env" shebangs, which are patched for nix
78− test-run-tests.t
79− test-check-shbang.t
80−
81− # unstable experimental/unsupported features
82− # https://bz.mercurial-scm.org/show_bug.cgi?id=6633#c1
83− test-git-interop.t
84− EOF
85−
86− # extended timeout necessary for tests to pass on the busy CI workers
87− export HGTESTFLAGS="--blacklist blacklists/nix --timeout 1800"
88− make check
89− '';
90−
9158 postInstall = (lib.optionalString guiSupport ''
9259 mkdir -p $out/etc/mercurial
9360 cp contrib/hgk $out/bin
@@ -115,7 +82,9 @@ let
11582 --zsh contrib/zsh_completion
11683 '';
11784
118− passthru.tests = {};
85+ passthru.tests = {
86+ mercurial-tests = makeTests { flags = "--with-hg=$MERCURIAL_BASE/bin/hg"; };
87+ };
11988
12089 meta = with lib; {
12190 description = "A fast, lightweight SCM system for very large distributed projects";
@@ -127,6 +96,67 @@ let
12796 platforms = platforms.unix;
12897 };
12998 };
99+
100+ makeTests = { mercurial ? self, nameSuffix ? "", flags ? "" }: runCommand "${mercurial.pname}${nameSuffix}-tests" {
101+ inherit (mercurial) src;
102+
103+ SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt"; # needed for git
104+ MERCURIAL_BASE = mercurial;
105+ nativeBuildInputs = [
106+ python
107+ unzip
108+ which
109+ sqlite
110+ git
111+ gnupg
112+ ];
113+
114+ postPatch = ''
115+ patchShebangs .
116+
117+ for f in **/*.{py,c,t}; do
118+ # not only used in shebangs
119+ substituteAllInPlace "$f" '/bin/sh' '${stdenv.shell}'
120+ done
121+
122+ for f in **/*.t; do
123+ substituteInPlace 2>/dev/null "$f" \
124+ --replace '*/hg:' '*/*hg*:' \${/* paths emitted by our wrapped hg look like ..hg-wrapped-wrapped */""}
125+ --replace '"$PYTHON" "$BINDIR"/hg' '"$BINDIR"/hg' ${/* 'hg' is a wrapper; don't run using python directly */""}
126+ done
127+ '';
128+
129+ # This runs Mercurial _a lot_ of times.
130+ requiredSystemFeatures = [ "big-parallel" ];
131+
132+ # Don't run tests if not-Linux or if cross-compiling.
133+ meta.broken = !stdenv.hostPlatform.isLinux || stdenv.buildPlatform != stdenv.hostPlatform;
134+ } ''
135+ addToSearchPathWithCustomDelimiter : PYTHONPATH "${mercurial}/${python.sitePackages}"
136+
137+ unpackPhase
138+ cd "$sourceRoot"
139+ patchPhase
140+
141+ cat << EOF > tests/blacklists/nix
142+ # tests enforcing "/usr/bin/env" shebangs, which are patched for nix
143+ test-run-tests.t
144+ test-check-shbang.t
145+
146+ # unstable experimental/unsupported features
147+ # https://bz.mercurial-scm.org/show_bug.cgi?id=6633#c1
148+ test-git-interop.t
149+
150+ # doesn't like the extra setlocale warnings emitted by our bash wrappers
151+ test-locale.t
152+ EOF
153+
154+ export HGTEST_REAL_HG="${mercurial}/bin/hg"
155+ # extended timeout necessary for tests to pass on the busy CI workers
156+ export HGTESTFLAGS="--blacklist blacklists/nix --timeout 1800 -j$NIX_BUILD_CORES ${flags}"
157+ make check
158+ touch $out
159+ '';
130160in
131161 self.overridePythonAttrs (origAttrs: {
132162 passthru = origAttrs.passthru // rec {