|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
3 | 3 | import json
|
| 4 | +import subprocess |
4 | 5 | from pathlib import Path
|
5 | 6 | from textwrap import dedent
|
6 | 7 | from typing import TYPE_CHECKING
|
|
12 | 13 | from semantic_release import __version__
|
13 | 14 | from semantic_release.cli.commands.main import main
|
14 | 15 |
|
15 |
| -from tests.const import MAIN_PROG_NAME, VERSION_SUBCMD |
| 16 | +from tests.const import MAIN_PROG_NAME, SUCCESS_EXIT_CODE, VERSION_SUBCMD |
16 | 17 | from tests.fixtures.repos import repo_w_no_tags_conventional_commits
|
17 | 18 | from tests.util import assert_exit_code, assert_successful_exit_code
|
18 | 19 |
|
|
25 | 26 | from tests.fixtures.git_repo import BuiltRepoResult
|
26 | 27 |
|
27 | 28 |
|
| 29 | +@pytest.mark.parametrize( |
| 30 | + "project_script_name", |
| 31 | + [ |
| 32 | + "python-semantic-release", |
| 33 | + "semantic-release", |
| 34 | + "psr", |
| 35 | + ], |
| 36 | +) |
| 37 | +def test_entrypoint_scripts(project_script_name: str): |
| 38 | + # Setup |
| 39 | + command = str.join(" ", [project_script_name, "--version"]) |
| 40 | + expected_output = f"semantic-release, version {__version__}\n" |
| 41 | + |
| 42 | + # Act |
| 43 | + proc = subprocess.run( # noqa: S602, PLW1510 |
| 44 | + command, shell=True, text=True, capture_output=True |
| 45 | + ) |
| 46 | + |
| 47 | + # Evaluate |
| 48 | + assert SUCCESS_EXIT_CODE == proc.returncode # noqa: SIM300 |
| 49 | + assert expected_output == proc.stdout |
| 50 | + assert not proc.stderr |
| 51 | + |
| 52 | + |
28 | 53 | def test_main_prints_version_and_exits(cli_runner: CliRunner):
|
29 | 54 | cli_cmd = [MAIN_PROG_NAME, "--version"]
|
30 | 55 |
|
|
0 commit comments