Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE-APACHE remove dependency to crate build-helper Jul 28, 2019
LICENSE-MIT remove dependency to crate build-helper Jul 28, 2019

MIT License Apache 2.0 Licensed

Rust Test-Generator Example

This is an example demonstrating useage of the Rust build-script dependencies generator build-deps and the test-function generator test-generator.

This example is using a package layout as follows:

├── Cargo.toml
├── res
│   ├── set1
│   │   ├── expect.txt
│   │   └── input.txt
│   ├── set2
│   │   ├── expect.txt
│   │   └── input.txt
│   └── set3
│       ├── expect.txt
│       └── input.txt
├── src
│   └──
├── benches
│   └──
└── tests

This is the package layout of the example package, here the tests are located in file and bench-tests are located in file; the tests and benches depend on the content of the res/ directory.

The build-script is used to realize conditional re-runs, in case a resource-file has changed or (more interesting) if new resource-files have been added to the sub-folder structure res/.

Conditional Build Process

The Test-Funciton-Generator is executed every time a new resource file is added or one of the existing files is changed. The conditional build is realized using the crate build-deps, expanding a glob pattern such as "res/*/input.txt", and communicating this list to the cargo-process via an internal Cargo-API.

The following diagram illustrates the integration of the build-script into the conditional cargo build-process.

 <Diagram - Build Script Intregration>

Executing the tests and benchs

The macro test_resources is compatible to stable Rust-compiler, whereas benchmarking is using an unstable compiler feature and therefor bench_resources requires the nightly Rust-compiler.

Executing the tests, either with stable or nightly Rust

cargo test

Executing the benchmarks requires the nightly release of the Rust-compiler

cargo +nightly bench 
You can’t perform that action at this time.