@@ -1516,7 +1516,10 @@ def report_overtime(self, out, test, example, got, *, check_timer=None):
15161516
15171517 OUTPUT: prints a report to ``out``
15181518
1519- EXAMPLES::
1519+ EXAMPLES:
1520+
1521+ Run an example with the Github CI variables overridden to test
1522+ the "normal" warning output::
15201523
15211524 sage: from sage.doctest.parsing import SageOutputChecker
15221525 sage: from sage.doctest.forker import SageDocTestRunner
@@ -1534,15 +1537,49 @@ def report_overtime(self, out, test, example, got, *, check_timer=None):
15341537 sage: check = Timer()
15351538 sage: check.cputime = 2.34
15361539 sage: check.walltime = 3.12
1540+ sage: from os import environ
1541+ sage: environ["GITHUB_ACTIONS"] = ""
1542+ sage: environ["CI"] = ""
15371543 sage: DTR.report_overtime(sys.stdout.write, doctests[0], ex, 'BAD ANSWER\n', check_timer=check)
15381544 **********************************************************************
15391545 File ".../sage/doctest/forker.py", line 12, in sage.doctest.forker
15401546 Warning, slow doctest:
15411547 doctest_var = 42; doctest_var^2
15421548 Test ran for 1.23s cpu, 2.50s wall
15431549 Check ran for 2.34s cpu, 3.12s wall
1550+
1551+ Repeat the example above as if we're running under the Github CI::
1552+
1553+ sage: from os import environ
1554+ sage: environ["GITHUB_ACTIONS"] = "true"
1555+ sage: environ["CI"] = "true"
1556+ sage: DTR.report_overtime(sys.stdout.write, doctests[0], ex, 'BAD ANSWER\n', check_timer=check)
1557+ **********************************************************************
1558+ File ".../sage/doctest/forker.py", line 12, in sage.doctest.forker
1559+ Uh oh, slow doctest:
1560+ doctest_var = 42; doctest_var^2
1561+ Test ran for 1.23s cpu, 2.50s wall
1562+ Check ran for 2.34s cpu, 3.12s wall
15441563 """
1545- out (self ._failure_header (test , example , 'Warning, slow doctest:' ) +
1564+ # Github actions (1) annotate "Warning" as an error, and (2)
1565+ # provide no way to disable this for files that you didn't
1566+ # actually change:
1567+ #
1568+ # https://github.com/actions/toolkit/issues/559
1569+ #
1570+ # As a very silly workaround, we avoid the word "Warning" for
1571+ # long-running tests when running under the CI. (We don't want
1572+ # to display a litany of "Error" notations that have nothing
1573+ # to do with the present pull request.)
1574+ #
1575+ # In the test below, keep in mind that both bool(None) and bool("")
1576+ # evaluate to False.
1577+ warning_word = "Warning"
1578+ from os import environ
1579+ if environ .get ('CI' ) or environ .get ('GITHUB_ACTIONS' ):
1580+ warning_word = "Uh oh"
1581+
1582+ out (self ._failure_header (test , example , f'{ warning_word } , slow doctest:' ) +
15461583 ('Test ran for %.2fs cpu, %.2fs wall\n Check ran for %.2fs cpu, %.2fs wall\n '
15471584 % (example .cputime ,
15481585 example .walltime ,
0 commit comments