Skip to content
This repository was archived by the owner on May 20, 2020. It is now read-only.

Commit 07801eb

Browse files
authored
Merge pull request #224 from hjr3/fix-223
Fix failing CI due to rustfmt regression
2 parents 77b98fa + 5a34e3c commit 07801eb

File tree

3 files changed

+119
-11
lines changed

3 files changed

+119
-11
lines changed

src/cargo.rs

Lines changed: 94 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,21 @@ mod tests {
248248
fn target_from_metadata() {
249249
let ui = Ui::default();
250250

251-
let metadata = json!({});
251+
// work around until https://github.com/rust-lang-nursery/rustfmt/issues/2344 is fixed
252+
#[cfg_attr(rustfmt, rustfmt_skip)]
253+
let metadata = json!({
254+
"packages": [
255+
{
256+
"name": "underscored_name",
257+
"targets": [
258+
{
259+
"kind": [ "lib" ],
260+
"name": "underscored_name",
261+
},
262+
],
263+
},
264+
],
265+
});
252266
let target = super::target_from_metadata(&ui, &metadata).unwrap();
253267
assert_eq!(
254268
target,
@@ -259,7 +273,21 @@ mod tests {
259273
);
260274
assert_eq!(&target.crate_name(), "underscored_name");
261275

262-
let metadata = json!({});
276+
// work around until https://github.com/rust-lang-nursery/rustfmt/issues/2344 is fixed
277+
#[cfg_attr(rustfmt, rustfmt_skip)]
278+
let metadata = json!({
279+
"packages": [
280+
{
281+
"name": "dashed-name",
282+
"targets": [
283+
{
284+
"kind": [ "lib" ],
285+
"name": "dashed-name",
286+
},
287+
],
288+
},
289+
],
290+
});
263291
let target = super::target_from_metadata(&ui, &metadata).unwrap();
264292
assert_eq!(
265293
target,
@@ -270,7 +298,21 @@ mod tests {
270298
);
271299
assert_eq!(&target.crate_name(), "dashed_name");
272300

273-
let metadata = json!({});
301+
// work around until https://github.com/rust-lang-nursery/rustfmt/issues/2344 is fixed
302+
#[cfg_attr(rustfmt, rustfmt_skip)]
303+
let metadata = json!({
304+
"packages": [
305+
{
306+
"name": "underscored_name",
307+
"targets": [
308+
{
309+
"kind": [ "bin" ],
310+
"name": "underscored_name",
311+
},
312+
],
313+
},
314+
],
315+
});
274316
let target = super::target_from_metadata(&ui, &metadata).unwrap();
275317
assert_eq!(
276318
target,
@@ -281,19 +323,65 @@ mod tests {
281323
);
282324
assert_eq!(&target.crate_name(), "underscored_name");
283325

284-
let metadata = json!({});
326+
// work around until https://github.com/rust-lang-nursery/rustfmt/issues/2344 is fixed
327+
#[cfg_attr(rustfmt, rustfmt_skip)]
328+
let metadata = json!({
329+
"packages": [
330+
{
331+
"name": "library",
332+
"targets": [
333+
{
334+
"kind": [ "lib" ],
335+
"name": "library",
336+
},
337+
],
338+
},
339+
],
340+
});
285341
assert_eq!(
286342
super::target_from_metadata(&ui, &metadata).unwrap().kind,
287343
TargetKind::Library
288344
);
289345

290-
let metadata = json!({});
346+
// work around until https://github.com/rust-lang-nursery/rustfmt/issues/2344 is fixed
347+
#[cfg_attr(rustfmt, rustfmt_skip)]
348+
let metadata = json!({
349+
"packages": [
350+
{
351+
"name": "binary",
352+
"targets": [
353+
{
354+
"kind": [ "bin" ],
355+
"name": "binary",
356+
},
357+
],
358+
},
359+
],
360+
});
291361
assert_eq!(
292362
super::target_from_metadata(&ui, &metadata).unwrap().kind,
293363
TargetKind::Binary
294364
);
295365

296-
let metadata = json!({});
366+
// work around until https://github.com/rust-lang-nursery/rustfmt/issues/2344 is fixed
367+
#[cfg_attr(rustfmt, rustfmt_skip)]
368+
let metadata = json!({
369+
"packages": [
370+
{
371+
"name": "library",
372+
"targets": [
373+
{
374+
"kind": [ "lib" ],
375+
"name": "library",
376+
},
377+
{
378+
"kind": [ "test" ],
379+
"name": "other_kind",
380+
},
381+
],
382+
},
383+
],
384+
});
297385
assert_eq!(
298386
super::target_from_metadata(&ui, &metadata).unwrap().kind,
299387
TargetKind::Library

src/json/api.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,15 @@ mod tests {
332332
#[test]
333333
fn serialize() {
334334
let module_data = Data::new().ty("module".into()).id("example::module".into());
335-
let module_data_json = json!({});
335+
// work around until https://github.com/rust-lang-nursery/rustfmt/issues/2344 is fixed
336+
#[cfg_attr(rustfmt, rustfmt_skip)]
337+
let module_data_json = json!({
338+
"type": "module",
339+
"id": "example::module",
340+
});
336341
assert_eq!(
337-
module_data_json,
338-
serde_json::to_value(&module_data).unwrap()
342+
serde_json::to_value(&module_data).unwrap(),
343+
module_data_json
339344
);
340345

341346
let mut krate = Document::new()
@@ -348,7 +353,16 @@ mod tests {
348353
.id("example::module".into())
349354
.attributes("docs".into(), "module docs".into())
350355
.attributes("name".into(), "module".into());
351-
let module_json = json!({});
356+
// work around until https://github.com/rust-lang-nursery/rustfmt/issues/2344 is fixed
357+
#[cfg_attr(rustfmt, rustfmt_skip)]
358+
let module_json = json!({
359+
"type": "module",
360+
"id": "example::module",
361+
"attributes": {
362+
"docs": "module docs",
363+
"name": "module",
364+
},
365+
});
352366
assert_eq!(serde_json::to_value(&module).unwrap(), module_json);
353367

354368
krate.relationships("modules".into(), vec![module_data]);

tests/source.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,13 @@ mod tests {
571571

572572
#[test]
573573
fn run_test() {
574-
let json = json!({});
574+
// work around until https://github.com/rust-lang-nursery/rustfmt/issues/2344 is fixed
575+
#[cfg_attr(rustfmt, rustfmt_skip)]
576+
let json = json!({
577+
"test": "value",
578+
"nonString": ["non", "string"],
579+
"boolean": true,
580+
});
575581

576582
let test = TestCase {
577583
jmespath: jmespath::compile("test").unwrap(),

0 commit comments

Comments
 (0)