rbx.cp 0.5.48__py3-none-any.whl → 0.5.49__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
rbx/box/schema.py CHANGED
@@ -356,8 +356,8 @@ class LimitModifiers(BaseModel):
356
356
  class ValidatorTest(BaseModel):
357
357
  model_config = ConfigDict(extra='forbid')
358
358
 
359
- input: pathlib.Path = Field(
360
- description='The input file to be used as unit test input for the validator.'
359
+ glob: str = Field(
360
+ description='A glob pattern for the input files to be used as unit test input for the validator.'
361
361
  )
362
362
  outcome: ValidatorOutcome = Field(
363
363
  default=ValidatorOutcome.VALID,
@@ -373,17 +373,12 @@ class ValidatorTest(BaseModel):
373
373
  class CheckerTest(BaseModel):
374
374
  model_config = ConfigDict(extra='forbid')
375
375
 
376
- input: Optional[pathlib.Path] = Field(
377
- default=None,
378
- description='The input file to be used as unit test input for the checker. If not specified, will pass an empty file.',
379
- )
380
- output: Optional[pathlib.Path] = Field(
381
- default=None,
382
- description='The solution output file to be used as unit test output for the checker. If not specified, will pass an empty file.',
383
- )
384
- answer: Optional[pathlib.Path] = Field(
385
- default=None,
386
- description='The answer file to be used as unit test answer for the checker. If not specified, will pass an empty file.',
376
+ glob: str = Field(
377
+ description="""
378
+ A glob pattern for the files to be used as unit test input for the checker.
379
+ This glob should simultaneously match the input, output, and answer files (.in, .out, .ans).
380
+ If one of them is not present, an empty file will be used instead.
381
+ """,
387
382
  )
388
383
 
389
384
  outcome: ExpectedOutcome = Field(
rbx/box/unit.py CHANGED
@@ -1,14 +1,79 @@
1
- from typing import List, Optional
1
+ import pathlib
2
+ from typing import List, Optional, Set
2
3
 
3
4
  import syncer
5
+ from pydantic import BaseModel
4
6
 
5
7
  from rbx import console
6
8
  from rbx.box import checkers, package, validators
7
- from rbx.box.schema import CodeItem, Testcase, ValidatorOutcome, ValidatorTest
9
+ from rbx.box.schema import (
10
+ CheckerTest,
11
+ CodeItem,
12
+ ExpectedOutcome,
13
+ Testcase,
14
+ ValidatorOutcome,
15
+ ValidatorTest,
16
+ )
8
17
  from rbx.utils import StatusProgress
9
18
 
10
19
 
11
- def _get_validator_for_test(test: ValidatorTest) -> Optional[CodeItem]:
20
+ class ValidatorTestEntry(BaseModel):
21
+ input: pathlib.Path
22
+ outcome: ValidatorOutcome
23
+ validator: Optional[CodeItem]
24
+
25
+
26
+ class CheckerTestEntry(BaseModel):
27
+ input: Optional[pathlib.Path] = None
28
+ output: Optional[pathlib.Path] = None
29
+ answer: Optional[pathlib.Path] = None
30
+ outcome: ExpectedOutcome
31
+
32
+
33
+ def _extract_validator_test_entries(
34
+ tests: List[ValidatorTest],
35
+ ) -> List[ValidatorTestEntry]:
36
+ res: List[ValidatorTestEntry] = []
37
+ for test in tests:
38
+ for input in pathlib.Path().glob(str(test.glob)):
39
+ if not input.is_file():
40
+ continue
41
+ res.append(
42
+ ValidatorTestEntry(
43
+ input=input, outcome=test.outcome, validator=test.validator
44
+ )
45
+ )
46
+ return sorted(res, key=lambda x: x.input.name)
47
+
48
+
49
+ def _extract_checker_test_entries(tests: List[CheckerTest]) -> List[CheckerTestEntry]:
50
+ res: List[CheckerTestEntry] = []
51
+ seen: Set[pathlib.Path] = set()
52
+ for test in tests:
53
+ for file in pathlib.Path().glob(str(test.glob)):
54
+ if not file.is_file():
55
+ continue
56
+ if file.suffix not in ['.in', '.out', '.ans']:
57
+ continue
58
+ basefile = file.with_suffix('')
59
+ if basefile in seen:
60
+ continue
61
+ seen.add(basefile)
62
+ input = basefile.with_suffix('.in')
63
+ output = basefile.with_suffix('.out')
64
+ answer = basefile.with_suffix('.ans')
65
+ res.append(
66
+ CheckerTestEntry(
67
+ input=input if input.is_file() else None,
68
+ output=output if output.is_file() else None,
69
+ answer=answer if answer.is_file() else None,
70
+ outcome=test.outcome,
71
+ )
72
+ )
73
+ return res
74
+
75
+
76
+ def _get_validator_for_test(test: ValidatorTestEntry) -> Optional[CodeItem]:
12
77
  pkg = package.find_problem_package_or_die()
13
78
  if test.validator is not None:
14
79
  return test.validator
@@ -18,8 +83,10 @@ def _get_validator_for_test(test: ValidatorTest) -> Optional[CodeItem]:
18
83
  async def run_validator_unit_tests(progress: StatusProgress):
19
84
  pkg = package.find_problem_package_or_die()
20
85
 
86
+ entries = _extract_validator_test_entries(pkg.unitTests.validator)
87
+
21
88
  vals: List[CodeItem] = []
22
- for test in pkg.unitTests.validator:
89
+ for test in entries:
23
90
  val = _get_validator_for_test(test)
24
91
  if val is not None:
25
92
  vals.append(val)
@@ -31,7 +98,7 @@ async def run_validator_unit_tests(progress: StatusProgress):
31
98
 
32
99
  console.console.rule('Validator tests', style='info')
33
100
 
34
- for i, test in enumerate(pkg.unitTests.validator):
101
+ for i, test in enumerate(entries):
35
102
  val = _get_validator_for_test(test)
36
103
  if val is None:
37
104
  console.console.print(
@@ -82,8 +149,9 @@ async def run_checker_unit_tests(progress: StatusProgress):
82
149
  console.console.rule('Checker tests', style='info')
83
150
 
84
151
  empty_file = package.get_empty_sentinel_path()
152
+ entries = _extract_checker_test_entries(pkg.unitTests.checker)
85
153
 
86
- for i, test in enumerate(pkg.unitTests.checker):
154
+ for i, test in enumerate(entries):
87
155
  result = await checkers.check(
88
156
  compiled_digest,
89
157
  run_log=None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: rbx.cp
3
- Version: 0.5.48
3
+ Version: 0.5.49
4
4
  Summary:
5
5
  Author: Roberto Sales
6
6
  Requires-Python: >=3.9,<4.0
@@ -44,7 +44,7 @@ rbx/box/presets/lock_schema.py,sha256=6sRPnyePOC8yy-5WcD5JRZdDJHf8loqbvpQ1IPiOU9
44
44
  rbx/box/presets/schema.py,sha256=mZmSPkQsw7eQM0lQN6er1MO_LiW1ObwwAZFDK0F5fxE,1962
45
45
  rbx/box/retries.py,sha256=tRk2K1bXw2xnwkAj2CsktRHTEhw7YKcPxMQTT6mCy-E,4707
46
46
  rbx/box/sanitizers/warning_stack.py,sha256=RI97_GJgdjTKIXY_r0EKp5h0qQQSDSdNDh5K7zINrqs,2861
47
- rbx/box/schema.py,sha256=P1jVaeqe4OcotAJOqu3T5WD8DR-amZyyq3cau5rPiM8,17086
47
+ rbx/box/schema.py,sha256=tOQ1tLHqc_5V-UgrzM44aS8ULAkq-IkeErxjLCFVA8I,16778
48
48
  rbx/box/setter_config.py,sha256=s53talhwM6FTGDCcBhY7IlZ6_6mJ3PMp6V4kTtaSs50,4262
49
49
  rbx/box/solutions.py,sha256=b4P6JN4eSDFiUKjBYvI38jsf8wLxS8Wi-YwBmm25Rcg,42684
50
50
  rbx/box/solutions_test.py,sha256=TCowbxBG3SvDlFO5-qtBj_M_HrAHe0IJaI1XwoQ1d00,1718
@@ -70,7 +70,7 @@ rbx/box/ui/captured_log.py,sha256=ptICDPViVnz-_2NfrcB0SSBXNW5L74zI-vAZNN7kSok,11
70
70
  rbx/box/ui/css/app.tcss,sha256=apd5PkPEvl5jK3kE2qrxPyVED1VnvSsj08QQwzUPwEA,786
71
71
  rbx/box/ui/main.py,sha256=b0rHcBF42W4AOCv7WhtiGf_rUnY0yxpqO5oj3wfR4R4,984
72
72
  rbx/box/ui/run.py,sha256=wMEXrEFdQvMHz2hRKAFIithTnTtaL0kNQZu0jKmb8jI,7060
73
- rbx/box/unit.py,sha256=veyBuz_7AbDFbdWi02jq_zLwXEkmgt0djXgVJU-OYCU,3755
73
+ rbx/box/unit.py,sha256=ziyfgU4gmmNqKucMYYiJksOHkp22pxYpgk7dpX2mSQM,5793
74
74
  rbx/box/validators.py,sha256=oqlNhw7jivbbH5l8g3xwihPRy76AM7MA3G4A8nyI_V0,10416
75
75
  rbx/box/validators_test.py,sha256=WY4Ho-wlsPHc0YNuz0KFVd6KQ9ouuiou3w5_zMOZ4Fs,362
76
76
  rbx/checker.py,sha256=pj1jO3my48ru-qugbER5onccANCjoR0-PaFe3H3VGEY,4118
@@ -188,8 +188,8 @@ rbx/testcase.py,sha256=yKOq3CAJZ1YTmInvnoIs0u1iJnRj_X85XiWbLI-p9d8,1951
188
188
  rbx/testcase_rendering.py,sha256=nfmv6dSEqd4aR3TsaODwkKGK6AXty_DDKtWf_ejiQpI,2084
189
189
  rbx/testing_utils.py,sha256=ZXMysGXpTtvS1lfLL38FuD5iSIyxi3ARjQePDrUmEtc,2067
190
190
  rbx/utils.py,sha256=6e1eXRzNE-52D0UVtqclePxqR4Haiqt8qWCrSVjnGuE,4585
191
- rbx_cp-0.5.48.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
192
- rbx_cp-0.5.48.dist-info/METADATA,sha256=LDeC-APwbLHB8kxUUmbWjS_pwbTSfIbOweMWlYRTU-M,3261
193
- rbx_cp-0.5.48.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
194
- rbx_cp-0.5.48.dist-info/entry_points.txt,sha256=qBTLBOeifT1F00LWaEewRRE_jQPgvH7BUdJfZ-dYsFU,57
195
- rbx_cp-0.5.48.dist-info/RECORD,,
191
+ rbx_cp-0.5.49.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
192
+ rbx_cp-0.5.49.dist-info/METADATA,sha256=mNCg5KTbxOIcJGovPqYotTF3kFQXqxcJ-8TRjAK47Pg,3261
193
+ rbx_cp-0.5.49.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
194
+ rbx_cp-0.5.49.dist-info/entry_points.txt,sha256=qBTLBOeifT1F00LWaEewRRE_jQPgvH7BUdJfZ-dYsFU,57
195
+ rbx_cp-0.5.49.dist-info/RECORD,,