1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
//! Tests for edition setting.
use cargo::core::Edition;
use cargo_test_support::{basic_lib_manifest, project};
#[cargo_test]
fn edition_works_for_build_script() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = 'foo'
version = '0.1.0'
edition = '2018'
[build-dependencies]
a = { path = 'a' }
"#,
)
.file("src/lib.rs", "")
.file(
"build.rs",
r#"
fn main() {
a::foo();
}
"#,
)
.file("a/Cargo.toml", &basic_lib_manifest("a"))
.file("a/src/lib.rs", "pub fn foo() {}")
.build();
p.cargo("check -v").run();
}
#[cargo_test]
fn edition_unstable_gated() {
// During the period where a new edition is coming up, but not yet stable,
// this test will verify that it cannot be used on stable. If there is no
// next edition, it does nothing.
let next = match Edition::LATEST_UNSTABLE {
Some(next) => next,
None => {
eprintln!("Next edition is currently not available, skipping test.");
return;
}
};
let p = project()
.file(
"Cargo.toml",
&format!(
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "{}"
"#,
next
),
)
.file("src/lib.rs", "")
.build();
p.cargo("check")
.with_status(101)
.with_stderr(&format!(
"\
[ERROR] failed to parse manifest at `[..]/foo/Cargo.toml`
Caused by:
feature `edition{next}` is required
The package requires the Cargo feature called `edition{next}`, \
but that feature is not stabilized in this version of Cargo (1.[..]).
Consider trying a newer version of Cargo (this may require the nightly release).
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-{next} \
for more information about the status of this feature.
",
next = next
))
.run();
}
#[cargo_test(nightly, reason = "fundamentally always nightly")]
fn edition_unstable() {
// During the period where a new edition is coming up, but not yet stable,
// this test will verify that it can be used with `cargo-features`. If
// there is no next edition, it does nothing.
let next = match Edition::LATEST_UNSTABLE {
Some(next) => next,
None => {
eprintln!("Next edition is currently not available, skipping test.");
return;
}
};
let p = project()
.file(
"Cargo.toml",
&format!(
r#"
cargo-features = ["edition{next}"]
[package]
name = "foo"
version = "0.1.0"
edition = "{next}"
"#,
next = next
),
)
.file("src/lib.rs", "")
.build();
p.cargo("check")
.masquerade_as_nightly_cargo(&["always_nightly"])
.with_stderr(
"\
[CHECKING] foo [..]
[FINISHED] [..]
",
)
.run();
}
|