Test that CI is skipped when it should be
(tmpdir_factory, commands, should_skip, pr_title, why)
| 723 | ), |
| 724 | ) |
| 725 | def test_skip_ci(tmpdir_factory, commands, should_skip, pr_title, why): |
| 726 | """ |
| 727 | Test that CI is skipped when it should be |
| 728 | """ |
| 729 | skip_ci_script = JENKINS_SCRIPT_ROOT / "git_skip_ci.py" |
| 730 | |
| 731 | git = TempGit(tmpdir_factory.mktemp("tmp_git_dir")) |
| 732 | |
| 733 | git.run("config", "user.name", "ci") |
| 734 | git.run("config", "user.email", "email@example.com") |
| 735 | git.run("commit", "--allow-empty", "--message", "base commit") |
| 736 | for command in commands: |
| 737 | git.run(*command) |
| 738 | pr_number = "1234" |
| 739 | proc = run_script( |
| 740 | [skip_ci_script, "--pr", pr_number, "--pr-title", pr_title], |
| 741 | cwd=git.cwd, |
| 742 | check=False, |
| 743 | ) |
| 744 | expected = 0 if should_skip else 1 |
| 745 | if proc.returncode != expected: |
| 746 | raise RuntimeError( |
| 747 | f"Unexpected return code {proc.returncode} " |
| 748 | f"(expected {expected}) in {why}:\n{proc.stdout}" |
| 749 | ) |
| 750 | |
| 751 | |
| 752 | @parameterize_named( |
nothing calls this directly
no test coverage detected
searching dependent graphs…