Skip to content

Commit a3f6852

Browse files
committed
use multipass dir
1 parent 3dfd9e5 commit a3f6852

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2604
-9
lines changed

bin/run.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ def _continue_with_tle(self, verdict, timeout_expired):
208208
def _prepare_nextpass(self, nextpass):
209209
if not nextpass or not nextpass.is_file():
210210
return False
211-
# clear all files outside of feedbackdir
211+
# TODO: keep feedback files and concatenate them?
212+
# - judgemessage.txt
213+
# - judgeerror.txt
212214
for f in self.tmpdir.iterdir():
213215
if f == self.feedbackdir:
214216
continue
@@ -217,7 +219,15 @@ def _prepare_nextpass(self, nextpass):
217219
elif f.exists():
218220
shutil.rmtree(f)
219221
# use nextpass.in as next input
220-
shutil.move(nextpass, self.in_path)
222+
nextpass.rename(self.in_path)
223+
# clear all files outside of "feedbackdir / multipass"
224+
for f in self.feedbackdir.iterdir():
225+
if f == self.feedbackdir / "multipass":
226+
continue
227+
if f.is_file():
228+
f.unlink()
229+
elif f.exists():
230+
shutil.rmtree(f)
221231
return True
222232

223233
def _validate_output(self, bar: BAR_TYPE) -> Optional[ExecResult]:
@@ -443,7 +453,7 @@ def process_run(run: Run):
443453
for f in run.feedbackdir.iterdir():
444454
if f.name.startswith("."):
445455
continue # skip "hidden" files
446-
if f.name in ["judgemessage.txt", "judgeerror.txt"]:
456+
if f.name in ["judgemessage.txt", "judgeerror.txt", "multipass"]:
447457
continue
448458
if f.name.startswith("judgeimage.") or f.name.startswith("teamimage."):
449459
data += f"{f.name}: {shorten_path(self.problem, f.parent) / f.name}\n"

bin/validate.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,9 @@ def run(
403403
cwd, constraints_path, arglist = self._run_helper(testcase, constraints, args)
404404
if not isinstance(mode, Mode):
405405
cwd = mode.feedbackdir
406+
if self.problem.multi_pass:
407+
multipassdir = cwd / "multipass"
408+
multipassdir.mkdir(parents=True, exist_ok=True)
406409
invocation = self.run_command + [in_path, ans_path, cwd]
407410

408411
with path.open("rb") as file:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#GENERATED BY BAPCtools
2+
data/*
3+
!data/sample/

test/problems/alternativeencryption/data/sample/001.ans

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
encrypt
2+
3
3+
plaintext
4+
nwerc
5+
correct
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<encrypt
2+
<3
3+
<plaintext
4+
<nwerc
5+
<correct
6+
>encrypted
7+
>delft
8+
>balloon
9+
---
10+
<decrypt
11+
<3
12+
<encrypted
13+
<delft
14+
<balloon
15+
>plaintext
16+
>nwerc
17+
>correct
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/python3
2+
from random import seed, choice
3+
from string import ascii_lowercase as sigma
4+
import sys
5+
6+
7+
def randstr(n):
8+
return "".join([choice(sigma) for _ in range(n)])
9+
10+
11+
# Init seed with first argument
12+
seed(int(sys.argv[1]))
13+
n = int(sys.argv[2])
14+
command = " ".join(sys.argv[3:]).encode("ascii").decode("unicode_escape")
15+
16+
print("encrypt")
17+
print(n)
18+
for i in range(n):
19+
print(eval(command))
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python3
2+
import sys
3+
import random
4+
5+
maxlen = 100
6+
7+
random.seed(int(sys.argv[1]))
8+
9+
10+
def letter(i):
11+
return chr(ord("a") + i)
12+
13+
14+
def randomstring(len):
15+
letters = [letter(random.randint(0, 25)) for _ in range(len)]
16+
string = "".join(letters)
17+
return string
18+
19+
20+
strings = []
21+
22+
# Single letter
23+
for i in range(0, 26):
24+
strings.append(letter(i))
25+
26+
# Fixed strings
27+
strings.append("aaaaaaaaaa")
28+
strings.append("abcdefghijklmnopqrstuvwxyz")
29+
strings.append("dejavu")
30+
strings.append("dejavu")
31+
strings.append("dejavu")
32+
33+
# Random strings, random length
34+
for _ in range(100):
35+
n = random.randint(10, maxlen)
36+
strings.append(randomstring(n))
37+
38+
# Random strings, max length
39+
for _ in range(20):
40+
strings.append(randomstring(maxlen))
41+
42+
43+
# Print strings
44+
print(len(strings))
45+
for string in strings:
46+
print(string)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
solution: /submissions/accepted/mzuenni_sample.cpp
2+
3+
testdata.yaml:
4+
output_validator_args:
5+
- case_sensitive
6+
data:
7+
sample:
8+
data:
9+
- "":
10+
in: |
11+
encrypt
12+
3
13+
plaintext
14+
nwerc
15+
correct
16+
17+
secret:
18+
data:
19+
- min:
20+
in: |
21+
encrypt
22+
1
23+
a
24+
- letters: eval.py 0 26 sigma[i % 26]
25+
- letters: eval.py 0 1000 sigma[i % 26]
26+
- random_equal: eval.py {seed} 1000 sigma[i % 26] * randrange(1, 101)
27+
- max_equal: eval.py 0 1000 sigma[i % 26] * 100
28+
- random2: eval.py {seed} 1000 randstr(2)
29+
- random3: eval.py {seed} 1000 randstr(3)
30+
- max_random: eval.py {seed} 1000 randstr(100)
31+
32+
- random:
33+
generate: eval.py {seed} 1000 randstr(randrange(1, 101))
34+
count: 100
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "validation.h"
2+
3+
// Check the grammar of the input files.
4+
// You should also check properties of the input.
5+
// E.g., check that a graph is connected.
6+
7+
int main(int argc, char* argv[]) {
8+
InputValidator v(argc, argv);
9+
v.test_strings({"encrypt", "decrypt"}, "action");
10+
v.newline();
11+
int n = v.read_integer("n", 1, 1000);
12+
v.newline();
13+
for(int i = 0; i < n; i++) {
14+
v.read_string("s", 1, 100, "abcdefghijklmnopqrstuvwxyz");
15+
v.newline();
16+
}
17+
}

0 commit comments

Comments
 (0)