r#"[package]
name = "{}"
version = "0.1.0"
-authors = [{}]{}
+authors = [{}]
+edition = {}
[dependencies]
{}"#,
name,
toml::Value::String(author),
match opts.edition {
- Some(edition) => {
- let edition = toml::Value::String(edition.to_string());
- format!("\nedition = {}", edition)
- }
- None => String::new(),
+ Some(edition) => toml::Value::String(edition.to_string()),
+ None => toml::Value::String("2018".to_string()),
},
cargotoml_path_specifier
).as_bytes(),
#[test]
fn simple_lib() {
- cargo_process("init --lib --vcs none")
+ cargo_process("init --lib --vcs none --edition 2015")
.env("USER", "foo")
.with_stderr("[CREATED] library project")
.run();
fn simple_bin() {
let path = paths::root().join("foo");
fs::create_dir(&path).unwrap();
- cargo_process("init --bin --vcs none")
+ cargo_process("init --bin --vcs none --edition 2015")
.env("USER", "foo")
.cwd(&path)
.with_stderr("[CREATED] binary (application) project")
#[test]
fn simple_lib() {
- cargo_process("new --lib foo --vcs none")
+ cargo_process("new --lib foo --vcs none --edition 2015")
.env("USER", "foo")
.with_stderr("[CREATED] library `foo` project")
.run();
#[test]
fn simple_bin() {
- cargo_process("new --bin foo")
+ cargo_process("new --bin foo --edition 2015")
.env("USER", "foo")
.with_stderr("[CREATED] binary (application) `foo` project")
.run();
#[test]
fn simple_git() {
- cargo_process("new --lib foo").env("USER", "foo").run();
+ cargo_process("new --lib foo --edition 2015").env("USER", "foo").run();
assert!(paths::root().is_dir());
assert!(paths::root().join("foo/Cargo.toml").is_file());
assert!(manifest.contains("edition = \"2018\""));
}
+#[test]
+fn new_default_edition() {
+ cargo_process("new foo")
+ .env("USER", "foo")
+ .run();
+ let manifest = fs::read_to_string(paths::root().join("foo/Cargo.toml")).unwrap();
+ assert!(manifest.contains("edition = \"2018\""));
+}
+
#[test]
fn new_with_bad_edition() {
cargo_process("new --edition something_else foo")