Skip to content

Commit d484b65

Browse files
committed
Auto merge of #8478 - oli-obk:master, r=alexcrichton
Emit the `test` field in cargo metadata This is needed so `cargo-metadata` can expose it: oli-obk/cargo_metadata#114
2 parents 974eb43 + 95b22d2 commit d484b65

File tree

14 files changed

+92
-24
lines changed

14 files changed

+92
-24
lines changed

src/cargo/core/manifest.rs

+3
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ struct SerializedTarget<'a> {
263263
#[serde(rename = "required-features", skip_serializing_if = "Option::is_none")]
264264
required_features: Option<Vec<&'a str>>,
265265
doctest: bool,
266+
/// Whether tests should be run for the target (`test` field in `Cargo.toml`)
267+
test: bool,
266268
}
267269

268270
impl ser::Serialize for Target {
@@ -283,6 +285,7 @@ impl ser::Serialize for Target {
283285
.required_features()
284286
.map(|rf| rf.iter().map(|s| &**s).collect()),
285287
doctest: self.doctested() && self.doctestable(),
288+
test: self.tested(),
286289
}
287290
.serialize(s)
288291
}

src/doc/man/cargo-metadata.adoc

+4-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ The output has the following format:
134134
/* Whether or not this target has doc tests enabled, and
135135
the target is compatible with doc testing.
136136
*/
137-
"doctest": false
137+
"doctest": false,
138+
/* Whether or not this target should be built and run with `--test`
139+
*/
140+
"test": true
138141
}
139142
],
140143
/* Set of features defined for the package.

src/doc/man/generated/cargo-metadata.html

+5-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ <h2 id="cargo_metadata_output_format">OUTPUT FORMAT</h2>
141141
/* Whether or not this target has doc tests enabled, and
142142
the target is compatible with doc testing.
143143
*/
144-
"doctest": false
144+
"doctest": false,
145+
/* Whether or not this target should be built and run with `--test`
146+
*/
147+
"test": true
145148
}
146149
],
147150
/* Set of features defined for the package.
@@ -514,4 +517,4 @@ <h2 id="cargo_metadata_see_also">SEE ALSO</h2>
514517
<p><a href="index.html">cargo(1)</a></p>
515518
</div>
516519
</div>
517-
</div>
520+
</div>

src/doc/src/reference/external-tools.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ following structure:
142142
"name": "my-package",
143143
"src_path": "/path/to/my-package/src/lib.rs",
144144
"edition": "2018",
145-
"doctest": true
145+
"doctest": true,
146+
"test": true
146147
},
147148
/* The profile indicates which compiler settings were used. */
148149
"profile": {

src/doc/src/reference/unstable.md

+1
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ The following is a description of the JSON structure:
694694
"name": "my-package",
695695
"src_path": "/path/to/my-package/src/lib.rs",
696696
"edition": "2018",
697+
"test": true,
697698
"doctest": true
698699
},
699700
/* The profile settings for this unit.

src/etc/man/cargo-metadata.1

+5-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ The output has the following format:
155155
/* Whether or not this target has doc tests enabled, and
156156
the target is compatible with doc testing.
157157
*/
158-
"doctest": false
158+
"doctest": false,
159+
/* Whether or not this target has the `test` field set in the manifest,
160+
causing it to be compiled with `--test`.
161+
*/
162+
"test": true
159163
}
160164
],
161165
/* Set of features defined for the package.

tests/testsuite/bench.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ fn bench_autodiscover_2015() {
595595
version = "0.0.1"
596596
authors = []
597597
edition = "2015"
598-
598+
599599
[features]
600600
magic = []
601601
@@ -1628,7 +1628,8 @@ fn json_artifact_includes_executable_for_benchmark() {
16281628
"doctest": false,
16291629
"edition": "2015",
16301630
"name": "benchmark",
1631-
"src_path": "[..]/foo/benches/benchmark.rs"
1631+
"src_path": "[..]/foo/benches/benchmark.rs",
1632+
"test": false
16321633
}
16331634
}
16341635

tests/testsuite/build.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -3142,7 +3142,8 @@ fn compiler_json_error_format() {
31423142
"doctest": false,
31433143
"edition": "2015",
31443144
"name":"build-script-build",
3145-
"src_path":"[..]build.rs"
3145+
"src_path":"[..]build.rs",
3146+
"test": false
31463147
},
31473148
"profile": {
31483149
"debug_assertions": true,
@@ -3166,7 +3167,8 @@ fn compiler_json_error_format() {
31663167
"doctest": true,
31673168
"edition": "2015",
31683169
"name":"bar",
3169-
"src_path":"[..]lib.rs"
3170+
"src_path":"[..]lib.rs",
3171+
"test": true
31703172
},
31713173
"message":"{...}"
31723174
}
@@ -3189,7 +3191,8 @@ fn compiler_json_error_format() {
31893191
"doctest": true,
31903192
"edition": "2015",
31913193
"name":"bar",
3192-
"src_path":"[..]lib.rs"
3194+
"src_path":"[..]lib.rs",
3195+
"test": true
31933196
},
31943197
"filenames":[
31953198
"[..].rlib",
@@ -3217,7 +3220,8 @@ fn compiler_json_error_format() {
32173220
"doctest": false,
32183221
"edition": "2015",
32193222
"name":"foo",
3220-
"src_path":"[..]main.rs"
3223+
"src_path":"[..]main.rs",
3224+
"test": true
32213225
},
32223226
"message":"{...}"
32233227
}
@@ -3231,7 +3235,8 @@ fn compiler_json_error_format() {
32313235
"doctest": false,
32323236
"edition": "2015",
32333237
"name":"foo",
3234-
"src_path":"[..]main.rs"
3238+
"src_path":"[..]main.rs",
3239+
"test": true
32353240
},
32363241
"profile": {
32373242
"debug_assertions": true,
@@ -3299,7 +3304,8 @@ fn message_format_json_forward_stderr() {
32993304
"doctest": false,
33003305
"edition": "2015",
33013306
"name":"foo",
3302-
"src_path":"[..]"
3307+
"src_path":"[..]",
3308+
"test": true
33033309
},
33043310
"message":"{...}"
33053311
}
@@ -3313,7 +3319,8 @@ fn message_format_json_forward_stderr() {
33133319
"doctest": false,
33143320
"edition": "2015",
33153321
"name":"foo",
3316-
"src_path":"[..]"
3322+
"src_path":"[..]",
3323+
"test": true
33173324
},
33183325
"profile":{
33193326
"debug_assertions":false,

tests/testsuite/metabuild.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,8 @@ fn metabuild_json_artifact() {
701701
"custom-build"
702702
],
703703
"name": "metabuild-foo",
704-
"src_path": "[..]/foo/target/.metabuild/metabuild-foo-[..].rs"
704+
"src_path": "[..]/foo/target/.metabuild/metabuild-foo-[..].rs",
705+
"test": false
705706
}
706707
}
707708
@@ -750,7 +751,8 @@ fn metabuild_failed_build_json() {
750751
"custom-build"
751752
],
752753
"name": "metabuild-foo",
753-
"src_path": null
754+
"src_path": null,
755+
"test": false
754756
}
755757
}
756758
"#,

0 commit comments

Comments
 (0)