From ffdfbd0aabdd7c663fad07b83be2af1982aac7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pehr=20S=C3=B6derman?= Date: Tue, 18 Jun 2024 14:55:13 +0200 Subject: [PATCH] Warn if sample is empty --- .github/workflows/python-app.yml | 8 +++----- problemtools/verifyproblem.py | 15 +++++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index d133618..b7058d7 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -25,11 +25,9 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Setup cache for apt packages (used by builddeb) - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: debhelper (>= 8.0.0) dh-python python3-pytest libboost-regex-dev - version: 1.0 + - name: Install apt packages (for debbuild) + run: sudo apt-get install debhelper dh-python python3-pytest libboost-regex-dev + shell: bash - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/problemtools/verifyproblem.py b/problemtools/verifyproblem.py index 2d5f868..a45cbf9 100644 --- a/problemtools/verifyproblem.py +++ b/problemtools/verifyproblem.py @@ -77,7 +77,7 @@ def __str__(self) -> str: if self.reason is not None: details.append(self.reason) if self.testcase is not None: - details.append(f'test case: {self.testcase}') + details.append(f'testcase: {self.testcase}') if self.runtime != -1: details.append(f'CPU: {self.runtime:.2f}s @ {self.runtime_testcase}') @@ -240,7 +240,7 @@ def check(self, context: Context) -> bool: return self._check_res def __str__(self) -> str: - return f'test case {self.strip_path_prefix(self._base)}' + return f'testcase {self.strip_path_prefix(self._base)}' def matches_filter(self, filter_re: Pattern[str]) -> bool: return filter_re.search(self.strip_path_prefix(self._base)) is not None @@ -268,7 +268,7 @@ def _check_symlinks(self) -> bool: self.error(f"Symbolic link points outside data/ directory for file '{nicepath}'") return False if self.testcasegroup.config['output_validator_flags'] != self.reuse_result_from.testcasegroup.config['output_validator_flags']: - self.error(f"Symbolic link '{nicepath}' points to test case with different output validator flags") + self.error(f"Symbolic link '{nicepath}' points to testcase with different output validator flags") return False return True @@ -418,7 +418,7 @@ def __init__(self, problem: Problem, datadir: str, parent: TestCaseGroup|None=No def __str__(self) -> str: - return f'test case group {self.name}' + return f'testcase group {self.name}' def set_symlinks(self) -> None: for sub in self._items: @@ -554,7 +554,10 @@ def check(self, context: Context) -> bool: self.error(f"No matching input file for answer '{ansfile}'") if not self.get_subgroups() and not self.get_testcases(): - self.error('Test case group is empty') + if os.path.basename(self._datadir) != 'sample': + self.error(f'Testcase group {self._datadir} exists, but does not contain any testcases') + else: + self.warning(f'Sample testcase group {self._datadir} exists, but does not contain any testcases') # Check whether a <= b according to a natural sorting where numeric components # are compactified, so that e.g. "a" < "a1" < "a2" < "a10" = "a010" < "a10a". @@ -785,7 +788,7 @@ def check(self, context: Context) -> bool: elif self._data['grading']['show_test_data_groups'] and self._data['type'] == 'pass-fail': self.error("Showing test data groups is only supported for scoring problems, this is a pass-fail problem") if self._data['type'] != 'pass-fail' and self._problem.testdata.has_custom_groups() and 'show_test_data_groups' not in self._origdata.get('grading', {}): - self.warning("Problem has custom test case groups, but does not specify a value for grading.show_test_data_groups; defaulting to false") + self.warning("Problem has custom testcase groups, but does not specify a value for grading.show_test_data_groups; defaulting to false") if 'on_reject' in self._data['grading']: if self._data['type'] == 'pass-fail' and self._data['grading']['on_reject'] == 'grade':