From 2709bc9e3035ce8e4f9ae4bfca573ca589d27d0f Mon Sep 17 00:00:00 2001 From: mzuenni Date: Tue, 14 May 2024 00:53:01 +0200 Subject: [PATCH] update code --- bin/generate.py | 19 ++++++------------- .../identity/generators/generators.yaml | 2 +- test/problems/identity/generators/stdout.py | 2 ++ 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/bin/generate.py b/bin/generate.py index 7e7b07230..6aaca4c60 100644 --- a/bin/generate.py +++ b/bin/generate.py @@ -432,8 +432,7 @@ def __init__(self, problem, generator_config, key, name: str, yaml, parent, coun # Used by `fuzz` self.in_is_generated = False - self.has_count = count_index is not None - self.count_index = count_index if self.has_count else 0 + self.count_index = count_index # used to decide if this was supposed to be a duplicate or not self.intended_copy = self.count_index > 0 @@ -510,7 +509,7 @@ def __init__(self, problem, generator_config, key, name: str, yaml, parent, coun # replace count command_string = yaml['generate'] if '{count}' in command_string: - if self.has_count: + if 'count' in yaml: command_string = command_string.replace( '{count}', f'{self.count_index+1}' ) @@ -883,6 +882,8 @@ def add_testdata_to_cache(): # Step 1: run `generate:` if present. if t.generator: result = t.generator.run(bar, cwd, infile.stem, t.seed, t.config.retries) + if result.err is not None: + bar.debug('generator:', result.err) if not result.status: return @@ -1434,22 +1435,14 @@ def parse(key, name_gen, yaml, parent): for count_index in range(count): if count_index > 0: name = name_gen() - if count > 1: + if 'count' in yaml: name += f'-{count_index+1:0{len(str(count))}}' # If a list of testcases was passed and this one is not in it, skip it. if not self.process_testcase(parent.path / name): continue - t = TestcaseRule( - self.problem, - self, - key, - name, - yaml, - parent, - count_index if count > 1 else None, - ) + t = TestcaseRule(self.problem, self, key, name, yaml, parent, count_index) if t.path in self.known_cases: message( f'was already parsed. Skipping.', diff --git a/test/problems/identity/generators/generators.yaml b/test/problems/identity/generators/generators.yaml index 267572e7e..0a92dea8e 100644 --- a/test/problems/identity/generators/generators.yaml +++ b/test/problems/identity/generators/generators.yaml @@ -180,7 +180,7 @@ data: generate: stdout.py 700 {count} count: 1 - generate: - generate: stdout.py 701 + generate: stdout.py 701 {name} count: 3 - seed: generate: random_gen.py {seed:9} diff --git a/test/problems/identity/generators/stdout.py b/test/problems/identity/generators/stdout.py index 0963bf806..b09428d92 100644 --- a/test/problems/identity/generators/stdout.py +++ b/test/problems/identity/generators/stdout.py @@ -2,3 +2,5 @@ import sys print(sys.argv[1]) +if 2 < len(sys.argv): + print(sys.argv[2], file=sys.stderr)