seacan

Crates.ioseacan
lib.rsseacan
version0.1.0
sourcesrc
created_at2021-05-17 21:04:53.533528
updated_at2021-05-18 15:03:21.13563
descriptionA library for interacting with cargo to build things
homepage
repositoryhttps://github.com/danielzfranklin/seacan
max_upload_size
id398750
size48,715
Daniel Franklin (danielzfranklin)

documentation

README

seacan

Version 0.1.0 License MIT

A library for interacting with cargo to build things.

The main entrypoints are [bin::Compiler] and [test::Compiler].

Binaries and examples

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,
})

Tests

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.

Why the name?

A Sea Can is another word for a shipping container. Shipping containers were invented to provide a standard interface around handling cargo.

Commit count: 13

cargo fmt