Skip to content

Commit

Permalink
Test new test-file-prefix setting
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoMi committed Sep 22, 2023
1 parent fab059c commit 37131e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/publish_test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,10 @@ def get_settings(options: dict, gha: GithubAction) -> Settings:
check_var(settings.token, 'GITHUB_TOKEN', 'GitHub token')
check_var(settings.repo, 'GITHUB_REPOSITORY', 'GitHub repository')
check_var(settings.commit, 'COMMIT, GITHUB_SHA or event file', 'Commit SHA')
check_var_condition(
settings.test_file_prefix is None or any([settings.test_file_prefix.startswith(sign) for sign in ['-', '+']]),
f"TEST_FILE_PREFIX is optional, but when given, it must start with '-' or '+': {settings.test_file_prefix}"
)
check_var(settings.comment_mode, 'COMMENT_MODE', 'Comment mode', comment_modes)
check_var(settings.pull_request_build, 'PULL_REQUEST_BUILD', 'Pull Request build', pull_request_build_modes)
check_var(suite_logs_mode, 'REPORT_SUITE_LOGS', 'Report suite logs mode', available_report_suite_logs)
Expand Down
10 changes: 10 additions & 0 deletions python/test/test_action_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,16 @@ def test_get_settings_time_unit(self):
self.assertIn('TIME_UNIT minutes is not supported. It is optional, '
'but when given must be one of these values: seconds, milliseconds', re.exception.args)

def test_get_settings_test_file_prefix(self):
self.do_test_get_settings(TEST_FILE_PREFIX=None, expected=self.get_settings(test_file_prefix=None))
self.do_test_get_settings(TEST_FILE_PREFIX='', expected=self.get_settings(test_file_prefix=None))
self.do_test_get_settings(TEST_FILE_PREFIX='+src/', expected=self.get_settings(test_file_prefix='+src/'))
self.do_test_get_settings(TEST_FILE_PREFIX='-./', expected=self.get_settings(test_file_prefix='-./'))

with self.assertRaises(RuntimeError) as re:
self.do_test_get_settings(TEST_FILE_PREFIX='path/', expected=None)
self.assertIn("TEST_FILE_PREFIX is optional, but when given, it must start with '-' or '+': path/", re.exception.args)

def test_get_settings_commit(self):
event = {'pull_request': {'head': {'sha': 'sha2'}}}
self.do_test_get_settings(INPUT_COMMIT='sha', GITHUB_EVENT_NAME='pull_request', event=event, GITHUB_SHA='default', expected=self.get_settings(commit='sha', event=event, event_name='pull_request', is_fork=True))
Expand Down

0 comments on commit 37131e3

Please sign in to comment.