Skip to content
This repository has been archived by the owner on Dec 29, 2021. It is now read-only.

fix(cargo): Avoid cargo run #111

Closed
wants to merge 2 commits into from
Closed

fix(cargo): Avoid cargo run #111

wants to merge 2 commits into from

Conversation

epage
Copy link
Collaborator

@epage epage commented May 25, 2018

This switches us from using cargo run to cargo build, reading where
the binary is placed, and callin that instead.

Fixes #95 because the user changing the CWD doesn't impact cargo build.

Fixes #79 because there is no cargo output when capturing the user's
stdout/stderr.

Fixes #51 because the user changing the environment doesn't impact
cargo build.

This is a step towards working around #100 because we can allow a user
to cache the result of cargo build.

epage added 2 commits May 25, 2018 14:03
This switches us from using `cargo run` to `cargo build`, reading where
the binary is placed, and callin that instead.

Fixes assert-rs#95 because the user changing the `CWD` doesn't impact `cargo
build`.

Fixes assert-rs#79 because there is no `cargo` output when capturing the user's
stdout/stderr.

Fixes assert-rs#51 because the user changing the environment doesn't impact
`cargo build`.

This is a step towards working around assert-rs#100 because we can allow a user
to cache the result of `cargo build`.
filenames: Vec<&'a str>,
}

fn filenames(msg: cargo::Message, kind: &str) -> Option<String> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve name

].into_iter()
.map(OsString::from)
.collect(),
pub fn main_binary() -> Result<Self, failure::Error> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define a proper error for this and related functions

const CURRENT_TARGET: &str = include_str!(concat!(env!("OUT_DIR"), "/current_target.txt"));

#[derive(Debug)]
pub struct Cargo {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new file is generating a lot of warnings from unused code.

I developed more than I'd need. I plan to eventually split this out into is own crate. It'll be reused by stager and other tools I'm working on that need to run cargo programmatically but don't want to link against cargo (slow to build, . This was a testing ground for the idea.

@epage
Copy link
Collaborator Author

epage commented May 29, 2018

This is superseded by https://github.com/assert-rs/assert_cmd

@epage epage closed this May 29, 2018
@epage epage deleted the cargo branch May 29, 2018 12:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant