Project import generated by Copybara.

GitOrigin-RevId: ff377a78794d412a35245e05428c8f95fef3951f
This commit is contained in:
Default email 2022-01-07 12:07:37 +08:00
parent 391e4a2fe6
commit 3a47dd4636

View file

@ -7,6 +7,7 @@
, highlightSupport ? fullBuild , highlightSupport ? fullBuild
, ApplicationServices , ApplicationServices
# test dependencies # test dependencies
, runCommand
, unzip , unzip
, which , which
, sqlite , sqlite
@ -39,15 +40,6 @@ let
} else null; } else null;
cargoRoot = if rustSupport then "rust" else null; cargoRoot = if rustSupport then "rust" else null;
postPatch = ''
patchShebangs .
for f in **/*.{py,c,t}; do
# not only used in shebangs
substituteAllInPlace "$f" '/bin/sh' '${stdenv.shell}'
done
'';
propagatedBuildInputs = lib.optional re2Support fb-re2 propagatedBuildInputs = lib.optional re2Support fb-re2
++ lib.optional gitSupport pygit2 ++ lib.optional gitSupport pygit2
++ lib.optional highlightSupport pygments; ++ lib.optional highlightSupport pygments;
@ -63,30 +55,6 @@ let
makeFlags = [ "PREFIX=$(out)" ] makeFlags = [ "PREFIX=$(out)" ]
++ lib.optional rustSupport "PURE=--rust"; ++ lib.optional rustSupport "PURE=--rust";
doCheck = stdenv.isLinux; # tests seem unstable on Darwin
checkInputs = [
unzip
which
sqlite
git
gnupg
];
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt"; # needed for git
checkPhase = ''
cat << EOF > tests/blacklists/nix
# tests enforcing "/usr/bin/env" shebangs, which are patched for nix
test-run-tests.t
test-check-shbang.t
# git tests, which are somewhat unstable (native git support is very experimental)
test-git-interop.t
EOF
# extended timeout necessary for tests to pass on the busy CI workers
export HGTESTFLAGS="--blacklist blacklists/nix --timeout 600"
make check
'';
postInstall = (lib.optionalString guiSupport '' postInstall = (lib.optionalString guiSupport ''
mkdir -p $out/etc/mercurial mkdir -p $out/etc/mercurial
cp contrib/hgk $out/bin cp contrib/hgk $out/bin
@ -114,18 +82,81 @@ let
--zsh contrib/zsh_completion --zsh contrib/zsh_completion
''; '';
passthru.tests = {}; passthru.tests = {
mercurial-tests = makeTests { flags = "--with-hg=$MERCURIAL_BASE/bin/hg"; };
};
meta = with lib; { meta = with lib; {
description = "A fast, lightweight SCM system for very large distributed projects"; description = "A fast, lightweight SCM system for very large distributed projects";
homepage = "https://www.mercurial-scm.org"; homepage = "https://www.mercurial-scm.org";
downloadPage = "https://www.mercurial-scm.org/release/"; downloadPage = "https://www.mercurial-scm.org/release/";
license = licenses.gpl2Plus; license = licenses.gpl2Plus;
maintainers = with maintainers; [ eelco lukegb ]; maintainers = with maintainers; [ eelco lukegb pacien ];
updateWalker = true; updateWalker = true;
platforms = platforms.unix; platforms = platforms.unix;
}; };
}; };
makeTests = { mercurial ? self, nameSuffix ? "", flags ? "" }: runCommand "${mercurial.pname}${nameSuffix}-tests" {
inherit (mercurial) src;
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt"; # needed for git
MERCURIAL_BASE = mercurial;
nativeBuildInputs = [
python
unzip
which
sqlite
git
gnupg
];
postPatch = ''
patchShebangs .
for f in **/*.{py,c,t}; do
# not only used in shebangs
substituteAllInPlace "$f" '/bin/sh' '${stdenv.shell}'
done
for f in **/*.t; do
substituteInPlace 2>/dev/null "$f" \
--replace '*/hg:' '*/*hg*:' \${/* paths emitted by our wrapped hg look like ..hg-wrapped-wrapped */""}
--replace '"$PYTHON" "$BINDIR"/hg' '"$BINDIR"/hg' ${/* 'hg' is a wrapper; don't run using python directly */""}
done
'';
# This runs Mercurial _a lot_ of times.
requiredSystemFeatures = [ "big-parallel" ];
# Don't run tests if not-Linux or if cross-compiling.
meta.broken = !stdenv.hostPlatform.isLinux || stdenv.buildPlatform != stdenv.hostPlatform;
} ''
addToSearchPathWithCustomDelimiter : PYTHONPATH "${mercurial}/${python.sitePackages}"
unpackPhase
cd "$sourceRoot"
patchPhase
cat << EOF > tests/blacklists/nix
# tests enforcing "/usr/bin/env" shebangs, which are patched for nix
test-run-tests.t
test-check-shbang.t
# unstable experimental/unsupported features
# https://bz.mercurial-scm.org/show_bug.cgi?id=6633#c1
test-git-interop.t
# doesn't like the extra setlocale warnings emitted by our bash wrappers
test-locale.t
EOF
export HGTEST_REAL_HG="${mercurial}/bin/hg"
# extended timeout necessary for tests to pass on the busy CI workers
export HGTESTFLAGS="--blacklist blacklists/nix --timeout 1800 -j$NIX_BUILD_CORES ${flags}"
make check
touch $out
'';
in in
self.overridePythonAttrs (origAttrs: { self.overridePythonAttrs (origAttrs: {
passthru = origAttrs.passthru // rec { passthru = origAttrs.passthru // rec {