Skip to content

Add a test to (just) use all of the crates #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dep-tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
exclude = [
"c2-chacha:0.2.3", # よくわからない理由でビルドに失敗する
"derive_more:0.99.2", # 必要なファイルがexcludeされている
"jemalloc-ctl:0.3.3", # CI上で偶にSIGFPEで落ちる。テストがまずいのか根本的にまずいのか不明
"libm:0.1.4", # `#![deny(warnings)]`
"mac:0.1.1", # `#![deny(warnings)]`
"nom:5.0.1", # 必要なファイルがexcludeされている
Expand All @@ -14,9 +15,9 @@ exclude = [
"rand:0.6.5", # 現状同一の`name`のpackageは一つのworkspace内で共存できない
"rand_core:0.3.1", # よくわからない理由でビルドに失敗する
"rand_pcg:0.1.2", # 現状同一の`name`のpackageは一つのworkspace内で共存できない
"smallvec:0.6.13", # 現状同一の`name`のpackageは一つのworkspace内で共存できない
"syn:0.15.44", # よくわからない理由でビルドに失敗する
"syn:1.0.8", # よくわからない理由でビルドに失敗する
"smallvec:0.6.13", # 現状同一の`name`のpackageは一つのworkspace内で共存できない
]

# key部分でSPECを指定すると、そのSPECの対象のpackageはvalue部分で指定したtargetのみ実行する。
Expand Down
64 changes: 64 additions & 0 deletions examples/apg4b-a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
use aho_corasick as _;
use alga as _;
use approx as _;
use ascii as _;
use bitset_fixed as _;
use defmac as _;
use derive_more as _;
use derive_new as _;
use either as _;
use euclid as _;
use fixedbitset as _;
use getrandom as _;
use if_chain as _;
use im_rc as _;
use indexmap as _;
use itertools as _;
use itertools_num as _;
use lazy_static as _;
use libm as _;
use mac as _;
use maplit as _;
use modtype as _;
use nalgebra as _;
use ndarray as _;
use nom as _;
use num as _;
use num_bigint as _;
use num_complex as _;
use num_derive as _;
use num_integer as _;
use num_iter as _;
use num_rational as _;
use num_traits as _;
use ordered_float as _;
use permutohedron as _;
use petgraph as _;
use primal as _;
use primal_check as _;
use primal_estimate as _;
use primal_sieve as _;
use proconio as _;
use rand as _;
use rand_chacha as _;
use rand_core as _;
use rand_distr as _;
use rand_hc as _;
use rand_pcg as _;
use regex as _;
use rustc_hash as _;
use smallvec as _;
use strsim as _;
use superslice as _;
use take_mut as _;
use text_io as _;
use whiteread as _;

#[cfg(feature = "jemalloc-ctl")]
use jemalloc_ctl as _;
#[cfg(feature = "jemallocator")]
use jemallocator as _;

fn main() {
println!("Hello, world!");
}
8 changes: 6 additions & 2 deletions examples/tests.ron
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
(
tests: {
"apg4b-a": (
name: "APG4b: A - 1.00.はじめに",
matching: ExactWhole,
),
"practice-a": (
name: "practice contest: A - Welcome to AtCoder",
word_match: Exact,
matching: ExactWords,
),
"arc065-c": (
name: "ABC049 / ARC065: C - 白昼夢 / Daydream",
word_match: Exact,
matching: ExactWords,
),
}
)
Empty file.
1 change: 1 addition & 0 deletions examples/testsets/apg4b-a/out/sample_01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello, world!
35 changes: 16 additions & 19 deletions tools/test-with-generated-opts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use std::fs::{self, File};
use std::io::{self, Read as _, Write as _};
use std::path::{Path, PathBuf};
use std::process::{Command, Output, Stdio};
use std::str::SplitWhitespace;
use std::time::Instant;

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

let tests = tests
.into_iter()
.map(|(slug, Test { name, word_match })| {
.map(|(slug, Test { name, matching })| {
let src = Path::new("./examples").join(&slug).with_extension("rs");
let testsets = Path::new("./examples/testsets").join(&slug);
let binary = compile(&src, tempdir.path(), &slug)?;
Ok((name, word_match, testsets, binary))
Ok((name, matching, testsets, binary))
})
.collect::<anyhow::Result<Vec<_>>>()?;

for (name, word_match, testsets, binary) in tests {
test(&name, word_match, &testsets, &binary)?;
for (name, matching, testsets, binary) in tests {
test(&name, matching, &testsets, &binary)?;
}
Ok(())
}
Expand Down Expand Up @@ -135,12 +134,7 @@ fn compile(src: &Path, tempdir: &Path, dir_name: &str) -> anyhow::Result<PathBuf
Ok(out)
}

fn test(
task_name: &str,
word_match: WordMatch,
testsets: &Path,
binary: &Path,
) -> anyhow::Result<()> {
fn test(task_name: &str, matching: Matching, testsets: &Path, binary: &Path) -> anyhow::Result<()> {
let testsets = {
let find_files = |dir: &str| -> _ {
fs::read_dir(testsets.join(dir))?
Expand Down Expand Up @@ -199,8 +193,7 @@ fn test(
};

let time = (stop - start).as_millis();
let (expected, actual) = (expected.split_whitespace(), actual.split_whitespace());
let verdict = if status.success() && word_match.accepts(expected, actual) {
let verdict = if status.success() && matching.accepts(&expected, &actual) {
"AC"
} else if status.success() {
"WA"
Expand All @@ -223,18 +216,22 @@ struct Tests {
#[derive(Debug, Deserialize)]
struct Test {
name: String,
word_match: WordMatch,
matching: Matching,
}

#[derive(Debug, Clone, Copy, Deserialize)]
enum WordMatch {
Exact,
enum Matching {
ExactWhole,
ExactWords,
}

impl WordMatch {
fn accepts(self, expected: SplitWhitespace, actual: SplitWhitespace) -> bool {
impl Matching {
fn accepts(self, expected: &str, actual: &str) -> bool {
match self {
WordMatch::Exact => itertools::equal(expected, actual),
Matching::ExactWhole => expected == actual,
Matching::ExactWords => {
itertools::equal(expected.split_whitespace(), actual.split_whitespace())
}
}
}
}