Skip to content

Commit deb6830

Browse files
authored
Merge pull request #32 from qryxip/ja-all-enabled-apg4b-a
Add a test to (just) `use` all of the crates
2 parents 9d614b0 + c230626 commit deb6830

File tree

6 files changed

+89
-22
lines changed

6 files changed

+89
-22
lines changed

dep-tests.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
exclude = [
55
"c2-chacha:0.2.3", # よくわからない理由でビルドに失敗する
66
"derive_more:0.99.2", # 必要なファイルがexcludeされている
7+
"jemalloc-ctl:0.3.3", # CI上で偶にSIGFPEで落ちる。テストがまずいのか根本的にまずいのか不明
78
"libm:0.1.4", # `#![deny(warnings)]`
89
"mac:0.1.1", # `#![deny(warnings)]`
910
"nom:5.0.1", # 必要なファイルがexcludeされている
@@ -14,9 +15,9 @@ exclude = [
1415
"rand:0.6.5", # 現状同一の`name`のpackageは一つのworkspace内で共存できない
1516
"rand_core:0.3.1", # よくわからない理由でビルドに失敗する
1617
"rand_pcg:0.1.2", # 現状同一の`name`のpackageは一つのworkspace内で共存できない
18+
"smallvec:0.6.13", # 現状同一の`name`のpackageは一つのworkspace内で共存できない
1719
"syn:0.15.44", # よくわからない理由でビルドに失敗する
1820
"syn:1.0.8", # よくわからない理由でビルドに失敗する
19-
"smallvec:0.6.13", # 現状同一の`name`のpackageは一つのworkspace内で共存できない
2021
]
2122

2223
# key部分でSPECを指定すると、そのSPECの対象のpackageはvalue部分で指定したtargetのみ実行する。

examples/apg4b-a.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
use aho_corasick as _;
2+
use alga as _;
3+
use approx as _;
4+
use ascii as _;
5+
use bitset_fixed as _;
6+
use defmac as _;
7+
use derive_more as _;
8+
use derive_new as _;
9+
use either as _;
10+
use euclid as _;
11+
use fixedbitset as _;
12+
use getrandom as _;
13+
use if_chain as _;
14+
use im_rc as _;
15+
use indexmap as _;
16+
use itertools as _;
17+
use itertools_num as _;
18+
use lazy_static as _;
19+
use libm as _;
20+
use mac as _;
21+
use maplit as _;
22+
use modtype as _;
23+
use nalgebra as _;
24+
use ndarray as _;
25+
use nom as _;
26+
use num as _;
27+
use num_bigint as _;
28+
use num_complex as _;
29+
use num_derive as _;
30+
use num_integer as _;
31+
use num_iter as _;
32+
use num_rational as _;
33+
use num_traits as _;
34+
use ordered_float as _;
35+
use permutohedron as _;
36+
use petgraph as _;
37+
use primal as _;
38+
use primal_check as _;
39+
use primal_estimate as _;
40+
use primal_sieve as _;
41+
use proconio as _;
42+
use rand as _;
43+
use rand_chacha as _;
44+
use rand_core as _;
45+
use rand_distr as _;
46+
use rand_hc as _;
47+
use rand_pcg as _;
48+
use regex as _;
49+
use rustc_hash as _;
50+
use smallvec as _;
51+
use strsim as _;
52+
use superslice as _;
53+
use take_mut as _;
54+
use text_io as _;
55+
use whiteread as _;
56+
57+
#[cfg(feature = "jemalloc-ctl")]
58+
use jemalloc_ctl as _;
59+
#[cfg(feature = "jemallocator")]
60+
use jemallocator as _;
61+
62+
fn main() {
63+
println!("Hello, world!");
64+
}

examples/tests.ron

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
(
22
tests: {
3+
"apg4b-a": (
4+
name: "APG4b: A - 1.00.はじめに",
5+
matching: ExactWhole,
6+
),
37
"practice-a": (
48
name: "practice contest: A - Welcome to AtCoder",
5-
word_match: Exact,
9+
matching: ExactWords,
610
),
711
"arc065-c": (
812
name: "ABC049 / ARC065: C - 白昼夢 / Daydream",
9-
word_match: Exact,
13+
matching: ExactWords,
1014
),
1115
}
1216
)

examples/testsets/apg4b-a/in/sample_01.txt

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello, world!

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

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use std::fs::{self, File};
1414
use std::io::{self, Read as _, Write as _};
1515
use std::path::{Path, PathBuf};
1616
use std::process::{Command, Output, Stdio};
17-
use std::str::SplitWhitespace;
1817
use std::time::Instant;
1918

2019
#[derive(StructOpt, Debug)]
@@ -56,16 +55,16 @@ fn main() -> anyhow::Result<()> {
5655

5756
let tests = tests
5857
.into_iter()
59-
.map(|(slug, Test { name, word_match })| {
58+
.map(|(slug, Test { name, matching })| {
6059
let src = Path::new("./examples").join(&slug).with_extension("rs");
6160
let testsets = Path::new("./examples/testsets").join(&slug);
6261
let binary = compile(&src, tempdir.path(), &slug)?;
63-
Ok((name, word_match, testsets, binary))
62+
Ok((name, matching, testsets, binary))
6463
})
6564
.collect::<anyhow::Result<Vec<_>>>()?;
6665

67-
for (name, word_match, testsets, binary) in tests {
68-
test(&name, word_match, &testsets, &binary)?;
66+
for (name, matching, testsets, binary) in tests {
67+
test(&name, matching, &testsets, &binary)?;
6968
}
7069
Ok(())
7170
}
@@ -135,12 +134,7 @@ fn compile(src: &Path, tempdir: &Path, dir_name: &str) -> anyhow::Result<PathBuf
135134
Ok(out)
136135
}
137136

138-
fn test(
139-
task_name: &str,
140-
word_match: WordMatch,
141-
testsets: &Path,
142-
binary: &Path,
143-
) -> anyhow::Result<()> {
137+
fn test(task_name: &str, matching: Matching, testsets: &Path, binary: &Path) -> anyhow::Result<()> {
144138
let testsets = {
145139
let find_files = |dir: &str| -> _ {
146140
fs::read_dir(testsets.join(dir))?
@@ -199,8 +193,7 @@ fn test(
199193
};
200194

201195
let time = (stop - start).as_millis();
202-
let (expected, actual) = (expected.split_whitespace(), actual.split_whitespace());
203-
let verdict = if status.success() && word_match.accepts(expected, actual) {
196+
let verdict = if status.success() && matching.accepts(&expected, &actual) {
204197
"AC"
205198
} else if status.success() {
206199
"WA"
@@ -223,18 +216,22 @@ struct Tests {
223216
#[derive(Debug, Deserialize)]
224217
struct Test {
225218
name: String,
226-
word_match: WordMatch,
219+
matching: Matching,
227220
}
228221

229222
#[derive(Debug, Clone, Copy, Deserialize)]
230-
enum WordMatch {
231-
Exact,
223+
enum Matching {
224+
ExactWhole,
225+
ExactWords,
232226
}
233227

234-
impl WordMatch {
235-
fn accepts(self, expected: SplitWhitespace, actual: SplitWhitespace) -> bool {
228+
impl Matching {
229+
fn accepts(self, expected: &str, actual: &str) -> bool {
236230
match self {
237-
WordMatch::Exact => itertools::equal(expected, actual),
231+
Matching::ExactWhole => expected == actual,
232+
Matching::ExactWords => {
233+
itertools::equal(expected.split_whitespace(), actual.split_whitespace())
234+
}
238235
}
239236
}
240237
}

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