mirror of https://github.com/rust-lang/cargo
Add an opt-out to the auto-generated Cargo.toml
This commit is contained in:
parent
2e6e5f880b
commit
d2c815be22
|
@ -535,7 +535,7 @@ Caused by:
|
|||
#[test]
|
||||
fn cargo_compile_without_manifest() {
|
||||
let tmpdir = tempfile::Builder::new().prefix("cargo").tempdir().unwrap();
|
||||
let p = ProjectBuilder::new(tmpdir.path().to_path_buf()).build();
|
||||
let p = ProjectBuilder::new(tmpdir.path().to_path_buf()).no_manifest().build();
|
||||
|
||||
assert_that(
|
||||
p.cargo("build"),
|
||||
|
|
|
@ -197,6 +197,7 @@ pub struct ProjectBuilder {
|
|||
root: Project,
|
||||
files: Vec<FileBuilder>,
|
||||
symlinks: Vec<SymlinkBuilder>,
|
||||
no_manifest: bool,
|
||||
}
|
||||
|
||||
impl ProjectBuilder {
|
||||
|
@ -215,6 +216,7 @@ impl ProjectBuilder {
|
|||
root: Project::Rooted(root),
|
||||
files: vec![],
|
||||
symlinks: vec![],
|
||||
no_manifest: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,6 +250,11 @@ impl ProjectBuilder {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn no_manifest(mut self) -> Self {
|
||||
self.no_manifest = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// Create the project.
|
||||
pub fn build(mut self) -> Project {
|
||||
// First, clean the directory if it already exists
|
||||
|
@ -257,7 +264,7 @@ impl ProjectBuilder {
|
|||
self.root.root().mkdir_p();
|
||||
|
||||
let manifest_path = self.root.root().join("Cargo.toml");
|
||||
if self.files.iter().all(|fb| fb.path != manifest_path) {
|
||||
if !self.no_manifest && self.files.iter().all(|fb| fb.path != manifest_path) {
|
||||
self._file(Path::new("Cargo.toml"), BASIC_MANIFEST)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue