Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #78 #79

Merged
merged 2 commits into from
Dec 29, 2017
Merged

fix #78 #79

merged 2 commits into from
Dec 29, 2017

Conversation

hdhoang
Copy link
Contributor

@hdhoang hdhoang commented Oct 10, 2017

These paths come from the rustc build environment, so I suppose cleaning their *.rmeta files here is appropriate.

I'm ignoring errors here because:

  • These are build artifacts
  • E0464 would return later in the build

@laumann
Copy link
Collaborator

laumann commented Oct 10, 2017

@hdhoang Thanks for the PR!

The change looks pretty straight-forward, but I'm wondering if this added functionality belongs in link_deps() though - I see that the paths we want to clean may be constructed by link_deps(). However, it is not required to use link_deps(), but you might still want to functionality to clean out *.rmeta files. Could it be implemented as a separate method on Config?

@hdhoang
Copy link
Contributor Author

hdhoang commented Oct 10, 2017

I have moved this functionality to a separate method, and add a note about it in the README

src/common.rs Outdated
"LD_LIBRARY_PATH"
};

let lib_paths = env::var(varname).unwrap_or_else(|e| {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why inspect the PATH variable? Isn't it the paths that end up on self.target_rustcflags that should be inspected?

let mut cfg = compiletest::Config::default();
cfg.target_rustcflags = Some(" -L target/debug");
cfg.clean_rmeta();

Maybe clean_rmeta() actually needs to inspect cfg.build_base?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, just curious, would it work any differently if you used the tmp feature?

Copy link
Contributor Author

@hdhoang hdhoang Oct 11, 2017

Choose a reason for hiding this comment

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

test-project uses tmp, while the example hdhoang/testee in #78 doesn't, and they behave the same.

AIUI, from the test's perspective, the tested crate's rlib is a dependency, thus it will be placed in the workspace's target/{debug,release}/deps. cargo check (--release) also places its rmeta there, causing this conflict.

mgattozzi/github-rs#109 is an example where breaking compile-tests out into another workspace avoids this issue. diesel does the same, but in that case there are genuine rlib conflicts.

I couldn't see that directory anywhere in Config's members, so I resorted to crudely iterating over dylib_env_var. (sidenote: I will update this to use dylib_env_var after #80 merges)

Copy link
Contributor Author

@hdhoang hdhoang Oct 12, 2017

Choose a reason for hiding this comment

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

This target/{profile}/deps path is defined in cargo::ops::cargo_rustc::Layout, used by Context and isn't exposed by that struct. I think the most we can do is constructing it from the build profile. Should I switch over to that, if possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I see what you mean now. I will look for it in target_rustcflags.

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

src/common.rs Outdated
};

let lib_paths = env::var(varname).unwrap_or_else(|e| {
panic!(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this be one line? I really don't like how rustfmt splits this on five lines...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will restore link_deps's formatting.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, thanks :-)

@hdhoang
Copy link
Contributor Author

hdhoang commented Oct 12, 2017

I have reworked clean_rmeta. Please have a look.

@antoyo
Copy link

antoyo commented Dec 10, 2017

@laumann Could you please take a look at this PR?
Thank you.

@laumann
Copy link
Collaborator

laumann commented Dec 11, 2017

@antoyo Yes, sorry, I completely forgot about it! Thanks for reminding me!

@hdhoang I'll have a look now, sorry for the delay!

@@ -233,6 +234,26 @@ impl Config {
self.target_rustcflags = Some(flags);
}

/// Remove rmeta files from target `deps` directory
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd like a little more documentation here, to explain why this is useful. IIRC this feature is useful when working with cargo check vs cargo build because the two methods don't share any information.

@laumann
Copy link
Collaborator

laumann commented Dec 11, 2017

@hdhoang LGTM modulo a little more documentation of clean_rmeta()

This method removes */deps/*.rmeta files in directories in rustcflags.
These files are created by `cargo check`, and conflict with `cargo
build` rlib files, causing E0464 for tests which use the parent crate.

Fix #78
@hdhoang
Copy link
Contributor Author

hdhoang commented Dec 29, 2017

I have worked the commit message into the doc comment. Please have a look.

@laumann
Copy link
Collaborator

laumann commented Dec 29, 2017

Did you just push this or did I completely miss it? Either way it looks good

@hdhoang
Copy link
Contributor Author

hdhoang commented Dec 29, 2017

Sorry, I often force push PRs. GitHub doesn't push new notifications for that event so I follow up with a comment.

@laumann
Copy link
Collaborator

laumann commented Dec 29, 2017

That's alright, I was just wondering if I overlooked something again. It looks good to me, I'm ready to merge if you don't have any further changes.

@hdhoang
Copy link
Contributor Author

hdhoang commented Dec 29, 2017

I feel this is good to go now.

@laumann laumann merged commit 31af8e9 into Manishearth:master Dec 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants