summary refs log tree commit diff
diff options
context:
space:
mode:
authorMauricio Collares <mauricio@collares.org>2022-01-13 18:52:39 -0300
committerMauricio Collares <mauricio@collares.org>2022-01-30 13:15:22 -0300
commit8ec9a32829f9510922481a99e67182478558cfb9 (patch)
tree99a2bf182ea9c39f17228a172f7ab09fb646e983
parentcecbb55fb0e844fd07d30b2dc73717aa5fcf5a81 (diff)
downloadnixpkgs-8ec9a32829f9510922481a99e67182478558cfb9.tar
nixpkgs-8ec9a32829f9510922481a99e67182478558cfb9.tar.gz
nixpkgs-8ec9a32829f9510922481a99e67182478558cfb9.tar.bz2
nixpkgs-8ec9a32829f9510922481a99e67182478558cfb9.tar.lz
nixpkgs-8ec9a32829f9510922481a99e67182478558cfb9.tar.xz
nixpkgs-8ec9a32829f9510922481a99e67182478558cfb9.tar.zst
nixpkgs-8ec9a32829f9510922481a99e67182478558cfb9.zip
sageWithDoc: do not autodetect optional features when testing dochtml
-rw-r--r--pkgs/applications/science/math/sage/patches/Only-test-external-software-when-all-of-sage-is.patch46
-rw-r--r--pkgs/applications/science/math/sage/patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch26
-rw-r--r--pkgs/applications/science/math/sage/sage-src.nix15
-rw-r--r--pkgs/applications/science/math/sage/sagedoc.nix2
4 files changed, 57 insertions, 32 deletions
diff --git a/pkgs/applications/science/math/sage/patches/Only-test-external-software-when-all-of-sage-is.patch b/pkgs/applications/science/math/sage/patches/Only-test-external-software-when-all-of-sage-is.patch
new file mode 100644
index 00000000000..a478f50d92e
--- /dev/null
+++ b/pkgs/applications/science/math/sage/patches/Only-test-external-software-when-all-of-sage-is.patch
@@ -0,0 +1,46 @@
+diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py
+index 01f32fb8e4..4d83dc7b47 100644
+--- a/src/sage/doctest/control.py
++++ b/src/sage/doctest/control.py
+@@ -1253,6 +1253,7 @@ class DocTestController(SageObject):
+ 
+             self.log("Using --optional=" + self._optional_tags_string())
+             available_software._allow_external = self.options.optional is True or 'external' in self.options.optional
++            available_software._autodetect_safe = self.options.optional is True or 'sage' in self.options.optional
+             self.log("Features to be detected: " + ','.join(available_software.detectable()))
+             self.add_files()
+             self.expand_files_into_sources()
+diff --git a/src/sage/doctest/external.py b/src/sage/doctest/external.py
+index 84dae19ea5..badc61466e 100644
+--- a/src/sage/doctest/external.py
++++ b/src/sage/doctest/external.py
+@@ -409,6 +409,7 @@ class AvailableSoftware(object):
+             []
+         """
+         self._allow_external = True
++        self._autodetect_safe = True
+         # For multiprocessing of doctests, the data self._seen should be
+         # shared among subprocesses. Thus we use Array class from the
+         # multiprocessing module.
+@@ -430,6 +431,8 @@ class AvailableSoftware(object):
+             sage: 'internet' in available_software # random, optional - internet
+             True
+         """
++        if not self._autodetect_safe:
++            return False
+         try:
+             idx = self._indices[item]
+         except KeyError:
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index 433338766d..233623b14a 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -12,7 +12,7 @@ class sagemath_doc_html(StaticFile):
+ 
+     EXAMPLES::
+ 
+-        sage: from sage.features.sagemath import sagemath_doc_html
++        sage: from sage.features.sagemath import sagemath_doc_html  # optional - sagemath_doc_html
+         sage: sagemath_doc_html().is_present()  # optional - sagemath_doc_html
+         FeatureTestResult('sagemath_doc_html', True)
+     """
diff --git a/pkgs/applications/science/math/sage/patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch b/pkgs/applications/science/math/sage/patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch
deleted file mode 100644
index d5c19a54fd9..00000000000
--- a/pkgs/applications/science/math/sage/patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From f5ea42a7aaed7611fb55b65897b9fcf2b7bcf97e Mon Sep 17 00:00:00 2001
-From: Timo Kaufmann <timokau@zoho.com>
-Date: Sun, 21 Oct 2018 17:52:40 +0200
-Subject: [PATCH] Only test py2/py3 optional tests when all of sage is tested
-
----
- src/sage/doctest/control.py | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py
-index 2d93841e50..6d156e29a1 100644
---- a/src/sage/doctest/control.py
-+++ b/src/sage/doctest/control.py
-@@ -375,7 +375,8 @@ class DocTestController(SageObject):
-                     if not optionaltag_regex.search(o):
-                         raise ValueError('invalid optional tag {!r}'.format(o))
- 
--                options.optional |= auto_optional_tags
-+                if "sage" in options.optional:
-+                    options.optional |= auto_optional_tags
- 
-         self.options = options
- 
--- 
-2.28.0
-
diff --git a/pkgs/applications/science/math/sage/sage-src.nix b/pkgs/applications/science/math/sage/sage-src.nix
index b260f2cd3cf..a51e92cde52 100644
--- a/pkgs/applications/science/math/sage/sage-src.nix
+++ b/pkgs/applications/science/math/sage/sage-src.nix
@@ -70,11 +70,16 @@ stdenv.mkDerivation rec {
   # Patches needed because of particularities of nix or the way this is packaged.
   # The goal is to upstream all of them and get rid of this list.
   nixPatches = [
-    # Make sure py2/py3 tests are only run when their expected context (all "sage"
-    # tests) are also run. That is necessary to test dochtml individually. See
-    # https://trac.sagemath.org/ticket/26110 for an upstream discussion.
-    # TODO: Determine if it is still necessary.
-    ./patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch
+    # Since https://trac.sagemath.org/ticket/32174, some external features are
+    # marked as "safe" and get auto-detected, in which case the corresponding
+    # optional tests are executed. We disable auto-detection of safe features if
+    # we are doctesting with an "--optional" argument which does not include
+    # "sage", because tests from autodetected features expect context provided
+    # by running basic sage tests. This is necessary to test sagemath_doc_html
+    # separately. See https://trac.sagemath.org/ticket/26110 for a related
+    # upstream discussion (from the time when Sage still had optional py2/py3
+    # tags).
+    ./patches/Only-test-external-software-when-all-of-sage-is.patch
 
     # Fixes a potential race condition which can lead to transient doctest failures.
     ./patches/fix-ecl-race.patch
diff --git a/pkgs/applications/science/math/sage/sagedoc.nix b/pkgs/applications/science/math/sage/sagedoc.nix
index 978d96e597b..489fc2edfe5 100644
--- a/pkgs/applications/science/math/sage/sagedoc.nix
+++ b/pkgs/applications/science/math/sage/sagedoc.nix
@@ -83,6 +83,6 @@ stdenv.mkDerivation rec {
 
   doCheck = true;
   checkPhase = ''
-    ${sage-with-env}/bin/sage -t --optional=dochtml --all
+    ${sage-with-env}/bin/sage -t --optional=sagemath_doc_html --all
   '';
 }