Skip to content

Commit bb7e640

Browse files
committed
Modify the format of test-with-generated-opts.toml
1 parent 001d2b7 commit bb7e640

File tree

2 files changed

+83
-43
lines changed

2 files changed

+83
-43
lines changed

test-with-generated-opts.toml

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,87 @@
11
# 手元でDropboxのテストケース(ある場合)で確認し、サンプルに含まれていないやつが大きいときはそれらをGitに入れない。
22
# その場合CI上でもサンプルだけテストする。(Dropboxから引っ張るのも面倒だし何より誰のアカウントを使うかという問題がある)
33

4-
[tests.abc054-c]
4+
[examples.abc054-c]
55
name = "ABC054: C - One-stroke Path"
6+
url = "https://atcoder.jp/contests/abc054/tasks/abc054_c"
67
matching = "Words"
78

8-
[tests.abc057-b]
9+
[examples.abc057-b]
910
name = "ABC057: B - Checkpoints"
11+
url = "https://atcoder.jp/contests/abc057/tasks/abc057_b"
1012
matching = "Words"
1113

12-
[tests.abc084-d]
14+
[examples.abc084-d]
1315
name = "ABC084: D - 2017-like Number"
16+
url = "https://atcoder.jp/contests/abc084/tasks/abc084_d"
1417
matching = "Words"
1518

16-
[tests.abc118-b]
19+
[examples.abc118-b]
1720
name = "ABC118: B - Foods Loved by Everyone"
21+
url = "https://atcoder.jp/contests/abc118/tasks/abc118_b"
1822
matching = "Words"
1923

20-
[tests.abc120-d]
24+
[examples.abc120-d]
2125
name = "ABC120: D - Decayed Bridges"
26+
url = "https://atcoder.jp/contests/abc120/tasks/abc120_d"
2227
matching = "Words"
2328

24-
[tests.abc121-b]
29+
[examples.abc121-b]
2530
name = "ABC121: B - Can you solve this?"
31+
url = "https://atcoder.jp/contests/abc121/tasks/abc121_b"
2632
matching = "Words"
2733

28-
[tests.abc129-f]
34+
[examples.abc129-f]
2935
name = "ABC129: F - Takahashi's Basics in Education and Learning"
36+
url = "https://atcoder.jp/contests/abc129/tasks/abc129_f"
3037
matching = "Words"
3138

32-
[tests.abc142-d]
39+
[examples.abc142-d]
3340
name = "ABC142: D - Disjoint Set of Common Divisors"
41+
url = "https://atcoder.jp/contests/abc142/tasks/abc142_d"
3442
matching = "Words"
3543

36-
[tests.abc144-d]
44+
[examples.abc144-d]
3745
name = "ABC144: D - Water Bottle"
46+
url = "https://atcoder.jp/contests/abc144/tasks/abc144_d"
3847
matching = { FloatOr = { abs = 1e-6, rel = 1e-6 } }
3948

40-
[tests.apg4b-a]
49+
[examples.apg4b-a]
4150
name = "APG4b: A - 1.00.はじめに"
51+
url = "https://atcoder.jp/contests/APG4b/tasks/APG4b_a"
4252
matching = "Exact"
4353

44-
[tests.apg4b-ex25]
54+
[examples.apg4b-ex25]
4555
name = "APG4b: EX25 - 集合の操作 / 3.05"
56+
url = "https://atcoder.jp/contests/APG4b/tasks/APG4b_bx"
4657
matching = "Words"
4758

48-
[tests.apg4b-ex26]
59+
[examples.apg4b-ex26]
4960
name = "APG4b: EX26 - 電卓を作ろう3 / 3.06"
61+
url = "https://atcoder.jp/contests/APG4b/tasks/APG4b_bw"
5062
matching = "Exact"
5163

52-
[tests.arc065-c]
64+
[examples.arc065-c]
5365
name = "ABC049 / ARC065: C - 白昼夢 / Daydream"
66+
url = "https://atcoder.jp/contests/arc065/tasks/arc065_a"
5467
matching = "Words"
5568

56-
[tests.arc084-c]
69+
[examples.arc084-c]
5770
name = "ABC077 / ARC084: C - Snuke Festival"
71+
url = "https://atcoder.jp/contests/arc084/tasks/arc084_a"
5872
matching = "Words"
5973

60-
[tests.atc001-b]
74+
[examples.atc001-b]
6175
name = "ATC001: B - Union Find"
76+
url = "https://atcoder.jp/contests/atc001/tasks/unionfind_a"
6277
matching = "Words"
6378

64-
[tests.atc002-b]
79+
[examples.atc002-b]
6580
name = "ATC002: B - n^p mod m"
81+
url = "https://atcoder.jp/contests/atc002/tasks/atc002_b"
6682
matching = "Words"
6783

