|
2 | 2 | # pylint: disable=use-implicit-booleaness-not-comparison |
3 | 3 |
|
4 | 4 | """High-level integration tests of diff-cover tool.""" |
5 | | - |
6 | 5 | import json |
7 | 6 | import os |
8 | 7 | import os.path |
9 | 8 | import re |
10 | 9 | import shutil |
| 10 | +import textwrap |
11 | 11 | from collections import defaultdict |
12 | 12 | from pathlib import Path |
13 | 13 | from subprocess import Popen |
@@ -429,6 +429,54 @@ def test_expand_coverage_report_uncomplete_report( |
429 | 429 | assert runbin(["coverage_missing_lines.xml", "--expand-coverage-report"]) == 0 |
430 | 430 | compare_console("expand_console_report.txt", capsys.readouterr().out) |
431 | 431 |
|
| 432 | + def test_github_silent(self, runbin, patch_git_command, capsys): |
| 433 | + patch_git_command.set_stdout("git_diff_add.txt") |
| 434 | + assert ( |
| 435 | + runbin(["coverage.xml", "--format", "github-annotations:notice", "-q"]) == 0 |
| 436 | + ) |
| 437 | + expected = textwrap.dedent( |
| 438 | + """\ |
| 439 | + ::notice file=test_src.txt,line=2,title=Missing Coverage::Line 2 missing coverage |
| 440 | + ::notice file=test_src.txt,line=4,title=Missing Coverage::Line 4 missing coverage |
| 441 | + ::notice file=test_src.txt,line=6,title=Missing Coverage::Line 6 missing coverage |
| 442 | + ::notice file=test_src.txt,line=8,title=Missing Coverage::Line 8 missing coverage |
| 443 | + ::notice file=test_src.txt,line=10,title=Missing Coverage::Line 10 missing coverage |
| 444 | + """ |
| 445 | + ) |
| 446 | + assert capsys.readouterr().out == expected |
| 447 | + |
| 448 | + @pytest.mark.usefixtures("patch_git_command") |
| 449 | + def test_github_fully_covered(self, runbin, capsys): |
| 450 | + assert runbin(["coverage2.xml", "--format", "github-annotations:notice"]) == 0 |
| 451 | + expected = textwrap.dedent( |
| 452 | + """\ |
| 453 | + ------------- |
| 454 | + Diff Coverage |
| 455 | + Diff: origin/main...HEAD, staged and unstaged changes |
| 456 | + ------------- |
| 457 | + No lines with coverage information in this diff. |
| 458 | + ------------- |
| 459 | +
|
| 460 | + """ |
| 461 | + ) |
| 462 | + assert capsys.readouterr().out == expected |
| 463 | + |
| 464 | + def test_github_empty_diff(self, runbin, patch_git_command, capsys): |
| 465 | + patch_git_command.set_stdout("") |
| 466 | + assert runbin(["coverage.xml", "--format", "github-annotations:notice"]) == 0 |
| 467 | + expected = textwrap.dedent( |
| 468 | + """\ |
| 469 | + ------------- |
| 470 | + Diff Coverage |
| 471 | + Diff: origin/main...HEAD, staged and unstaged changes |
| 472 | + ------------- |
| 473 | + No lines with coverage information in this diff. |
| 474 | + ------------- |
| 475 | +
|
| 476 | + """ |
| 477 | + ) |
| 478 | + assert capsys.readouterr().out == expected |
| 479 | + |
432 | 480 | def test_real_world_cpp_lcov_coverage(self, runbin, patch_git_command, capsys): |
433 | 481 | """Test with real C++ LCOV coverage data""" |
434 | 482 | # Create git diff for C++ files |
|
0 commit comments