Skip to content

Commit 745e2b8

Browse files
author
Release Manager
committed
sagemathgh-39512: Add test for github format of doctest report As in the title. The feature was added in sagemath#36938 for the purpose of showing GitHub annotations for test failures, but there wasn't a doctest for it. This adds the test. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. (no change to documentation preview because private method.) ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39512 Reported by: user202729 Reviewer(s): Dima Pasechnik
2 parents 32d441a + 5668e84 commit 745e2b8

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/sage/doctest/forker.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,18 @@ def _failure_header(self, test, example, message='Failed example:', extra=None):
12471247
Hello there!
12481248
doctest_var = 42; doctest_var^2
12491249
<BLANKLINE>
1250+
1251+
TESTS:
1252+
1253+
Test GitHub output format (used for GitHub Actions annotations)::
1254+
1255+
sage: DTR.options.format = 'github'
1256+
sage: print(DTR._failure_header(doctests[0], ex))
1257+
**********************************************************************
1258+
::error title=Failed example:,file=.../sage/doctest/forker.py,line=12::Failed example:
1259+
doctest_var = 42; doctest_var^2
1260+
<BLANKLINE>
1261+
sage: DTR.options.format = 'sage'
12501262
"""
12511263
out = [self.DIVIDER]
12521264
with OriginalSource(example):

src/sage/doctest/reporting.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,14 @@ def _log_failure(self, source, fail_msg, event, output=None):
254254
Tests run before process (pid=1234) timed out:
255255
Output so far...
256256
**********************************************************************
257+
258+
TESTS:
259+
260+
Test GitHub output format (used for GitHub Actions annotations)::
261+
262+
sage: DTR.controller.options.format = 'github'
263+
sage: DTR._log_failure(FDS, "Timed out", "process (pid=1234) timed out", "Output so far...")
264+
::error title=Timed out,file=.../sage/doctest/reporting.py::Output so far...
257265
"""
258266
log = self.controller.log
259267
format = self.controller.options.format

0 commit comments

Comments
 (0)