From 370c1a9ad0388df4c3677fa82899353ae19dee40 Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Mon, 7 Nov 2022 13:23:19 +0000 Subject: [PATCH] python3Packages.sh: disable flaky tests --- .../development/python-modules/sh/default.nix | 24 +++++++--- .../sh/disable-broken-tests-darwin.patch | 48 ------------------- 2 files changed, 17 insertions(+), 55 deletions(-) delete mode 100644 pkgs/development/python-modules/sh/disable-broken-tests-darwin.patch diff --git a/pkgs/development/python-modules/sh/default.nix b/pkgs/development/python-modules/sh/default.nix index d6334251bff4..17dcc5acbee0 100644 --- a/pkgs/development/python-modules/sh/default.nix +++ b/pkgs/development/python-modules/sh/default.nix @@ -1,4 +1,4 @@ -{ lib, buildPythonPackage, fetchPypi, python, coverage, lsof, glibcLocales, coreutils }: +{ lib, stdenv, buildPythonPackage, fetchPypi, python, coverage, lsof, glibcLocales, coreutils, pytestCheckHook }: buildPythonPackage rec { pname = "sh"; @@ -9,17 +9,12 @@ buildPythonPackage rec { sha256 = "sha256-5ARbbHMtnOddVxx59awiNO3Zrk9fqdWbCXBQgr3KGMc="; }; - patches = [ - # Disable tests that fail on Darwin sandbox - ./disable-broken-tests-darwin.patch - ]; - postPatch = '' sed -i 's#/usr/bin/env python#${python.interpreter}#' test.py sed -i 's#/bin/sleep#${coreutils.outPath}/bin/sleep#' test.py ''; - checkInputs = [ coverage lsof glibcLocales ]; + checkInputs = [ coverage lsof glibcLocales pytestCheckHook ]; # A test needs the HOME directory to be different from $TMPDIR. preCheck = '' @@ -27,6 +22,21 @@ buildPythonPackage rec { HOME=$(mktemp -d) ''; + pytestFlagsArray = [ "test.py" ]; + + disabledTests = [ + # Disable tests that fail on Hydra + "test_no_fd_leak" + "test_piped_exception1" + "test_piped_exception2" + "test_unicode_path" + ] ++ lib.optionals stdenv.isDarwin [ + # Disable tests that fail on Darwin sandbox + "test_background_exception" + "test_cwd" + "test_ok_code" + ]; + meta = with lib; { description = "Python subprocess interface"; homepage = "https://pypi.python.org/pypi/sh/"; diff --git a/pkgs/development/python-modules/sh/disable-broken-tests-darwin.patch b/pkgs/development/python-modules/sh/disable-broken-tests-darwin.patch deleted file mode 100644 index dfeb50db8d0e..000000000000 --- a/pkgs/development/python-modules/sh/disable-broken-tests-darwin.patch +++ /dev/null @@ -1,48 +0,0 @@ -From c596ad546fe7460b57a62799837757eb641309c1 Mon Sep 17 00:00:00 2001 -From: Sirio Balmelli -Date: Mon, 20 Jul 2020 19:51:20 +0200 -Subject: [PATCH] Disable tests that fail on Darwin (macOS) or with sandboxing - -Signed-off-by: Sirio Balmelli ---- a/test.py -+++ b/test.py -@@ -377,6 +377,7 @@ exit(3) - self.assertEqual(sed(_in="one test three", e="s/test/two/").strip(), - "one two three") - -+ @not_macos - def test_ok_code(self): - from sh import ls, ErrorReturnCode_1, ErrorReturnCode_2 - -@@ -982,6 +983,7 @@ print(sys.argv[1]) - now = time.time() - self.assertGreater(now - start, sleep_time) - -+ @not_macos - def test_background_exception(self): - from sh import ls, ErrorReturnCode_1, ErrorReturnCode_2 - p = ls("/ofawjeofj", _bg=True, _bg_exc=False) # should not raise -@@ -1779,6 +1781,7 @@ exit(49) - p = python(py.name, _ok_code=49, _bg=True) - self.assertEqual(49, p.exit_code) - -+ @not_macos - def test_cwd(self): - from sh import pwd - from os.path import realpath -@@ -2777,6 +2780,7 @@ print("cool") - # on osx. so skip it for now if osx - @not_macos - @requires_progs("lsof") -+ @skipUnless(False, "Flaky on Hydra") - def test_no_fd_leak(self): - import sh - import os -@@ -2879,6 +2883,7 @@ print("hi") - python(py.name, _in=stdin) - - @requires_utf8 -+ @skipUnless(False, "Does not work in sandbox") - def test_unicode_path(self): - from sh import Command -