68-
[tests.practice-a]
84+
[examples.practice-a]
6985
name = "practice contest: A - Welcome to AtCoder"
86+
url = "https://atcoder.jp/contests/practice/tasks/practice_1"
7087
matching = "Words"

tools/test-with-generated-opts/src/main.rs

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,34 @@ fn main() -> anyhow::Result<()> {
5454
.filter_module("test_with_generated_opts", LevelFilter::Info)
5555
.init();
5656

57-
let Tests { tests } = fs::read_to_string(&config)
57+
let Config { examples } = fs::read_to_string(&config)
5858
.map_err(anyhow::Error::from)
5959
.and_then(|s| toml::from_str(&s).map_err(Into::into))
6060
.with_context(|| format!("Failed to read {}", config.display()))?;
6161

6262
let tempdir = TempDir::new("atcoder-rust-base-test-with-generated-opts")?;
6363

64-
let tests = tests
64+
let tests = examples
6565
.into_iter()
66-
.map(|(slug, Test { name, matching })| {
67-
let src = Path::new("./examples").join(&slug).with_extension("rs");
68-
let testsets = Path::new("./examples/testsets").join(&slug);
69-
let binary = compile(&src, tempdir.path(), &slug)?;
70-
Ok((name, matching, testsets, binary))
71-
})
66+
.map(
67+
|(
68+
slug,
69+
Example {
70+
name,
71+
url,
72+
matching,
73+
},
74+
)| {
75+
let src = Path::new("./examples").join(&slug).with_extension("rs");
76+
let testsets = Path::new("./examples/testsets").join(&slug);
77+
let binary = compile(&src, tempdir.path(), &slug)?;
78+
Ok((name, url, matching, testsets, binary))
79+
},
80+
)
7281
.collect::<anyhow::Result<Vec<_>>>()?;
7382

74-
for (name, matching, testsets, binary) in tests {
75-
test(&name, matching, &testsets, &binary)?;
83+
for (name, url, matching, testsets, binary) in tests {
84+
test(&name, &url, matching, &testsets, &binary)?;
7685
}
7786
Ok(())
7887
}
@@ -142,20 +151,31 @@ fn compile(src: &Path, tempdir: &Path, dir_name: &str) -> anyhow::Result<PathBuf
142151
Ok(out)
143152
}
144153

145-
fn test(task_name: &str, matching: Matching, testsets: &Path, binary: &Path) -> anyhow::Result<()> {
154+
fn test(
155+
task_name: &str,
156+
url: &str,
157+
matching: Matching,
158+
testsets: &Path,
159+
binary: &Path,
160+
) -> anyhow::Result<()> {
146161
let testsets = {
147-
let find_files = |dir: &str| -> _ {
148-
fs::read_dir(testsets.join(dir))?
149-
.map(|entry| {
150-
let path = entry?.path();
151-
let name = path
152-
.file_stem()
153-
.unwrap_or_default()
154-
.to_string_lossy()
155-
.into_owned();
156-
Ok((name, path))
162+
let find_files = |dir_file_name: &str| -> _ {
163+
let dir = testsets.join(dir_file_name);
164+
fs::read_dir(&dir)
165+
.and_then(|read_dir| {
166+
read_dir
167+
.map(|entry| {
168+
let path = entry?.path();
169+
let name = path
170+
.file_stem()
171+
.unwrap_or_default()
172+
.to_string_lossy()
173+
.into_owned();
174+
Ok((name, path))
175+
})
176+
.collect::<io::Result<HashMap<_, _>>>()
157177
})
158-
.collect::<io::Result<HashMap<_, _>>>()
178+
.with_context(|| format!("Failed to read {}", dir.display()))
159179
};
160180

161181
let (ins, outs) = (find_files("in")?, find_files("out")?);
@@ -168,7 +188,9 @@ fn test(task_name: &str, matching: Matching, testsets: &Path, binary: &Path) ->
168188
.collect::<BTreeMap<_, _>>()
169189
};
170190

171-
info!("Testing {} for {:?}", binary.display(), task_name);
191+
info!("Testing {}", binary.display());
192+
info!(" Name: {:?}", task_name);
193+
info!(" URL: {}", url);
172194

173195
for (test_name, (path_in, path_out)) in testsets {
174196
fn read_to_string(path: &Path) -> anyhow::Result<String> {
@@ -218,13 +240,14 @@ fn test(task_name: &str, matching: Matching, testsets: &Path, binary: &Path) ->
218240
}
219241

220242
#[derive(Debug, Deserialize)]
221-
struct Tests {
222-
tests: IndexMap<String, Test>,
243+
struct Config {
244+
examples: IndexMap<String, Example>,
223245
}
224246

225247
#[derive(Debug, Deserialize)]
226-
struct Test {
248+
struct Example {
227249
name: String,
250+
url: String,
228251
matching: Matching,
229252
}
230253

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy