batch_run

Crates.iobatch_run
lib.rsbatch_run
version1.2.0
sourcesrc
created_at2019-09-25 18:12:40.910974
updated_at2020-04-30 08:26:57.688301
descriptionBatch runner for arbitrary Rust files within current project
homepage
repositoryhttps://github.com/cerberuser/batch_run
max_upload_size
id167604
size74,468
(Cerber-Ursi)

documentation

https://docs.rs/batch_run

README

Batch Run

Latest Version Rust Documentation

batch_run is a runner for a set of Rust source files, based on dtolnay's trybuild. It can be useful when you have a bunch of Rust sources which are not complex enough to be packed into dedicated crates, but which are (by their meaning) not just integration test cases. It also checks for output correctness, either on compile-time (for compile_fail cases) or at runtime (for run_pass cases).

[dependencies]
batch_run = "1.0"

Compiler support: requires rustc 1.31+


Compile-fail cases

A minimal batch_run setup looks like this:

fn main() {
    let b = batch_run::Batch::new();
    b.compile_fail("batches/ui/*.rs");
    match b.run() {
        Ok(()) => {},
        Err(err) => println!("{:?}", err)
    };
}

This program will individually compile each of the source files matching the glob pattern, expect them to fail to compile, and assert that the compiler's error message matches an adjacently named *.stderr file containing the expected output (same file name as the test except with a different extension). If it doesn't match, the program will print the error message with expected vs actual compiler output.

Dependencies listed under [dependencies] and [dev-dependencies] in the project's Cargo.toml are accessible from within the batch, just like on ordinary cargo run.

A compile_fail case that fails to fail to compile is also a failure.


Run-pass cases

In the run_pass cases, we not only check that the code compiles, but also actually run it and match the stdout/stderr output with the corresponding *.stdout/*.stderr files.

You can mix compile_fail and run_pass cases in one batch:

fn main() {
    let t = batch_run::Batch::new();
    t.run_pass("batches/01-parse-header.rs");
    t.run_pass("batches/02-parse-body.rs");
    t.compile_fail("batches/03-expand-four-errors.rs");
    t.run_pass("batches/04-paste-ident.rs");
    t.run_pass("batches/05-repeat-section.rs");
}

Details

That's the entire API.


Workflow

(TODO)

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Commit count: 133

cargo fmt