Crates.io | seacan |
lib.rs | seacan |
version | 0.1.0 |
source | src |
created_at | 2021-05-17 21:04:53.533528 |
updated_at | 2021-05-18 15:03:21.13563 |
description | A library for interacting with cargo to build things |
homepage | |
repository | https://github.com/danielzfranklin/seacan |
max_upload_size | |
id | 398750 |
size | 48,715 |
A library for interacting with cargo to build things.
The main entrypoints are [bin::Compiler
] and [test::Compiler
].
Building binaries and examples is relatively simple, although we do use regexes to give you nicer errors in a few cases.
use seacan::bin;
let binary_artifact = bin::Compiler::bin("binary_name").release(true).compile()?;
let example_artifact = bin::Compiler::example("example_name").compile()?;
Example return value:
Ok(ExecutableArtifact {
package_id: PackageId { .. },
target: Target { .. },
profile: ArtifactProfile { .. },
features: [],
filenames: [ .. ],
executable: "/path/to/crate/.target/debug/example_name",
fresh: true,
})
Building tests is a bit more complicated. We expose all of Cargo's api for specifying which test artifacts to build. After we build each artifact we ask it for a list of all the test or benchmark functions in it that match the spec you provided.
use seacan::test;
let mut artifacts = test::Compiler::new(
test::NameSpec::exact("test_frobs_baz"),
test::TypeSpec::integration("frob_*"),
).compile()?;
Example return value:
Ok(vec![
Artifact {
artifact: ExecutableArtifact {
target: Target {
name: "frob_a",
..
},
...
},
tests: vec![
TestFn {
name: "test_frobs_baz",
test_type: TestType::Test,
},
],
},
Artifact {
artifact: ExecutableArtifact {
target: Target {
name: "frob_b",
..
},
...
},
tests: vec![],
}
])
Only the default test runner (libtest
) is supported.
A Sea Can is another word for a shipping container. Shipping containers were invented to provide a standard interface around handling cargo.