sagiegurari / cargo-make
1
use super::*;
2

3 8
fn get_script_vec(task: &Task) -> Vec<String> {
4 8
    match task.script.as_ref().unwrap() {
5 8
        ScriptValue::Text(value) => value.clone(),
6 0
        _ => panic!("Invalid script value type."),
7
    }
8 8
}
9

10
#[test]
11 8
fn cli_args_new() {
12 8
    let cli_args = CliArgs::new();
13

14 8
    assert_eq!(cli_args.command, "");
15 8
    assert!(cli_args.build_file.is_none());
16 8
    assert_eq!(cli_args.task, "default");
17 8
    assert!(cli_args.profile.is_none());
18 8
    assert_eq!(cli_args.log_level, "info");
19 8
    assert!(!cli_args.disable_color);
20 8
    assert!(cli_args.cwd.is_none());
21 8
    assert!(cli_args.env.is_none());
22 8
    assert!(cli_args.env_file.is_none());
23 8
    assert!(!cli_args.disable_workspace);
24 8
    assert!(!cli_args.disable_on_error);
25 8
    assert!(!cli_args.allow_private);
26 8
    assert!(!cli_args.skip_init_end_tasks);
27 8
    assert!(!cli_args.disable_check_for_updates);
28 8
    assert!(!cli_args.print_only);
29 8
    assert!(!cli_args.list_all_steps);
30 8
    assert!(!cli_args.diff_execution_plan);
31 8
    assert!(!cli_args.experimental);
32 8
    assert!(cli_args.arguments.is_none());
33 8
    assert_eq!(cli_args.output_format, "default");
34 8
    assert!(cli_args.output_file.is_none());
35 8
    assert!(!cli_args.print_time_summary);
36 8
}
37

38
#[test]
39 8
fn flow_state_new() {
40 8
    let flow_state = FlowState::new();
41

42 8
    assert!(flow_state.time_summary.is_empty());
43 8
}
44

45
#[test]
46 8
fn global_config_new() {
47 8
    let global_config = GlobalConfig::new();
48

49 8
    assert!(global_config.file_name.is_none());
50 8
    assert!(global_config.log_level.is_none());
51 8
    assert!(global_config.default_task_name.is_none());
52 8
    assert!(global_config.update_check_minimum_interval.is_none());
53 8
    assert!(!global_config.search_project_root.unwrap());
54 8
    assert!(global_config.disable_color.is_none());
55 8
}
56

57
#[test]
58 8
fn cache_new() {
59 8
    let cache = Cache::new();
60

61 8
    assert!(cache.file_name.is_none());
62 8
    assert!(cache.last_update_check.is_none());
63 8
}
64

65
#[test]
66 8
fn install_cargo_plugin_info_eq_same_all() {
67 8
    let first = InstallCargoPluginInfo {
68 8
        crate_name: Some("test".to_string()),
69 8
        min_version: "1.0.0".to_string(),
70 0
    };
71 8
    let second = InstallCargoPluginInfo {
72 8
        crate_name: Some("test".to_string()),
73 8
        min_version: "1.0.0".to_string(),
74 0
    };
75

76 8
    assert_eq!(first, second);
77 8
}
78

79
#[test]
80 8
fn install_cargo_plugin_info_eq_same_no_crate_name() {
81 8
    let first = InstallCargoPluginInfo {
82 8
        crate_name: None,
83 8
        min_version: "1.0.0".to_string(),
84 0
    };
85 8
    let second = InstallCargoPluginInfo {
86 8
        crate_name: None,
87 8
        min_version: "1.0.0".to_string(),
88 0
    };
89

90 8
    assert_eq!(first, second);
91 8
}
92

93
#[test]
94 8
fn install_cargo_plugin_info_eq_different_crate_name_type() {
95 8
    let first = InstallCargoPluginInfo {
96 8
        crate_name: Some("test".to_string()),
97 8
        min_version: "1.0.0".to_string(),
98 0
    };
99 8
    let second = InstallCargoPluginInfo {
100 8
        crate_name: None,
101 8
        min_version: "1.0.0".to_string(),
102 0
    };
103

104 8
    assert!(first != second);
105 8
}
106

107
#[test]
108 8
fn install_cargo_plugin_info_eq_different_crate_name_value() {
109 8
    let first = InstallCargoPluginInfo {
110 8
        crate_name: Some("test1".to_string()),
111 8
        min_version: "1.0.0".to_string(),
112 0
    };
113 8
    let second = InstallCargoPluginInfo {
114 8
        crate_name: Some("test2".to_string()),
115 8
        min_version: "1.0.0".to_string(),
116 0
    };
117

118 8
    assert!(first != second);
119 8
}
120

121
#[test]
122 8
fn install_cargo_plugin_info_eq_different_min_version_value() {
123 8
    let first = InstallCargoPluginInfo {
124 8
        crate_name: None,
125 8
        min_version: "1.0.0".to_string(),
126 0
    };
127 8
    let second = InstallCargoPluginInfo {
128 8
        crate_name: None,
129 8
        min_version: "2.0.0".to_string(),
130 0
    };
131

132 8
    assert!(first != second);
133 8
}
134

135
#[test]
136 8
fn install_crate_info_eq_same_all() {
137 8
    let first = InstallCrateInfo {
138 8
        crate_name: "test".to_string(),
139 8
        binary: "bin".to_string(),
140 8
        test_arg: TestArg {
141 8
            inner: vec!["--help".to_string()],
142
        },
143 8
        rustup_component_name: Some("component".to_string()),
144 8
        min_version: Some("1.0.0".to_string()),
145 0
    };
146 8
    let second = InstallCrateInfo {
147 8
        crate_name: "test".to_string(),
148 8
        binary: "bin".to_string(),
149 8
        test_arg: TestArg {
150 8
            inner: vec!["--help".to_string()],
151
        },
152 8
        rustup_component_name: Some("component".to_string()),
153 8
        min_version: Some("1.0.0".to_string()),
154 0
    };
155

156 8
    assert_eq!(first, second);
157 8
}
158

159
#[test]
160 8
fn install_crate_info_eq_same_no_component() {
161 8
    let first = InstallCrateInfo {
162 8
        crate_name: "test".to_string(),
163 8
        binary: "bin".to_string(),
164 8
        test_arg: TestArg {
165 8
            inner: vec!["--help".to_string()],
166
        },
167 8
        rustup_component_name: None,
168 8
        min_version: Some("1.0.0".to_string()),
169 0
    };
170 8
    let second = InstallCrateInfo {
171 8
        crate_name: "test".to_string(),
172 8
        binary: "bin".to_string(),
173 8
        test_arg: TestArg {
174 8
            inner: vec!["--help".to_string()],
175
        },
176 8
        rustup_component_name: None,
177 8
        min_version: Some("1.0.0".to_string()),
178 0
    };
179

180 8
    assert_eq!(first, second);
181 8
}
182

183
#[test]
184 8
fn install_crate_info_eq_same_no_min_version() {
185 8
    let first = InstallCrateInfo {
186 8
        crate_name: "test".to_string(),
187 8
        binary: "bin".to_string(),
188 8
        test_arg: TestArg {
189 8
            inner: vec!["--help".to_string()],
190
        },
191 8
        rustup_component_name: Some("component".to_string()),
192 8
        min_version: None,
193 0
    };
194 8
    let second = InstallCrateInfo {
195 8
        crate_name: "test".to_string(),
196 8
        binary: "bin".to_string(),
197 8
        test_arg: TestArg {
198 8
            inner: vec!["--help".to_string()],
199
        },
200 8
        rustup_component_name: Some("component".to_string()),
201 8
        min_version: None,
202 0
    };
203

204 8
    assert_eq!(first, second);
205 8
}
206

207
#[test]
208 8
fn install_crate_info_eq_different_crate_name() {
209 8
    let first = InstallCrateInfo {
210 8
        crate_name: "test1".to_string(),
211 8
        binary: "bin".to_string(),
212 8
        test_arg: TestArg {
213 8
            inner: vec!["--help".to_string()],
214
        },
215 8
        rustup_component_name: None,
216 8
        min_version: Some("1.0.0".to_string()),
217 0
    };
218 8
    let second = InstallCrateInfo {
219 8
        crate_name: "test2".to_string(),
220 8
        binary: "bin".to_string(),
221 8
        test_arg: TestArg {
222 8
            inner: vec!["--help".to_string()],
223
        },
224 8
        rustup_component_name: None,
225 8
        min_version: Some("1.0.0".to_string()),
226 0
    };
227

228 8
    assert!(first != second);
229 8
}
230

231
#[test]
232 8
fn install_crate_info_eq_different_binary() {
233 8
    let first = InstallCrateInfo {
234 8
        crate_name: "test".to_string(),
235 8
        binary: "bin1".to_string(),
236 8
        test_arg: TestArg {
237 8
            inner: vec!["--help".to_string()],
238
        },
239 8
        rustup_component_name: None,
240 8
        min_version: Some("1.0.0".to_string()),
241 0
    };
242 8
    let second = InstallCrateInfo {
243 8
        crate_name: "test".to_string(),
244 8
        binary: "bin2".to_string(),
245 8
        test_arg: TestArg {
246 8
            inner: vec!["--help".to_string()],
247
        },
248 8
        rustup_component_name: None,
249 8
        min_version: Some("1.0.0".to_string()),
250 0
    };
251

252 8
    assert!(first != second);
253 8
}
254

255
#[test]
256 8
fn install_crate_info_eq_different_test_arg() {
257 8
    let first = InstallCrateInfo {
258 8
        crate_name: "test".to_string(),
259 8
        binary: "bin".to_string(),
260 8
        test_arg: TestArg {
261 8
            inner: vec!["--help1".to_string()],
262
        },
263 8
        rustup_component_name: None,
264 8
        min_version: Some("1.0.0".to_string()),
265 0
    };
266 8
    let second = InstallCrateInfo {
267 8
        crate_name: "test".to_string(),
268 8
        binary: "bin".to_string(),
269 8
        test_arg: TestArg {
270 8
            inner: vec!["--help2".to_string()],
271
        },
272 8
        rustup_component_name: None,
273 8
        min_version: Some("1.0.0".to_string()),
274 0
    };
275

276 8
    assert!(first != second);
277 8
}
278

279
#[test]
280 8
fn install_crate_info_eq_different_component_type() {
281 8
    let first = InstallCrateInfo {
282 8
        crate_name: "test".to_string(),
283 8
        binary: "bin".to_string(),
284 8
        test_arg: TestArg {
285 8
            inner: vec!["--help".to_string()],
286
        },
287 8
        rustup_component_name: Some("value".to_string()),
288 8
        min_version: Some("1.0.0".to_string()),
289 0
    };
290 8
    let second = InstallCrateInfo {
291 8
        crate_name: "test".to_string(),
292 8
        binary: "bin".to_string(),
293 8
        test_arg: TestArg {
294 8
            inner: vec!["--help".to_string()],
295
        },
296 8
        rustup_component_name: None,
297 8
        min_version: Some("1.0.0".to_string()),
298 0
    };
299

300 8
    assert!(first != second);
301 8
}
302

303
#[test]
304 8
fn install_crate_info_eq_different_component_value() {
305 8
    let first = InstallCrateInfo {
306 8
        crate_name: "test".to_string(),
307 8
        binary: "bin".to_string(),
308 8
        test_arg: TestArg {
309 8
            inner: vec!["--help".to_string()],
310
        },
311 8
        rustup_component_name: Some("value1".to_string()),
312 8
        min_version: Some("1.0.0".to_string()),
313 0
    };
314 8
    let second = InstallCrateInfo {
315 8
        crate_name: "test".to_string(),
316 8
        binary: "bin".to_string(),
317 8
        test_arg: TestArg {
318 8
            inner: vec!["--help".to_string()],
319
        },
320 8
        rustup_component_name: Some("value2".to_string()),
321 8
        min_version: Some("1.0.0".to_string()),
322 0
    };
323

324 8
    assert!(first != second);
325 8
}
326

327
#[test]
328 8
fn install_crate_info_eq_different_min_version_type() {
329 8
    let first = InstallCrateInfo {
330 8
        crate_name: "test".to_string(),
331 8
        binary: "bin".to_string(),
332 8
        test_arg: TestArg {
333 8
            inner: vec!["--help".to_string()],
334
        },
335 8
        rustup_component_name: Some("value".to_string()),
336 8
        min_version: Some("1.0.0".to_string()),
337 0
    };
338 8
    let second = InstallCrateInfo {
339 8
        crate_name: "test".to_string(),
340 8
        binary: "bin".to_string(),
341 8
        test_arg: TestArg {
342 8
            inner: vec!["--help".to_string()],
343
        },
344 8
        rustup_component_name: Some("value".to_string()),
345 8
        min_version: None,
346 0
    };
347

348 8
    assert!(first != second);
349 8
}
350

351
#[test]
352 8
fn install_crate_info_eq_different_min_version_value() {
353 8
    let first = InstallCrateInfo {
354 8
        crate_name: "test".to_string(),
355 8
        binary: "bin".to_string(),
356 8
        test_arg: TestArg {
357 8
            inner: vec!["--help".to_string()],
358
        },
359 8
        rustup_component_name: Some("value".to_string()),
360 8
        min_version: Some("1.0.0".to_string()),
361 0
    };
362 8
    let second = InstallCrateInfo {
363 8
        crate_name: "test".to_string(),
364 8
        binary: "bin".to_string(),
365 8
        test_arg: TestArg {
366 8
            inner: vec!["--help".to_string()],
367
        },
368 8
        rustup_component_name: Some("value".to_string()),
369 8
        min_version: Some("2.0.0".to_string()),
370 0
    };
371

372 8
    assert!(first != second);
373 8
}
374

375
#[test]
376 8
fn install_rustup_component_info_eq_same_all() {
377 8
    let first = InstallRustupComponentInfo {
378 8
        rustup_component_name: "component".to_string(),
379 8
        binary: Some("bin".to_string()),
380 8
        test_arg: Some(TestArg {
381 8
            inner: vec!["--help".to_string()],
382
        }),
383 0
    };
384 8
    let second = InstallRustupComponentInfo {
385 8
        rustup_component_name: "component".to_string(),
386 8
        binary: Some("bin".to_string()),
387 8
        test_arg: Some(TestArg {
388 8
            inner: vec!["--help".to_string()],
389
        }),
390 0
    };
391

392 8
    assert_eq!(first, second);
393 8
}
394

395
#[test]
396 8
fn install_rustup_component_info_eq_same_no_binary() {
397 8
    let first = InstallRustupComponentInfo {
398 8
        rustup_component_name: "component".to_string(),
399 8
        binary: None,
400 8
        test_arg: Some(TestArg {
401 8
            inner: vec!["--help".to_string()],
402
        }),
403 0
    };
404 8
    let second = InstallRustupComponentInfo {
405 8
        rustup_component_name: "component".to_string(),
406 8
        binary: None,
407 8
        test_arg: Some(TestArg {
408 8
            inner: vec!["--help".to_string()],
409
        }),
410 0
    };
411

412 8
    assert_eq!(first, second);
413 8
}
414

415
#[test]
416 8
fn install_rustup_component_info_eq_same_no_test_arg() {
417 8
    let first = InstallRustupComponentInfo {
418 8
        rustup_component_name: "component".to_string(),
419 8
        binary: Some("bin".to_string()),
420 8
        test_arg: None,
421 0
    };
422 8
    let second = InstallRustupComponentInfo {
423 8
        rustup_component_name: "component".to_string(),
424 8
        binary: Some("bin".to_string()),
425 8
        test_arg: None,
426 0
    };
427

428 8
    assert_eq!(first, second);
429 8
}
430

431
#[test]
432 8
fn install_rustup_component_info_eq_different_component() {
433 8
    let first = InstallRustupComponentInfo {
434 8
        rustup_component_name: "component1".to_string(),
435 8
        binary: Some("bin".to_string()),
436 8
        test_arg: Some(TestArg {
437 8
            inner: vec!["--help".to_string()],
438
        }),
439 0
    };
440 8
    let second = InstallRustupComponentInfo {
441 8
        rustup_component_name: "component2".to_string(),
442 8
        binary: Some("bin".to_string()),
443 8
        test_arg: Some(TestArg {
444 8
            inner: vec!["--help".to_string()],
445
        }),
446 0
    };
447

448 8
    assert!(first != second);
449 8
}
450

451
#[test]
452 8
fn install_rustup_component_info_eq_different_binary() {
453 8
    let first = InstallRustupComponentInfo {
454 8
        rustup_component_name: "component".to_string(),
455 8
        binary: Some("bin1".to_string()),
456 8
        test_arg: Some(TestArg {
457 8
            inner: vec!["--help".to_string()],
458
        }),
459 0
    };
460 8
    let second = InstallRustupComponentInfo {
461 8
        rustup_component_name: "component".to_string(),
462 8
        binary: Some("bin2".to_string()),
463 8
        test_arg: Some(TestArg {
464 8
            inner: vec!["--help".to_string()],
465
        }),
466 0
    };
467

468 8
    assert!(first != second);
469 8
}
470

471
#[test]
472 8
fn install_rustup_component_info_eq_different_binary_type() {
473 8
    let first = InstallRustupComponentInfo {
474 8
        rustup_component_name: "component".to_string(),
475 8
        binary: Some("bin".to_string()),
476 8
        test_arg: Some(TestArg {
477 8
            inner: vec!["--help".to_string()],
478
        }),
479 0
    };
480 8
    let second = InstallRustupComponentInfo {
481 8
        rustup_component_name: "component".to_string(),
482 8
        binary: None,
483 8
        test_arg: Some(TestArg {
484 8
            inner: vec!["--help".to_string()],
485
        }),
486 0
    };
487

488 8
    assert!(first != second);
489 8
}
490

491
#[test]
492 8
fn install_rustup_component_info_eq_different_test_arg() {
493 8
    let first = InstallRustupComponentInfo {
494 8
        rustup_component_name: "component".to_string(),
495 8
        binary: Some("bin".to_string()),
496 8
        test_arg: Some(TestArg {
497 8
            inner: vec!["--hel1p".to_string()],
498
        }),
499 0
    };
500 8
    let second = InstallRustupComponentInfo {
501 8
        rustup_component_name: "component".to_string(),
502 8
        binary: Some("bin".to_string()),
503 8
        test_arg: Some(TestArg {
504 8
            inner: vec!["--help2".to_string()],
505
        }),
506 0
    };
507

508 8
    assert!(first != second);
509 8
}
510

511
#[test]
512 8
fn install_rustup_component_info_eq_different_test_arg_type() {
513 8
    let first = InstallRustupComponentInfo {
514 8
        rustup_component_name: "component".to_string(),
515 8
        binary: Some("bin".to_string()),
516 8
        test_arg: None,
517 0
    };
518 8
    let second = InstallRustupComponentInfo {
519 8
        rustup_component_name: "component".to_string(),
520 8
        binary: None,
521 8
        test_arg: Some(TestArg {
522 8
            inner: vec!["--help".to_string()],
523
        }),
524 0
    };
525

526 8
    assert!(first != second);
527 8
}
528

529
#[test]
530 8
fn install_crate_eq_same_value() {
531 8
    let first = InstallCrate::Value("crate".to_string());
532 8
    let second = InstallCrate::Value("crate".to_string());
533

534 8
    assert_eq!(first, second);
535 8
}
536

537
#[test]
538 8
fn install_crate_eq_same_cargo_plugin_info() {
539 8
    let info = InstallCargoPluginInfo {
540 8
        crate_name: Some("test".to_string()),
541 8
        min_version: "1.0.0".to_string(),
542 0
    };
543 8
    let first = InstallCrate::CargoPluginInfo(info.clone());
544 8
    let second = InstallCrate::CargoPluginInfo(info.clone());
545

546 8
    assert_eq!(first, second);
547 8
}
548

549
#[test]
550 8
fn install_crate_eq_same_crate_info() {
551 8
    let info = InstallCrateInfo {
552 8
        crate_name: "test".to_string(),
553 8
        binary: "bin".to_string(),
554 8
        test_arg: TestArg {
555 8
            inner: vec!["--help".to_string()],
556
        },
557 8
        rustup_component_name: Some("value".to_string()),
558 8
        min_version: Some("1.0.0".to_string()),
559 0
    };
560 8
    let first = InstallCrate::CrateInfo(info.clone());
561 8
    let second = InstallCrate::CrateInfo(info.clone());
562

563 8
    assert_eq!(first, second);
564 8
}
565

566
#[test]
567 8
fn install_crate_eq_same_rustup_component_info() {
568 8
    let info = InstallRustupComponentInfo {
569 8
        rustup_component_name: "value".to_string(),
570 8
        binary: Some("bin".to_string()),
571 8
        test_arg: Some(TestArg {
572 8
            inner: vec!["--help".to_string()],
573
        }),
574 0
    };
575 8
    let first = InstallCrate::RustupComponentInfo(info.clone());
576 8
    let second = InstallCrate::RustupComponentInfo(info.clone());
577

578 8
    assert_eq!(first, second);
579 8
}
580

581
#[test]
582 8
fn install_crate_eq_different_value() {
583 8
    let first = InstallCrate::Value("crate1".to_string());
584 8
    let second = InstallCrate::Value("crate2".to_string());
585

586 8
    assert!(first != second);
587 8
}
588

589
#[test]
590 8
fn install_crate_eq_different_cargo_plugin_info() {
591 8
    let first = InstallCrate::CargoPluginInfo(InstallCargoPluginInfo {
592 8
        crate_name: Some("test1".to_string()),
593 8
        min_version: "1.0.0".to_string(),
594 0
    });
595 8
    let second = InstallCrate::CargoPluginInfo(InstallCargoPluginInfo {
596 8
        crate_name: Some("test2".to_string()),
597 8
        min_version: "1.0.0".to_string(),
598 0
    });
599

600 8
    assert!(first != second);
601 8
}
602

603
#[test]
604 8
fn install_crate_eq_different_crate_info() {
605 8
    let first = InstallCrate::CrateInfo(InstallCrateInfo {
606 8
        crate_name: "test1".to_string(),
607 8
        binary: "bin".to_string(),
608 8
        test_arg: TestArg {
609 8
            inner: vec!["--help".to_string()],
610
        },
611 8
        rustup_component_name: Some("value".to_string()),
612 8
        min_version: None,
613 0
    });
614 8
    let second = InstallCrate::CrateInfo(InstallCrateInfo {
615 8
        crate_name: "test2".to_string(),
616 8
        binary: "bin".to_string(),
617 8
        test_arg: TestArg {
618 8
            inner: vec!["--help".to_string()],
619
        },
620 8
        rustup_component_name: Some("value".to_string()),
621 8
        min_version: None,
622 0
    });
623

624 8
    assert!(first != second);
625 8
}
626

627
#[test]
628 8
fn install_crate_eq_different_rustup_component_info() {
629 8
    let first = InstallCrate::RustupComponentInfo(InstallRustupComponentInfo {
630 8
        rustup_component_name: "component1".to_string(),
631 8
        binary: Some("bin".to_string()),
632 8
        test_arg: Some(TestArg {
633 8
            inner: vec!["--help".to_string()],
634
        }),
635 0
    });
636 8
    let second = InstallCrate::RustupComponentInfo(InstallRustupComponentInfo {
637 8
        rustup_component_name: "component2".to_string(),
638 8
        binary: Some("bin".to_string()),
639 8
        test_arg: Some(TestArg {
640 8
            inner: vec!["--help".to_string()],
641
        }),
642 0
    });
643

644 8
    assert!(first != second);
645 8
}
646

647
#[test]
648 8
fn install_crate_info_deserialize_string_test_arg() {
649 8
    let info: InstallCrateInfo = toml::from_str(
650
        r#"
651
        crate_name = "mkisofs-rs"
652
        binary = "mkisofs-rs"
653
        test_arg = "--help"
654
        "#,
655
    )
656
    .unwrap();
657 8
    assert_eq!(*info.test_arg, &["--help"]);
658 8
}
659

660
#[test]
661 8
fn install_crate_info_deserialize_array_test_arg() {
662 8
    let info: InstallCrateInfo = toml::from_str(
663
        r#"
664
        crate_name = "mkisofs-rs"
665
        binary = "mkisofs-rs"
666
        test_arg = ["--help", "--test"]
667
        "#,
668
    )
669
    .unwrap();
670 8
    assert_eq!(*info.test_arg, &["--help", "--test"]);
671 8
}
672

673
#[test]
674
#[should_panic]
675 8
fn install_crate_info_deserialize_missing_test_arg() {
676 8
    let _info: InstallCrateInfo = toml::from_str(
677
        r#"
678
        crate_name = "mkisofs-rs"
679
        binary = "mkisofs-rs
680
        "#,
681
    )
682
    .unwrap();
683 0
}
684

685
#[test]
686 8
fn install_rustup_component_info_deserialize_string_test_arg() {
687 8
    let info: InstallRustupComponentInfo = toml::from_str(
688
        r#"
689
        rustup_component_name = "clippy-preview"
690
        binary = "cargo-clippy"
691
        test_arg = "--help"
692
        "#,
693
    )
694
    .unwrap();
695 8
    assert_eq!(*info.test_arg.unwrap(), &["--help"]);
696 8
}
697

698
#[test]
699 8
fn install_rustup_component_info_deserialize_array_test_arg() {
700 8
    let info: InstallRustupComponentInfo = toml::from_str(
701
        r#"
702
        rustup_component_name = "clippy-preview"
703
        binary = "cargo"
704
        test_arg = ["clippy", "--help"]
705
        "#,
706
    )
707
    .unwrap();
708 8
    assert_eq!(*info.test_arg.unwrap(), &["clippy", "--help"]);
709 8
}
710

711
#[test]
712 8
fn install_rustup_component_info_deserialize_missing_test_arg() {
713 8
    let info: InstallRustupComponentInfo = toml::from_str(
714
        r#"
715
        rustup_component_name = "clippy-preview"
716
        binary = "cargo"
717
        "#,
718
    )
719
    .unwrap();
720

721 8
    assert_eq!(info.test_arg, None);
722 8
}
723

724
#[test]
725 8
fn env_value_deserialize_string() {
726 8
    let config: ExternalConfig = toml::from_str(
727
        r#"
728
        [env]
729
        key = "value"
730
        "#,
731
    )
732
    .unwrap();
733 8
    let env = config.env.unwrap();
734

735 8
    for (_, info) in &env {
736
        match info {
737 8
            EnvValue::Value(value) => assert_eq!(value, "value"),
738 0
            _ => panic!("invalid env value type"),
739
        };
740
    }
741 8
}
742

743
#[test]
744 8
fn env_value_deserialize_bool_true() {
745 8
    let config: ExternalConfig = toml::from_str(
746
        r#"
747
        [env]
748
        key = true
749
        "#,
750
    )
751
    .unwrap();
752 8
    let env = config.env.unwrap();
753

754 8
    for (_, info) in &env {
755
        match info {
756 8
            EnvValue::Boolean(value) => assert!(value),
757 0
            _ => panic!("invalid env value type"),
758
        };
759
    }
760 8
}
761

762
#[test]
763 8
fn env_value_deserialize_bool_false() {
764 8
    let config: ExternalConfig = toml::from_str(
765
        r#"
766
        [env]
767
        key = false
768
        "#,
769
    )
770
    .unwrap();
771 8
    let env = config.env.unwrap();
772

773 8
    for (_, info) in &env {
774
        match info {
775 8
            EnvValue::Boolean(value) => assert!(!value),
776 0
            _ => panic!("invalid env value type"),
777
        };
778
    }
779 8
}
780

781
#[test]
782 8
fn env_value_deserialize_list_empty() {
783 8
    let config: ExternalConfig = toml::from_str(
784
        r#"
785
        [env]
786
        key = []
787
        "#,
788
    )
789
    .unwrap();
790 8
    let env = config.env.unwrap();
791

792 8
    for (_, info) in &env {
793
        match info {
794 8
            EnvValue::List(value) => assert!(value.is_empty()),
795 0
            _ => panic!("invalid env value type"),
796
        };
797
    }
798 8
}
799

800
#[test]
801 8
fn env_value_deserialize_list_with_values() {
802 8
    let config: ExternalConfig = toml::from_str(
803
        r#"
804
        [env]
805
        key = ["1", "2", "3"]
806
        "#,
807
    )
808
    .unwrap();
809 8
    let env = config.env.unwrap();
810

811 8
    for (_, info) in &env {
812
        match info {
813 8
            EnvValue::List(value) => assert_eq!(value, &vec!["1", "2", "3"]),
814 0
            _ => panic!("invalid env value type"),
815
        };
816
    }
817 8
}
818

819
#[test]
820 8
fn env_value_deserialize_script() {
821 8
    let config: ExternalConfig = toml::from_str(
822
        r#"
823
        [env]
824
        key = { script = ["echo test"] }
825
        "#,
826
    )
827
    .unwrap();
828 8
    let env = config.env.unwrap();
829

830 8
    for (_, info) in &env {
831
        match info {
832 8
            EnvValue::Script(value) => assert_eq!(value.script[0], "echo test"),
833 0
            _ => panic!("invalid env value type"),
834
        };
835
    }
836 8
}
837

838
#[test]
839 8
fn env_value_deserialize_decode() {
840 8
    let config: ExternalConfig = toml::from_str(
841
        r#"
842
        [env]
843
        key = { source = "source value", default_value = "default value", mapping = { "key1" = "value1", "key2" = "value2" } }
844
        "#,
845
    )
846
    .unwrap();
847 8
    let env = config.env.unwrap();
848

849 8
    for (_, info) in &env {
850
        match info {
851 8
            EnvValue::Decode(value) => {
852 8
                assert_eq!(value.source, "source value");
853 8
                assert_eq!(value.default_value, Some("default value".to_string()));
854 8
                assert_eq!(value.mapping.len(), 2);
855

856
                ()
857
            }
858 0
            _ => panic!("invalid env value type"),
859
        };
860
    }
861 8
}
862

863
#[test]
864 8
fn env_value_deserialize_conditional_env_value_no_condition() {
865 8
    let config: ExternalConfig = toml::from_str(
866
        r#"
867
        [env]
868
        key = { value = "value" }
869
        "#,
870
    )
871
    .unwrap();
872 8
    let env = config.env.unwrap();
873

874 8
    for (_, info) in &env {
875
        match info {
876 8
            EnvValue::Conditional(value) => {
877 8
                assert_eq!(value.value, "value");
878 8
                assert!(value.condition.is_none());
879

880
                ()
881
            }
882 0
            _ => panic!("invalid env value type"),
883
        };
884
    }
885 8
}
886

887
#[test]
888 8
fn env_value_deserialize_conditional_env_value_with_condition() {
889 8
    let config: ExternalConfig = toml::from_str(
890
        r#"
891
        [env]
892
        key = { value = "value", condition = {} }
893
        "#,
894
    )
895
    .unwrap();
896 8
    let env = config.env.unwrap();
897

898 8
    for (_, info) in &env {
899
        match info {
900 8
            EnvValue::Conditional(value) => {
901 8
                assert_eq!(value.value, "value");
902 8
                assert!(value.condition.is_some());
903

904
                ()
905
            }
906 0
            _ => panic!("invalid env value type"),
907
        };
908
    }
909 8
}
910

911
#[test]
912 8
fn env_value_deserialize_profile() {
913 8
    let config: ExternalConfig = toml::from_str(
914
        r#"
915
        [env.my-profile]
916
        bool_key = true
917
        string_key = "value"
918
        "#,
919
    )
920
    .unwrap();
921 8
    let env = config.env.unwrap();
922

923 8
    for (_, info) in &env {
924
        match info {
925 8
            EnvValue::Profile(value) => {
926 8
                assert_eq!(value.len(), 2);
927

928
                ()
929
            }
930 0
            _ => panic!("invalid env value type"),
931
        };
932
    }
933 8
}
934

935
#[test]
936 8
fn env_value_deserialize_unset() {
937 8
    let config: ExternalConfig = toml::from_str(
938
        r#"
939
        [env]
940
        key = { unset = true }
941
        "#,
942
    )
943
    .unwrap();
944 8
    let env = config.env.unwrap();
945

946 8
    for (_, info) in &env {
947
        match info {
948 8
            EnvValue::Unset(value) => {
949 8
                assert!(value.unset);
950

951
                ()
952
            }
953 0
            _ => panic!("invalid env value type"),
954
        };
955
    }
956 8
}
957

958
#[test]
959 8
fn task_new() {
960 8
    let task = Task::new();
961

962 8
    assert!(task.clear.is_none());
963 8
    assert!(task.install_crate.is_none());
964 8
    assert!(task.install_crate_args.is_none());
965 8
    assert!(task.command.is_none());
966 8
    assert!(task.disabled.is_none());
967 8
    assert!(task.private.is_none());
968 8
    assert!(task.deprecated.is_none());
969 8
    assert!(task.extend.is_none());
970 8
    assert!(task.watch.is_none());
971 8
    assert!(task.condition.is_none());
972 8
    assert!(task.condition_script.is_none());
973 8
    assert!(task.description.is_none());
974 8
    assert!(task.category.is_none());
975 8
    assert!(task.workspace.is_none());
976 8
    assert!(task.ignore_errors.is_none());
977 8
    assert!(task.force.is_none());
978 8
    assert!(task.env_files.is_none());
979 8
    assert!(task.env.is_none());
980 8
    assert!(task.cwd.is_none());
981 8
    assert!(task.alias.is_none());
982 8
    assert!(task.linux_alias.is_none());
983 8
    assert!(task.windows_alias.is_none());
984 8
    assert!(task.mac_alias.is_none());
985 8
    assert!(task.install_script.is_none());
986 8
    assert!(task.args.is_none());
987 8
    assert!(task.script.is_none());
988 8
    assert!(task.script_runner.is_none());
989 8
    assert!(task.script_runner_args.is_none());
990 8
    assert!(task.script_extension.is_none());
991 8
    assert!(task.run_task.is_none());
992 8
    assert!(task.dependencies.is_none());
993 8
    assert!(task.toolchain.is_none());
994 8
    assert!(task.linux.is_none());
995 8
    assert!(task.windows.is_none());
996 8
    assert!(task.mac.is_none());
997 8
}
998

999
#[test]
1000 8
fn external_config_new() {
1001 8
    let config = ExternalConfig::new();
1002

1003 8
    assert!(config.extend.is_none());
1004 8
    assert!(config.config.is_none());
1005 8
    assert!(config.env_files.is_none());
1006 8
    assert!(config.env.is_none());
1007 8
    assert!(config.env_scripts.is_none());
1008 8
    assert!(config.tasks.is_none());
1009 8
}
1010

1011
#[test]
1012 8
fn task_should_ignore_errors_none() {
1013 8
    let task = Task::new();
1014 8
    assert!(!task.should_ignore_errors());
1015 8
}
1016

1017
#[test]
1018 8
fn task_should_ignore_errors_false() {
1019 8
    let mut task = Task::new();
1020 8
    task.ignore_errors = Some(false);
1021 8
    assert!(!task.should_ignore_errors());
1022 8
}
1023

1024
#[test]
1025 8
fn task_should_ignore_errors_true() {
1026 8
    let mut task = Task::new();
1027 8
    task.ignore_errors = Some(true);
1028 8
    assert!(task.should_ignore_errors());
1029 8
}
1030

1031
#[test]
1032 8
fn task_should_ignore_errors_force_false() {
1033 8
    let mut task = Task::new();
1034 8
    task.force = Some(false);
1035 8
    assert!(!task.should_ignore_errors());
1036 8
}
1037

1038
#[test]
1039 8
fn task_should_ignore_errors_force_true() {
1040 8
    let mut task = Task::new();
1041 8
    task.force = Some(true);
1042 8
    assert!(task.should_ignore_errors());
1043 8
}
1044

1045
#[test]
1046 8
fn task_should_ignore_errors_false_force_true() {
1047 8
    let mut task = Task::new();
1048 8
    task.ignore_errors = Some(false);
1049 8
    task.force = Some(true);
1050 8
    assert!(!task.should_ignore_errors());
1051 8
}
1052

1053
#[test]
1054 8
fn task_extend_both_have_misc_data() {
1055 8
    let mut base = Task::new();
1056 8
    base.install_crate = Some(InstallCrate::Value("my crate1".to_string()));
1057 8
    base.command = Some("test1".to_string());
1058 8
    base.disabled = Some(false);
1059 8
    base.private = Some(false);
1060 8
    base.deprecated = Some(DeprecationInfo::Message("base".to_string()));
1061 8
    base.watch = Some(TaskWatchOptions::Boolean(false));
1062 8
    base.script = Some(ScriptValue::Text(vec!["1".to_string(), "2".to_string()]));
1063

1064 8
    let extended = Task {
1065 8
        clear: Some(false),
1066 8
        install_crate: Some(InstallCrate::Value("my crate2".to_string())),
1067 8
        command: None,
1068 8
        description: None,
1069 8
        category: None,
1070 8
        workspace: None,
1071 8
        disabled: Some(true),
1072 8
        private: Some(true),
1073 8
        deprecated: Some(DeprecationInfo::Message("extended".to_string())),
1074 8
        extend: None,
1075 8
        watch: Some(TaskWatchOptions::Boolean(true)),
1076 8
        condition: None,
1077 8
        condition_script: None,
1078 8
        ignore_errors: Some(true),
1079 8
        force: Some(true),
1080 8
        env_files: Some(vec![]),
1081 8
        env: Some(IndexMap::new()),
1082 8
        cwd: None,
1083 8
        alias: Some("alias2".to_string()),
1084 8
        linux_alias: None,
1085 8
        windows_alias: None,
1086 8
        mac_alias: None,
1087 8
        install_crate_args: None,
1088 8
        install_script: None,
1089 8
        args: None,
1090 8
        script: None,
1091 8
        script_runner: None,
1092 8
        script_runner_args: None,
1093 8
        script_extension: None,
1094 8
        run_task: None,
1095 8
        dependencies: None,
1096 8
        toolchain: None,
1097 8
        linux: None,
1098 8
        windows: None,
1099 8
        mac: None,
1100 0
    };
1101

1102 8
    base.extend(&extended);
1103

1104 8
    assert!(!base.clear.unwrap());
1105 8
    assert!(base.install_crate.is_some());
1106 8
    assert!(base.command.is_some());
1107 8
    assert!(base.description.is_none());
1108 8
    assert!(base.category.is_none());
1109 8
    assert!(base.workspace.is_none());
1110 8
    assert!(base.disabled.is_some());
1111 8
    assert!(base.private.is_some());
1112 8
    assert!(base.deprecated.is_some());
1113 8
    assert!(base.extend.is_none());
1114 8
    assert!(base.watch.is_some());
1115 8
    assert!(base.condition.is_none());
1116 8
    assert!(base.condition_script.is_none());
1117 8
    assert!(base.ignore_errors.is_some());
1118 8
    assert!(base.force.is_some());
1119 8
    assert!(base.env_files.is_some());
1120 8
    assert!(base.env.is_some());
1121 8
    assert!(base.cwd.is_none());
1122 8
    assert!(base.alias.is_some());
1123 8
    assert!(base.linux_alias.is_none());
1124 8
    assert!(base.windows_alias.is_none());
1125 8
    assert!(base.mac_alias.is_none());
1126 8
    assert!(base.install_crate_args.is_none());
1127 8
    assert!(base.install_script.is_none());
1128 8
    assert!(base.script_runner.is_none());
1129 8
    assert!(base.script_runner_args.is_none());
1130 8
    assert!(base.script_extension.is_none());
1131 8
    assert!(base.run_task.is_none());
1132 8
    assert!(base.args.is_none());
1133 8
    assert!(base.script.is_some());
1134 8
    assert!(base.dependencies.is_none());
1135 8
    assert!(base.toolchain.is_none());
1136 8
    assert!(base.linux.is_none());
1137 8
    assert!(base.windows.is_none());
1138 8
    assert!(base.mac.is_none());
1139

1140 8
    assert_eq!(get_script_vec(&base).len(), 2);
1141 8
    assert_eq!(
1142 8
        base.install_crate.unwrap(),
1143 8
        InstallCrate::Value("my crate2".to_string())
1144
    );
1145 8
    assert_eq!(base.command.unwrap(), "test1");
1146 8
    assert!(base.disabled.unwrap());
1147 8
    assert!(base.private.unwrap());
1148 8
    assert_eq!(
1149 8
        base.deprecated.unwrap(),
1150 8
        DeprecationInfo::Message("extended".to_string())
1151
    );
1152 8
    assert_eq!(base.watch.unwrap(), TaskWatchOptions::Boolean(true));
1153 8
    assert!(base.ignore_errors.unwrap());
1154 8
    assert!(base.force.unwrap());
1155 8
    assert_eq!(base.env_files.unwrap().len(), 0);
1156 8
    assert_eq!(base.env.unwrap().len(), 0);
1157 8
    assert_eq!(base.alias.unwrap(), "alias2");
1158 8
}
1159

1160
#[test]
1161 8
fn task_extend_extended_have_all_fields() {
1162 8
    let mut base = Task {
1163 8
        clear: Some(true),
1164 8
        install_crate: Some(InstallCrate::Value("my crate1".to_string())),
1165 8
        command: Some("test1".to_string()),
1166 8
        description: None,
1167 8
        category: None,
1168 8
        workspace: None,
1169 8
        disabled: Some(false),
1170 8
        private: Some(true),
1171 8
        deprecated: Some(DeprecationInfo::Boolean(true)),
1172 8
        extend: Some("base".to_string()),
1173 8
        watch: Some(TaskWatchOptions::Boolean(true)),
1174 8
        condition: None,
1175 8
        condition_script: None,
1176 8
        ignore_errors: Some(true),
1177 8
        force: Some(true),
1178 8
        env_files: Some(vec![]),
1179 8
        env: Some(IndexMap::new()),
1180 8
        cwd: None,
1181 8
        alias: None,
1182 8
        linux_alias: None,
1183 8
        windows_alias: None,
1184 8
        mac_alias: None,
1185 8
        install_crate_args: None,
1186 8
        install_script: None,
1187 8
        args: None,
1188 8
        script: Some(ScriptValue::Text(vec!["1".to_string(), "2".to_string()])),
1189 8
        script_runner: Some("sh1".to_string()),
1190 8
        script_runner_args: None,
1191 8
        script_extension: Some("ext1".to_string()),
1192 8
        run_task: Some(RunTaskInfo::Name("task1".to_string())),
1193 8
        dependencies: None,
1194 8
        toolchain: None,
1195 8
        linux: None,
1196 8
        windows: None,
1197 8
        mac: None,
1198 0
    };
1199

1200 8
    let mut env = IndexMap::new();
1201 8
    env.insert("test".to_string(), EnvValue::Value("value".to_string()));
1202 8
    let extended = Task {
1203 8
        clear: Some(false),
1204 8
        install_crate: Some(InstallCrate::Value("my crate2".to_string())),
1205 8
        install_crate_args: Some(vec!["c1".to_string(), "c2".to_string()]),
1206 8
        command: Some("test2".to_string()),
1207 8
        description: Some("description".to_string()),
1208 8
        category: Some("category".to_string()),
1209 8
        workspace: Some(true),
1210 8
        disabled: Some(true),
1211 8
        private: Some(false),
1212 8
        deprecated: Some(DeprecationInfo::Boolean(false)),
1213 8
        extend: Some("extended".to_string()),
1214 8
        watch: Some(TaskWatchOptions::Boolean(false)),
1215 8
        condition: Some(TaskCondition {
1216 8
            fail_message: None,
1217 8
            profiles: Some(vec!["development".to_string()]),
1218 8
            platforms: Some(vec!["linux".to_string(), "mac".to_string()]),
1219 8
            channels: Some(vec!["nightly".to_string(), "stable".to_string()]),
1220 8
            env_set: None,
1221 8
            env_not_set: None,
1222 8
            env_true: None,
1223 8
            env_false: None,
1224 8
            env: None,
1225 8
            env_contains: None,
1226 8
            rust_version: None,
1227 8
            files_exist: None,
1228 8
            files_not_exist: None,
1229 0
        }),
1230 8
        condition_script: Some(vec!["exit 0".to_string()]),
1231 8
        ignore_errors: Some(false),
1232 8
        force: Some(false),
1233 8
        env_files: Some(vec![EnvFile::Path("extended".to_string())]),
1234 8
        env: Some(env.clone()),
1235 8
        cwd: Some("cwd".to_string()),
1236 8
        alias: Some("alias2".to_string()),
1237 8
        linux_alias: Some("linux".to_string()),
1238 8
        windows_alias: Some("windows".to_string()),
1239 8
        mac_alias: Some("mac".to_string()),
1240 8
        install_script: Some(vec!["i1".to_string(), "i2".to_string()]),
1241 8
        args: Some(vec!["a1".to_string(), "a2".to_string()]),
1242 8
        script: Some(ScriptValue::Text(vec![
1243 8
            "1".to_string(),
1244 8
            "2".to_string(),
1245 8
            "3".to_string(),
1246
        ])),
1247 8
        script_runner: Some("sh2".to_string()),
1248 8
        script_runner_args: Some(vec!["sr_a1".to_string(), "sr_a2".to_string()]),
1249 8
        script_extension: Some("ext2".to_string()),
1250 8
        run_task: Some(RunTaskInfo::Name("task2".to_string())),
1251 8
        dependencies: Some(vec!["A".to_string()]),
1252 8
        toolchain: Some("toolchain".to_string()),
1253 8
        linux: Some(PlatformOverrideTask {
1254 8
            clear: Some(true),
1255 8
            install_crate: Some(InstallCrate::Value("my crate2".to_string())),
1256 8
            install_crate_args: Some(vec!["c1".to_string(), "c2".to_string()]),
1257 8
            command: Some("test2".to_string()),
1258 8
            disabled: Some(true),
1259 8
            private: Some(false),
1260 8
            deprecated: Some(DeprecationInfo::Boolean(false)),
1261 8
            extend: Some("extended".to_string()),
1262 8
            watch: Some(TaskWatchOptions::Boolean(false)),
1263 8
            condition: Some(TaskCondition {
1264 8
                fail_message: None,
1265 8
                profiles: Some(vec!["development".to_string()]),
1266 8
                platforms: Some(vec!["linux".to_string(), "mac".to_string()]),
1267 8
                channels: Some(vec!["nightly".to_string(), "stable".to_string()]),
1268 8
                env_set: None,
1269 8
                env_not_set: None,
1270 8
                env_true: None,
1271 8
                env_false: None,
1272 8
                env: None,
1273 8
                env_contains: None,
1274 8
                rust_version: None,
1275 8
                files_exist: None,
1276 8
                files_not_exist: None,
1277 0
            }),
1278 8
            condition_script: Some(vec!["exit 0".to_string()]),
1279 8
            ignore_errors: Some(true),
1280 8
            force: Some(true),
1281 8
            env_files: Some(vec![EnvFile::Path("extended".to_string())]),
1282 8
            env: Some(env.clone()),
1283 8
            cwd: Some("cwd".to_string()),
1284 8
            install_script: Some(vec!["i1".to_string(), "i2".to_string()]),
1285 8
            args: Some(vec!["a1".to_string(), "a2".to_string()]),
1286 8
            script: Some(ScriptValue::Text(vec![
1287 8
                "1".to_string(),
1288 8
                "2".to_string(),
1289 8
                "3".to_string(),
1290
            ])),
1291 8
            script_runner: Some("sh3".to_string()),
1292 8
            script_runner_args: Some(vec!["sr_a1".to_string(), "sr_a2".to_string()]),
1293 8
            script_extension: Some("ext3".to_string()),
1294 8
            run_task: Some(RunTaskInfo::Name("task3".to_string())),
1295 8
            dependencies: Some(vec!["A".to_string()]),
1296 8
            toolchain: Some("toolchain".to_string()),
1297 0
        }),
1298 8
        windows: Some(PlatformOverrideTask {
1299 8
            clear: Some(false),
1300 8
            install_crate: Some(InstallCrate::Value("my crate2".to_string())),
1301 8
            install_crate_args: Some(vec!["c1".to_string(), "c2".to_string()]),
1302 8
            command: Some("test2".to_string()),
1303 8
            disabled: Some(true),
1304 8
            private: Some(false),
1305 8
            deprecated: Some(DeprecationInfo::Boolean(false)),
1306 8
            extend: Some("extended".to_string()),
1307 8
            watch: Some(TaskWatchOptions::Boolean(false)),
1308 8
            condition: Some(TaskCondition {
1309 8
                fail_message: None,
1310 8
                profiles: Some(vec!["development".to_string()]),
1311 8
                platforms: Some(vec!["linux".to_string(), "mac".to_string()]),
1312 8
                channels: Some(vec!["nightly".to_string(), "stable".to_string()]),
1313 8
                env_set: None,
1314 8
                env_not_set: None,
1315 8
                env_true: None,
1316 8
                env_false: None,
1317 8
                env: None,
1318 8
                env_contains: None,
1319 8
                rust_version: None,
1320 8
                files_exist: None,
1321 8
                files_not_exist: None,
1322 0
            }),
1323 8
            condition_script: Some(vec!["exit 0".to_string()]),
1324 8
            ignore_errors: Some(true),
1325 8
            force: Some(true),
1326 8
            env_files: Some(vec![EnvFile::Path("extended".to_string())]),
1327 8
            env: Some(env.clone()),
1328 8
            cwd: Some("cwd".to_string()),
1329 8
            install_script: Some(vec!["i1".to_string(), "i2".to_string()]),
1330 8
            args: Some(vec!["a1".to_string(), "a2".to_string()]),
1331 8
            script: Some(ScriptValue::Text(vec![
1332 8
                "1".to_string(),
1333 8
                "2".to_string(),
1334 8
                "3".to_string(),
1335
            ])),
1336 8
            script_runner: Some("sh3".to_string()),
1337 8
            script_runner_args: Some(vec!["sr_a1".to_string(), "sr_a2".to_string()]),
1338 8
            script_extension: Some("ext3".to_string()),
1339 8
            run_task: Some(RunTaskInfo::Name("task3".to_string())),
1340 8
            dependencies: Some(vec!["A".to_string()]),
1341 8
            toolchain: Some("toolchain".to_string()),
1342 0
        }),
1343 8
        mac: Some(PlatformOverrideTask {
1344 8
            clear: None,
1345 8
            install_crate: Some(InstallCrate::Value("my crate2".to_string())),
1346 8
            install_crate_args: Some(vec!["c1".to_string(), "c2".to_string()]),
1347 8
            command: Some("test2".to_string()),
1348 8
            disabled: Some(true),
1349 8
            private: Some(false),
1350 8
            deprecated: Some(DeprecationInfo::Boolean(false)),
1351 8
            extend: Some("extended".to_string()),
1352 8
            watch: Some(TaskWatchOptions::Boolean(false)),
1353 8
            condition: Some(TaskCondition {
1354 8
                fail_message: None,
1355 8
                profiles: Some(vec!["development".to_string()]),
1356 8
                platforms: Some(vec!["linux".to_string(), "mac".to_string()]),
1357 8
                channels: Some(vec!["nightly".to_string(), "stable".to_string()]),
1358 8
                env_set: None,
1359 8
                env_not_set: None,
1360 8
                env_true: None,
1361 8
                env_false: None,
1362 8
                env: None,
1363 8
                env_contains: None,
1364 8
                rust_version: None,
1365 8
                files_exist: None,
1366 8
                files_not_exist: None,
1367 0
            }),
1368 8
            condition_script: Some(vec!["exit 0".to_string()]),
1369 8
            ignore_errors: Some(true),
1370 8
            force: Some(true),
1371 8
            env_files: Some(vec![EnvFile::Path("extended".to_string())]),
1372 8
            env: Some(env.clone()),
1373 8
            cwd: Some("cwd".to_string()),
1374 8
            install_script: Some(vec!["i1".to_string(), "i2".to_string()]),
1375 8
            args: Some(vec!["a1".to_string(), "a2".to_string()]),
1376 8
            script: Some(ScriptValue::Text(vec![
1377 8
                "1".to_string(),
1378 8
                "2".to_string(),
1379 8
                "3".to_string(),
1380
            ])),
1381 8
            script_runner: Some("sh3".to_string()),
1382 8
            script_runner_args: Some(vec!["sr_a1".to_string(), "sr_a2".to_string()]),
1383 8
            script_extension: Some("ext3".to_string()),
1384 8
            run_task: Some(RunTaskInfo::Name("task3".to_string())),
1385 8
            dependencies: Some(vec!["A".to_string()]),
1386 8
            toolchain: Some("toolchain".to_string()),
1387 0
        }),
1388 0
    };
1389

1390 8
    base.extend(&extended);
1391

1392 8
    assert!(!base.clear.unwrap());
1393 8
    assert!(base.install_crate.is_some());
1394 8
    assert!(base.install_crate_args.is_some());
1395 8
    assert!(base.command.is_some());
1396 8
    assert!(base.description.is_some());
1397 8
    assert!(base.category.is_some());
1398 8
    assert!(base.workspace.is_some());
1399 8
    assert!(base.disabled.is_some());
1400 8
    assert!(base.private.is_some());
1401 8
    assert!(base.deprecated.is_some());
1402 8
    assert!(base.extend.is_some());
1403 8
    assert!(base.watch.is_some());
1404 8
    assert!(base.condition.is_some());
1405 8
    assert!(base.condition_script.is_some());
1406 8
    assert!(base.ignore_errors.is_some());
1407 8
    assert!(base.force.is_some());
1408 8
    assert!(base.env_files.is_some());
1409 8
    assert!(base.env.is_some());
1410 8
    assert!(base.cwd.is_some());
1411 8
    assert!(base.alias.is_some());
1412 8
    assert!(base.linux_alias.is_some());
1413 8
    assert!(base.windows_alias.is_some());
1414 8
    assert!(base.mac_alias.is_some());
1415 8
    assert!(base.install_script.is_some());
1416 8
    assert!(base.args.is_some());
1417 8
    assert!(base.script.is_some());
1418 8
    assert!(base.script_runner.is_some());
1419 8
    assert!(base.script_runner_args.is_some());
1420 8
    assert!(base.script_extension.is_some());
1421 8
    assert!(base.run_task.is_some());
1422 8
    assert!(base.dependencies.is_some());
1423 8
    assert!(base.toolchain.is_some());
1424 8
    assert!(base.linux.is_some());
1425 8
    assert!(base.windows.is_some());
1426 8
    assert!(base.mac.is_some());
1427

1428 8
    assert_eq!(get_script_vec(&base).len(), 3);
1429 8
    assert_eq!(
1430 8
        base.install_crate.unwrap(),
1431 8
        InstallCrate::Value("my crate2".to_string())
1432
    );
1433 8
    assert_eq!(base.install_crate_args.unwrap().len(), 2);
1434 8
    assert_eq!(base.command.unwrap(), "test2");
1435 8
    assert_eq!(base.description.unwrap(), "description");
1436 8
    assert_eq!(base.category.unwrap(), "category");
1437 8
    assert!(base.workspace.unwrap());
1438 8
    assert!(base.disabled.unwrap());
1439 8
    assert!(!base.private.unwrap());
1440 8
    assert_eq!(base.deprecated.unwrap(), DeprecationInfo::Boolean(false));
1441 8
    assert_eq!(base.extend.unwrap(), "extended");
1442 8
    assert_eq!(base.watch.unwrap(), TaskWatchOptions::Boolean(false));
1443 8
    assert_eq!(base.condition_script.unwrap().len(), 1);
1444 8
    assert!(!base.ignore_errors.unwrap());
1445 8
    assert!(!base.force.unwrap());
1446 8
    assert_eq!(base.env_files.unwrap().len(), 1);
1447 8
    assert_eq!(base.env.unwrap().len(), 1);
1448 8
    assert_eq!(base.cwd.unwrap(), "cwd".to_string());
1449 8
    assert_eq!(base.alias.unwrap(), "alias2");
1450 8
    assert_eq!(base.linux_alias.unwrap(), "linux");
1451 8
    assert_eq!(base.windows_alias.unwrap(), "windows");
1452 8
    assert_eq!(base.mac_alias.unwrap(), "mac");
1453 8
    assert_eq!(base.install_script.unwrap().len(), 2);
1454 8
    assert_eq!(base.args.unwrap().len(), 2);
1455 8
    assert_eq!(base.script_runner.unwrap(), "sh2");
1456 8
    assert_eq!(base.script_runner_args.unwrap().len(), 2);
1457 8
    assert_eq!(base.script_extension.unwrap(), "ext2");
1458 8
    let run_task_name = match base.run_task.unwrap() {
1459 8
        RunTaskInfo::Name(name) => name,
1460 0
        _ => panic!("Invalid run task value."),
1461 8
    };
1462 8
    assert_eq!(run_task_name, "task2".to_string());
1463 8
    assert_eq!(base.dependencies.unwrap().len(), 1);
1464 8
    assert_eq!(base.toolchain.unwrap(), "toolchain");
1465 8
    assert!(base.linux.unwrap().clear.unwrap());
1466 8
    assert!(!base.windows.unwrap().clear.unwrap());
1467 8
    assert!(base.mac.unwrap().clear.is_none());
1468

1469 8
    let condition = base.condition.unwrap();
1470 8
    assert_eq!(condition.platforms.unwrap().len(), 2);
1471 8
    assert_eq!(condition.channels.unwrap().len(), 2);
1472 8
}
1473

1474
#[test]
1475 8
fn task_extend_clear_with_no_data() {
1476 8
    let env = IndexMap::new();
1477 8
    let mut base = Task {
1478 8
        clear: Some(false),
1479 8
        install_crate: Some(InstallCrate::Value("my crate2".to_string())),
1480 8
        install_crate_args: Some(vec!["c1".to_string(), "c2".to_string()]),
1481 8
        command: Some("test2".to_string()),
1482 8
        description: Some("description".to_string()),
1483 8
        category: Some("category".to_string()),
1484 8
        workspace: Some(false),
1485 8
        disabled: Some(true),
1486 8
        private: Some(false),
1487 8
        deprecated: Some(DeprecationInfo::Boolean(true)),
1488 8
        extend: Some("base".to_string()),
1489 8
        watch: Some(TaskWatchOptions::Boolean(false)),
1490 8
        condition: Some(TaskCondition {
1491 8
            fail_message: None,
1492 8
            profiles: Some(vec!["development".to_string()]),
1493 8
            platforms: Some(vec!["linux".to_string(), "mac".to_string()]),
1494 8
            channels: Some(vec!["nightly".to_string(), "stable".to_string()]),
1495 8
            env_set: None,
1496 8
            env_not_set: None,
1497 8
            env_true: None,
1498 8
            env_false: None,
1499 8
            env: None,
1500 8
            env_contains: None,
1501 8
            rust_version: None,
1502 8
            files_exist: None,
1503 8
            files_not_exist: None,
1504 0
        }),
1505 8
        condition_script: Some(vec!["exit 0".to_string()]),
1506 8
        ignore_errors: Some(false),
1507 8
        force: Some(false),
1508 8
        env_files: Some(vec![]),
1509 8
        env: Some(env.clone()),
1510 8
        cwd: Some("cwd".to_string()),
1511 8
        alias: Some("alias2".to_string()),
1512 8
        linux_alias: Some("linux".to_string()),
1513 8
        windows_alias: Some("windows".to_string()),
1514 8
        mac_alias: Some("mac".to_string()),
1515 8
        install_script: Some(vec!["i1".to_string(), "i2".to_string()]),
1516 8
        args: Some(vec!["a1".to_string(), "a2".to_string()]),
1517 8
        script: Some(ScriptValue::Text(vec![
1518 8
            "1".to_string(),
1519 8
            "2".to_string(),
1520 8
            "3".to_string(),
1521
        ])),
1522 8
        script_runner: Some("sh2".to_string()),
1523 8
        script_runner_args: Some(vec!["sr_a1".to_string(), "sr_a2".to_string()]),
1524 8
        script_extension: Some("ext2".to_string()),
1525 8
        run_task: Some(RunTaskInfo::Name("task2".to_string())),
1526 8
        dependencies: Some(vec!["A".to_string()]),
1527 8
        toolchain: Some("toolchain".to_string()),
1528 8
        linux: Some(PlatformOverrideTask {
1529 8
            clear: Some(true),
1530 8
            install_crate: Some(InstallCrate::Value("my crate2".to_string())),
1531 8
            install_crate_args: Some(vec!["c1".to_string(), "c2".to_string()]),
1532 8
            command: Some("test2".to_string()),
1533 8
            disabled: Some(true),
1534 8
            private: Some(false),
1535 8
            deprecated: Some(DeprecationInfo::Boolean(true)),
1536 8
            extend: Some("base".to_string()),
1537 8
            watch: Some(TaskWatchOptions::Boolean(false)),
1538 8
            condition: Some(TaskCondition {
1539 8
                fail_message: None,
1540 8
                profiles: Some(vec!["development".to_string()]),
1541 8
                platforms: Some(vec!["linux".to_string(), "mac".to_string()]),
1542 8
                channels: Some(vec!["nightly".to_string(), "stable".to_string()]),
1543 8
                env_set: None,
1544 8
                env_not_set: None,
1545 8
                env_true: None,
1546 8
                env_false: None,
1547 8
                env: None,
1548 8
                env_contains: None,
1549 8
                rust_version: None,
1550 8
                files_exist: None,
1551 8
                files_not_exist: None,
1552 0
            }),
1553 8
            condition_script: Some(vec!["exit 0".to_string()]),
1554 8
            ignore_errors: Some(true),
1555 8
            force: Some(true),
1556 8
            env_files: Some(vec![]),
1557 8
            env: Some(env.clone()),
1558 8
            cwd: Some("cwd".to_string()),
1559 8
            install_script: Some(vec!["i1".to_string(), "i2".to_string()]),
1560 8
            args: Some(vec!["a1".to_string(), "a2".to_string()]),
1561 8
            script: Some(ScriptValue::Text(vec![
1562 8
                "1".to_string(),
1563 8
                "2".to_string(),
1564 8
                "3".to_string(),
1565
            ])),
1566 8
            script_runner: Some("sh3".to_string()),
1567 8
            script_runner_args: Some(vec!["sr_a1".to_string(), "sr_a2".to_string()]),
1568 8
            script_extension: Some("ext3".to_string()),
1569 8
            run_task: Some(RunTaskInfo::Name("task3".to_string())),
1570 8
            dependencies: Some(vec!["A".to_string()]),
1571 8
            toolchain: Some("toolchain".to_string()),
1572 0
        }),
1573 8
        windows: Some(PlatformOverrideTask {
1574 8
            clear: Some(false),
1575 8
            install_crate: Some(InstallCrate::Value("my crate2".to_string())),
1576 8
            install_crate_args: Some(vec!["c1".to_string(), "c2".to_string()]),
1577 8
            command: Some("test2".to_string()),
1578 8
            disabled: Some(true),
1579 8
            private: Some(false),
1580 8
            deprecated: Some(DeprecationInfo::Boolean(true)),
1581 8
            extend: Some("base".to_string()),
1582 8
            watch: Some(TaskWatchOptions::Boolean(false)),
1583 8
            condition: Some(TaskCondition {
1584 8
                fail_message: None,
1585 8
                profiles: Some(vec!["development".to_string()]),
1586 8
                platforms: Some(vec!["linux".to_string(), "mac".to_string()]),
1587 8
                channels: Some(vec!["nightly".to_string(), "stable".to_string()]),
1588 8
                env_set: None,
1589 8
                env_not_set: None,
1590 8
                env_true: None,
1591 8
                env_false: None,
1592 8
                env: None,
1593 8
                env_contains: None,
1594 8
                rust_version: None,
1595 8
                files_exist: None,
1596 8
                files_not_exist: None,
1597 0
            }),
1598 8
            condition_script: Some(vec!["exit 0".to_string()]),
1599 8
            ignore_errors: Some(true),
1600 8
            force: Some(true),
1601 8
            env_files: Some(vec![]),
1602 8
            env: Some(env.clone()),
1603 8
            cwd: Some("cwd".to_string()),
1604 8
            install_script: Some(vec!["i1".to_string(), "i2".to_string()]),
1605 8
            args: Some(vec!["a1".to_string(), "a2".to_string()]),
1606 8
            script: Some(ScriptValue::Text(vec![
1607 8
                "1".to_string(),
1608 8
                "2".to_string(),
1609 8
                "3".to_string(),
1610
            ])),
1611 8
            script_runner: Some("sh3".to_string()),
1612 8
            script_runner_args: Some(vec!["sr_a1".to_string(), "sr_a2".to_string()]),
1613 8
            script_extension: Some("ext3".to_string()),
1614 8
            run_task: Some(RunTaskInfo::Name("task3".to_string())),
1615 8
            dependencies: Some(vec!["A".to_string()]),
1616 8
            toolchain: Some("toolchain".to_string()),
1617 0
        }),
1618 8
        mac: Some(PlatformOverrideTask {
1619 8
            clear: None,
1620 8
            install_crate: Some(InstallCrate::Value("my crate2".to_string())),
1621 8
            install_crate_args: Some(vec!["c1".to_string(), "c2".to_string()]),
1622 8
            command: Some("test2".to_string()),
1623 8
            disabled: Some(true),
1624 8
            private: Some(false),
1625 8
            deprecated: Some(DeprecationInfo::Boolean(true)),
1626 8
            extend: Some("base".to_string()),
1627 8
            watch: Some(TaskWatchOptions::Boolean(false)),
1628 8
            condition: Some(TaskCondition {
1629 8
                fail_message: None,
1630 8
                profiles: Some(vec!["development".to_string()]),
1631 8
                platforms: Some(vec!["linux".to_string(), "mac".to_string()]),
1632 8
                channels: Some(vec!["nightly".to_string(), "stable".to_string()]),
1633 8
                env_set: None,
1634 8
                env_not_set: None,
1635 8
                env_true: None,
1636 8
                env_false: None,
1637 8
                env: None,
1638 8
                env_contains: None,
1639 8
                rust_version: None,
1640 8
                files_exist: None,
1641 8
                files_not_exist: None,
1642 0
            }),
1643 8
            condition_script: Some(vec!["exit 0".to_string()]),
1644 8
            ignore_errors: Some(true),
1645 8
            force: Some(true),
1646 8
            env_files: Some(vec![]),
1647 8
            env: Some(env.clone()),
1648 8
            cwd: Some("cwd".to_string()),
1649 8
            install_script: Some(vec!["i1".to_string(), "i2".to_string()]),
1650 8
            args: Some(vec!["a1".to_string(), "a2".to_string()]),
1651 8
            script: Some(ScriptValue::Text(vec![
1652 8
                "1".to_string(),
1653 8
                "2".to_string(),
1654 8
                "3".to_string(),
1655
            ])),
1656 8
            script_runner: Some("sh3".to_string()),
1657 8
            script_runner_args: Some(vec!["sr_a1".to_string(), "sr_a2".to_string()]),
1658 8
            script_extension: Some("ext3".to_string()),
1659 8
            run_task: Some(RunTaskInfo::Name("task3".to_string())),
1660 8
            dependencies: Some(vec!["A".to_string()]),
1661 8
            toolchain: Some("toolchain".to_string()),
1662 0
        }),
1663 0
    };
1664

1665 8
    let mut extended = Task::new();
1666 8
    extended.clear = Some(true);
1667

1668 8
    base.extend(&extended);
1669

1670 8
    assert!(base.clear.unwrap());
1671 8
    assert!(base.install_crate.is_none());
1672 8
    assert!(base.command.is_none());
1673 8
    assert!(base.description.is_none());
1674 8
    assert!(base.category.is_none());
1675 8
    assert!(base.workspace.is_none());
1676 8
    assert!(base.disabled.is_none());
1677 8
    assert!(base.private.is_none());
1678 8
    assert!(base.deprecated.is_none());
1679 8
    assert!(base.extend.is_none());
1680 8
    assert!(base.watch.is_none());
1681 8
    assert!(base.condition.is_none());
1682 8
    assert!(base.condition_script.is_none());
1683 8
    assert!(base.ignore_errors.is_none());
1684 8
    assert!(base.force.is_none());
1685 8
    assert!(base.env_files.is_none());
1686 8
    assert!(base.env.is_none());
1687 8
    assert!(base.cwd.is_none());
1688 8
    assert!(base.alias.is_none());
1689 8
    assert!(base.linux_alias.is_none());
1690 8
    assert!(base.windows_alias.is_none());
1691 8
    assert!(base.mac_alias.is_none());
1692 8
    assert!(base.install_crate_args.is_none());
1693 8
    assert!(base.install_script.is_none());
1694 8
    assert!(base.script_runner.is_none());
1695 8
    assert!(base.script_runner_args.is_none());
1696 8
    assert!(base.script_extension.is_none());
1697 8
    assert!(base.run_task.is_none());
1698 8
    assert!(base.args.is_none());
1699 8
    assert!(base.script.is_none());
1700 8
    assert!(base.dependencies.is_none());
1701 8
    assert!(base.toolchain.is_none());
1702 8
    assert!(base.linux.is_none());
1703 8
    assert!(base.windows.is_none());
1704 8
    assert!(base.mac.is_none());
1705 8
}
1706

1707
#[test]
1708 8
fn task_extend_clear_with_all_data() {
1709 8
    let mut base = Task::new();
1710

1711 8
    let env = IndexMap::new();
1712 8
    let extended = Task {
1713 8
        clear: Some(true),
1714 8
        install_crate: Some(InstallCrate::Value("my crate2".to_string())),
1715 8
        install_crate_args: Some(vec!["c1".to_string(), "c2".to_string()]),
1716 8
        command: Some("test2".to_string()),
1717 8
        description: Some("description".to_string()),
1718 8
        category: Some("category".to_string()),
1719 8
        workspace: Some(true),
1720 8
        disabled: Some(true),
1721 8
        private: Some(false),
1722 8
        deprecated: Some(DeprecationInfo::Boolean(true)),
1723 8
        extend: Some("base".to_string()),
1724 8
        watch: Some(TaskWatchOptions::Boolean(false)),
1725 8
        condition: Some(TaskCondition {
1726 8
            fail_message: None,
1727 8
            profiles: Some(vec!["development".to_string()]),
1728 8
            platforms: Some(vec!["linux".to_string(), "mac".to_string()]),
1729 8
            channels: Some(vec!["nightly".to_string(), "stable".to_string()]),
1730 8
            env_set: None,
1731 8
            env_not_set: None,
1732 8
            env_true: None,
1733 8
            env_false: None,
1734 8
            env: None,
1735 8
            env_contains: None,
1736 8
            rust_version: None,
1737 8
            files_exist: None,
1738 8
            files_not_exist: None,
1739 0
        }),
1740 8
        condition_script: Some(vec!["exit 0".to_string()]),
1741 8
        ignore_errors: Some(false),
1742 8
        force: Some(false),
1743 8
        env_files: Some(vec![]),
1744 8
        env: Some(env.clone()),
1745 8
        cwd: Some("cwd".to_string()),
1746 8
        alias: Some("alias2".to_string()),
1747 8
        linux_alias: Some("linux".to_string()),
1748 8
        windows_alias: Some("windows".to_string()),
1749 8
        mac_alias: Some("mac".to_string()),
1750 8
        install_script: Some(vec!["i1".to_string(), "i2".to_string()]),
1751 8
        args: Some(vec!["a1".to_string(), "a2".to_string()]),
1752 8
        script: Some(ScriptValue::Text(vec![
1753 8
            "1".to_string(),
1754 8
            "2".to_string(),
1755 8
            "3".to_string(),
1756
        ])),
1757 8
        script_runner: Some("sh2".to_string()),
1758 8
        script_runner_args: Some(vec!["sr_a1".to_string(), "sr_a2".to_string()]),
1759 8
        script_extension: Some("ext2".to_string()),
1760 8
        run_task: Some(RunTaskInfo::Name("task2".to_string())),
1761 8
        dependencies: Some(vec!["A".to_string()]),
1762 8
        toolchain: Some("toolchain".to_string()),
1763 8
        linux: Some(PlatformOverrideTask {
1764 8
            clear: Some(true),
1765 8
            install_crate: Some(InstallCrate::Value("my crate2".to_string())),
1766 8
            install_crate_args: Some(vec!["c1".to_string(), "c2".to_string()]),
1767 8
            command: Some("test2".to_string()),
1768 8
            disabled: Some(true),
1769 8
            private: Some(false),
1770 8
            deprecated: Some(DeprecationInfo::Boolean(true)),
1771 8
            extend: Some("base".to_string()),
1772 8
            watch: Some(TaskWatchOptions::Boolean(false)),
1773 8
            condition: Some(TaskCondition {
1774 8
                fail_message: None,
1775 8
                profiles: Some(vec!["development".to_string()]),
1776 8
                platforms: Some(vec!["linux".to_string(), "mac".to_string()]),
1777 8
                channels: Some(vec!["nightly".to_string(), "stable".to_string()]),
1778 8
                env_set: None,
1779 8
                env_not_set: None,
1780 8
                env_true: None,
1781 8
                env_false: None,
1782 8
                env: None,
1783 8
                env_contains: None,
1784 8
                rust_version: None,
1785 8
                files_exist: None,
1786 8
                files_not_exist: None,
1787 0
            }),
1788 8
            condition_script: Some(vec!["exit 0".to_string()]),
1789 8
            ignore_errors: Some(true),
1790 8
            force: Some(true),
1791 8
            env_files: Some(vec![]),
1792 8
            env: Some(env.clone()),
1793 8
            cwd: Some("cwd".to_string()),
1794 8
            install_script: Some(vec!["i1".to_string(), "i2".to_string()]),
1795 8
            args: Some(vec!["a1".to_string(), "a2".to_string()]),
1796 8
            script: Some(ScriptValue::Text(vec![
1797 8
                "1".to_string(),
1798 8
                "2".to_string(),
1799 8
                "3".to_string(),
1800
            ])),
1801 8
            script_runner: Some("sh3".to_string()),
1802 8
            script_runner_args: Some(vec!["sr_a1".to_string(), "sr_a2".to_string()]),
1803 8
            script_extension: Some("ext3".to_string()),
1804 8
            run_task: Some(RunTaskInfo::Name("task3".to_string())),
1805 8
            dependencies: Some(vec!["A".to_string()]),
1806 8
            toolchain: Some("toolchain".to_string()),
1807 0
        }),
1808 8
        windows: Some(PlatformOverrideTask {
1809 8
            clear: Some(false),
1810 8
            install_crate: Some(InstallCrate::Value("my crate2".to_string())),
1811 8
            install_crate_args: Some(vec!["c1".to_string(), "c2".to_string()]),
1812 8
            command: Some("test2".to_string()),
1813 8
            disabled: Some(true),
1814 8
            private: Some(false),
1815 8
            deprecated: Some(DeprecationInfo::Boolean(true)),
1816 8
            extend: Some("base".to_string()),
1817 8
            watch: Some(TaskWatchOptions::Boolean(false)),
1818 8
            condition: Some(TaskCondition {
1819 8
                fail_message: None,
1820 8
                profiles: Some(vec!["development".to_string()]),
1821 8
                platforms: Some(vec!["linux".to_string(), "mac".to_string()]),
1822 8
                channels: Some(vec!["nightly".to_string(), "stable".to_string()]),
1823 8
                env_set: None,
1824 8
                env_not_set: None,
1825 8
                env_true: None,
1826 8
                env_false: None,
1827 8
                env: None,
1828 8
                env_contains: None,
1829 8
                rust_version: None,
1830 8
                files_exist: None,
1831 8
                files_not_exist: None,
1832 0
            }),
1833 8
            condition_script: Some(vec!["exit 0".to_string()]),
1834 8
            ignore_errors: Some(true),
1835 8
            force: Some(true),
1836 8
            env_files: Some(vec![]),
1837 8
            env: Some(env.clone()),
1838 8
            cwd: Some("cwd".to_string()),
1839 8
            install_script: Some(vec!["i1".to_string(), "i2".to_string()]),
1840 8
            args: Some(vec!["a1".to_string(), "a2".to_string()]),
1841 8
            script: Some(ScriptValue::Text(vec![
1842 8
                "1".to_string(),
1843 8
                "2".to_string(),
1844 8
                "3".to_string(),
1845
            ])),
1846 8
            script_runner: Some("sh3".to_string()),
1847 8
            script_runner_args: Some(vec!["sr_a1".to_string(), "sr_a2".to_string()]),
1848 8
            script_extension: Some("ext3".to_string()),
1849 8
            run_task: Some(RunTaskInfo::Name("task3".to_string())),
1850 8
            dependencies: Some(vec!["A".to_string()]),
1851 8
            toolchain: Some("toolchain".to_string()),
1852 0
        }),
1853 8
        mac: Some(PlatformOverrideTask {
1854 8
            clear: None,
1855 8
            install_crate: Some(InstallCrate::Value("my crate2".to_string())),
1856 8
            install_crate_args: Some(vec!["c1".to_string(), "c2".to_string()]),
1857 8
            command: Some("test2".to_string()),
1858 8
            disabled: Some(true),
1859 8
            private: Some(false),
1860 8
            deprecated: Some(DeprecationInfo::Boolean(true)),
1861 8
            extend: Some("base".to_string()),
1862 8
            watch: Some(TaskWatchOptions::Boolean(false)),
1863 8
            condition: Some(TaskCondition {
1864 8
                fail_message: None,
1865 8
                profiles: Some(vec!["development".to_string()]),
1866 8
                platforms: Some(vec!["linux".to_string(), "mac".to_string()]),
1867 8
                channels: Some(vec!["nightly".to_string(), "stable".to_string()]),
1868 8
                env_set: None,
1869 8
                env_not_set: None,
1870 8
                env_true: None,
1871 8
                env_false: None,
1872 8
                env: None,
1873 8
                env_contains: None,
1874 8
                rust_version: None,
1875 8
                files_exist: None,
1876 8
                files_not_exist: None,
1877 0
            }),
1878 8
            condition_script: Some(vec!["exit 0".to_string()]),
1879 8
            ignore_errors: Some(true),
1880 8
            force: Some(true),
1881 8
            env_files: Some(vec![]),
1882 8
            env: Some(env.clone()),
1883 8
            cwd: Some("cwd".to_string()),
1884 8
            install_script: Some(vec!["i1".to_string(), "i2".to_string()]),
1885 8
            args: Some(vec!["a1".to_string(), "a2".to_string()]),
1886 8
            script: Some(ScriptValue::Text(vec![
1887 8
                "1".to_string(),
1888 8
                "2".to_string(),
1889 8
                "3".to_string(),
1890
            ])),
1891 8
            script_runner: Some("sh3".to_string()),
1892 8
            script_runner_args: Some(vec!["sr_a1".to_string(), "sr_a2".to_string()]),
1893 8
            script_extension: Some("ext3".to_string()),
1894 8
            run_task: Some(RunTaskInfo::Name("task3".to_string())),
1895 8
            dependencies: Some(vec!["A".to_string()]),
1896 8
            toolchain: Some("toolchain".to_string()),
1897 0
        }),
1898 0
    };
1899

1900 8
    base.extend(&extended);
1901

1902 8
    assert!(base.clear.unwrap());
1903 8
    assert!(base.install_crate.is_some());
1904 8
    assert!(base.command.is_some());
1905 8
    assert!(base.description.is_some());
1906 8
    assert!(base.category.is_some());
1907 8
    assert!(base.workspace.is_some());
1908 8
    assert!(base.disabled.is_some());
1909 8
    assert!(base.private.is_some());
1910 8
    assert!(base.deprecated.is_some());
1911 8
    assert!(base.extend.is_some());
1912 8
    assert!(base.watch.is_some());
1913 8
    assert!(base.condition.is_some());
1914 8
    assert!(base.condition_script.is_some());
1915 8
    assert!(base.ignore_errors.is_some());
1916 8
    assert!(base.force.is_some());
1917 8
    assert!(base.env_files.is_some());
1918 8
    assert!(base.env.is_some());
1919 8
    assert!(base.cwd.is_some());
1920 8
    assert!(base.alias.is_some());
1921 8
    assert!(base.linux_alias.is_some());
1922 8
    assert!(base.windows_alias.is_some());
1923 8
    assert!(base.mac_alias.is_some());
1924 8
    assert!(base.install_crate_args.is_some());
1925 8
    assert!(base.install_script.is_some());
1926 8
    assert!(base.script_runner.is_some());
1927 8
    assert!(base.script_runner_args.is_some());
1928 8
    assert!(base.script_extension.is_some());
1929 8
    assert!(base.run_task.is_some());
1930 8
    assert!(base.args.is_some());
1931 8
    assert!(base.script.is_some());
1932 8
    assert!(base.dependencies.is_some());
1933 8
    assert!(base.toolchain.is_some());
1934 8
    assert!(base.linux.is_some());
1935 8
    assert!(base.windows.is_some());
1936 8
    assert!(base.mac.is_some());
1937 8
}
1938

1939
#[test]
1940 8
fn task_get_alias_all_none() {
1941 8
    let task = Task::new();
1942

1943 8
    let alias = task.get_alias();
1944 8
    assert!(alias.is_none());
1945 8
}
1946

1947
#[test]
1948 8
fn task_get_alias_common_defined() {
1949 8
    let mut task = Task::new();
1950 8
    task.alias = Some("other".to_string());
1951

1952 8
    let alias = task.get_alias();
1953 8
    assert_eq!(alias.unwrap(), "other");
1954 8
}
1955

1956
#[test]
1957 8
fn task_get_alias_platform_defined() {
1958 8
    let mut task = Task::new();
1959 8
    task.alias = Some("other".to_string());
1960 8
    task.linux_alias = Some("linux".to_string());
1961 8
    task.windows_alias = Some("windows".to_string());
1962 8
    task.mac_alias = Some("mac".to_string());
1963

1964 8
    let alias = task.get_alias();
1965 2
    if cfg!(windows) {
1966 0
        assert_eq!(alias.unwrap(), "windows");
1967 2
    } else if cfg!(target_os = "macos") || cfg!(target_os = "ios") {
1968 0
        assert_eq!(alias.unwrap(), "mac");
1969
    } else {
1970 8
        assert_eq!(alias.unwrap(), "linux");
1971
    };
1972 8
}
1973

1974
#[test]
1975 8
fn task_get_normalized_task_undefined() {
1976 8
    let mut task = Task {
1977 8
        clear: Some(false),
1978 8
        alias: Some("alias".to_string()),
1979 8
        linux_alias: Some("linux".to_string()),
1980 8
        windows_alias: Some("windows".to_string()),
1981 8
        mac_alias: Some("mac".to_string()),
1982 8
        install_crate: Some(InstallCrate::Value("install_crate".to_string())),
1983 8
        install_crate_args: None,
1984 8
        command: Some("command".to_string()),
1985 8
        disabled: Some(false),
1986 8
        private: Some(true),
1987 8
        deprecated: None,
1988 8
        extend: Some("base".to_string()),
1989 8
        watch: Some(TaskWatchOptions::Boolean(true)),
1990 8
        condition: None,
1991 8
        condition_script: None,
1992 8
        ignore_errors: None,
1993 8
        force: None,
1994 8
        env_files: None,
1995 8
        env: None,
1996 8
        cwd: None,
1997 8
        install_script: Some(vec!["A".to_string(), "B".to_string(), "C".to_string()]),
1998 8
        args: Some(vec!["1".to_string(), "2".to_string()]),
1999 8
        script: Some(ScriptValue::Text(vec!["a".to_string(), "b".to_string()])),
2000 8
        script_runner: Some("sh1".to_string()),
2001 8
        script_runner_args: Some(vec!["sr_a1".to_string(), "sr_a2".to_string()]),
2002 8
        script_extension: Some("ext1".to_string()),
2003 8
        run_task: Some(RunTaskInfo::Name("task1".to_string())),
2004 8
        dependencies: Some(vec!["1".to_string()]),
2005 8
        toolchain: Some("toolchain2".to_string()),
2006 8
        description: Some("description".to_string()),
2007 8
        category: Some("category".to_string()),
2008 8
        workspace: Some(false),
2009 8
        linux: None,
2010 8
        windows: None,
2011 8
        mac: None,
2012 0
    };
2013

2014 8
    let normalized_task = task.get_normalized_task();
2015

2016 8
    assert!(!normalized_task.clear.unwrap());
2017 8
    assert!(normalized_task.install_crate.is_some());
2018 8
    assert!(normalized_task.install_crate_args.is_none());
2019 8
    assert!(normalized_task.command.is_some());
2020 8
    assert!(normalized_task.disabled.is_some());
2021 8
    assert!(normalized_task.private.is_some());
2022 8
    assert!(normalized_task.deprecated.is_none());
2023 8
    assert!(normalized_task.extend.is_some());
2024 8
    assert!(normalized_task.watch.is_some());
2025 8
    assert!(normalized_task.condition.is_none());
2026 8
    assert!(normalized_task.condition_script.is_none());
2027 8
    assert!(normalized_task.ignore_errors.is_none());
2028 8
    assert!(normalized_task.force.is_none());
2029 8
    assert!(normalized_task.env_files.is_none());
2030 8
    assert!(normalized_task.env.is_none());
2031 8
    assert!(normalized_task.cwd.is_none());
2032 8
    assert!(normalized_task.alias.is_some());
2033 8
    assert!(normalized_task.linux_alias.is_some());
2034 8
    assert!(normalized_task.windows_alias.is_some());
2035 8
    assert!(normalized_task.mac_alias.is_some());
2036 8
    assert!(normalized_task.install_script.is_some());
2037 8
    assert!(normalized_task.args.is_some());
2038 8
    assert!(normalized_task.script.is_some());
2039 8
    assert!(normalized_task.script_runner.is_some());
2040 8
    assert!(normalized_task.script_runner_args.is_some());
2041 8
    assert!(normalized_task.script_extension.is_some());
2042 8
    assert!(normalized_task.run_task.is_some());
2043 8
    assert!(normalized_task.dependencies.is_some());
2044 8
    assert!(normalized_task.toolchain.is_some());
2045 8
    assert!(normalized_task.description.is_some());
2046 8
    assert!(normalized_task.category.is_some());
2047 8
    assert!(normalized_task.workspace.is_some());
2048 8
    assert!(normalized_task.linux.is_none());
2049 8
    assert!(normalized_task.windows.is_none());
2050 8
    assert!(normalized_task.mac.is_none());
2051

2052 8
    assert_eq!(get_script_vec(&normalized_task).len(), 2);
2053 8
    assert_eq!(
2054 8
        normalized_task.install_crate.unwrap(),
2055 8
        InstallCrate::Value("install_crate".to_string())
2056
    );
2057 8
    assert_eq!(normalized_task.command.unwrap(), "command");
2058 8
    assert_eq!(normalized_task.description.unwrap(), "description");
2059 8
    assert_eq!(normalized_task.category.unwrap(), "category");
2060 8
    assert!(!normalized_task.workspace.unwrap());
2061 8
    assert!(!normalized_task.disabled.unwrap());
2062 8
    assert!(normalized_task.private.unwrap());
2063 8
    assert_eq!(normalized_task.extend.unwrap(), "base");
2064 8
    assert_eq!(
2065 8
        normalized_task.watch.unwrap(),
2066
        TaskWatchOptions::Boolean(true)
2067
    );
2068 8
    assert!(!normalized_task.ignore_errors.unwrap_or(false));
2069 8
    assert!(!normalized_task.force.unwrap_or(false));
2070 8
    assert_eq!(normalized_task.alias.unwrap(), "alias");
2071 8
    assert_eq!(normalized_task.linux_alias.unwrap(), "linux");
2072 8
    assert_eq!(normalized_task.windows_alias.unwrap(), "windows");
2073 8
    assert_eq!(normalized_task.mac_alias.unwrap(), "mac");
2074 8
    assert_eq!(normalized_task.install_script.unwrap().len(), 3);
2075 8
    assert_eq!(normalized_task.args.unwrap().len(), 2);
2076 8
    assert_eq!(normalized_task.script_runner.unwrap(), "sh1");
2077 8
    assert_eq!(normalized_task.script_runner_args.unwrap().len(), 2);
2078 8
    assert_eq!(normalized_task.script_extension.unwrap(), "ext1");
2079 8
    let run_task_name = match normalized_task.run_task.unwrap() {
2080 8
        RunTaskInfo::Name(name) => name,
2081 0
        _ => panic!("Invalid run task value."),
2082 8
    };
2083 8
    assert_eq!(run_task_name, "task1".to_string());
2084 8
    assert_eq!(normalized_task.dependencies.unwrap().len(), 1);
2085 8
    assert_eq!(normalized_task.toolchain.unwrap(), "toolchain2");
2086 8
}
2087

2088
#[test]
2089
#[cfg(target_os = "linux")]
2090 8
fn task_get_normalized_task_with_override_no_clear() {
2091 8
    let mut env = IndexMap::new();
2092 8
    env.insert("test".to_string(), EnvValue::Value("value".to_string()));
2093

2094 8
    let mut task = Task {
2095 8
        clear: Some(true),
2096 8
        alias: Some("bad".to_string()),
2097 8
        linux_alias: Some("bad".to_string()),
2098 8
        windows_alias: Some("bad".to_string()),
2099 8
        mac_alias: Some("bad".to_string()),
2100 8
        install_crate: Some(InstallCrate::Value("install_crate".to_string())),
2101 8
        install_crate_args: Some(vec!["c1".to_string(), "c2".to_string()]),
2102 8
        command: Some("command".to_string()),
2103 8
        description: Some("description".to_string()),
2104 8
        category: Some("category".to_string()),
2105 8
        workspace: Some(true),
2106 8
        disabled: Some(false),
2107 8
        private: Some(true),
2108 8
        deprecated: None,
2109 8
        extend: Some("base".to_string()),
2110 8
        watch: Some(TaskWatchOptions::Boolean(true)),
2111 8
        condition: Some(TaskCondition {
2112 8
            fail_message: None,
2113 8
            profiles: Some(vec!["development".to_string()]),
2114 8
            platforms: Some(vec!["linux".to_string(), "mac".to_string()]),
2115 8
            channels: Some(vec!["nightly".to_string(), "stable".to_string()]),
2116 8
            env_set: None,
2117 8
            env_not_set: None,
2118 8
            env_true: None,
2119 8
            env_false: None,
2120 8
            env: None,
2121 8
            env_contains: None,
2122 8
            rust_version: None,
2123 8
            files_exist: None,
2124 8
            files_not_exist: None,
2125 0
        }),
2126 8
        condition_script: Some(vec!["exit 0".to_string()]),
2127 8
        ignore_errors: Some(false),
2128 8
        force: Some(false),
2129 8
        env_files: Some(vec![]),
2130 8
        env: Some(IndexMap::new()),
2131 8
        cwd: Some("cwd".to_string()),
2132 8
        install_script: Some(vec!["A".to_string(), "B".to_string(), "C".to_string()]),
2133 8
        args: Some(vec!["1".to_string(), "2".to_string()]),
2134 8
        script: Some(ScriptValue::Text(vec!["a".to_string(), "b".to_string()])),
2135 8
        script_runner: Some("sh1".to_string()),
2136 8
        script_runner_args: Some(vec!["sr_a1".to_string(), "sr_a2".to_string()]),
2137 8
        script_extension: Some("ext1".to_string()),
2138 8
        run_task: Some(RunTaskInfo::Name("task1".to_string())),
2139 8
        dependencies: Some(vec!["1".to_string()]),
2140 8
        toolchain: Some("toolchain1".to_string()),
2141 8
        linux: Some(PlatformOverrideTask {
2142 8
            clear: None,
2143 8
            install_crate: Some(InstallCrate::Value("linux_crate".to_string())),
2144 8
            install_crate_args: Some(vec!["c1".to_string(), "c2".to_string(), "c3".to_string()]),
2145 8
            command: Some("linux_command".to_string()),
2146 8
            disabled: Some(true),
2147 8
            private: Some(false),
2148 8
            deprecated: Some(DeprecationInfo::Boolean(true)),
2149 8
            extend: Some("linux".to_string()),
2150 8
            watch: Some(TaskWatchOptions::Boolean(false)),
2151 8
            condition: Some(TaskCondition {
2152 8
                fail_message: None,
2153 8
                profiles: Some(vec!["development".to_string()]),
2154 8
                platforms: Some(vec!["linux".to_string(), "mac".to_string()]),
2155 8
                channels: Some(vec!["nightly".to_string(), "stable".to_string()]),
2156 8
                env_set: None,
2157 8
                env_not_set: None,
2158 8
                env_true: None,
2159 8
                env_false: None,
2160 8
                env: None,
2161 8
                env_contains: None,
2162 8
                rust_version: None,
2163 8
                files_exist: None,
2164 8
                files_not_exist: None,
2165 0
            }),
2166 8
            condition_script: Some(vec!["exit 0".to_string()]),
2167 8
            ignore_errors: Some(true),
2168 8
            force: Some(true),
2169 8
            env_files: Some(vec![EnvFile::Path("extended".to_string())]),
2170 8
            env: Some(env),
2171 8
            cwd: Some("cwd2".to_string()),
2172 8
            install_script: Some(vec![
2173 8
                "A".to_string(),
2174 8
                "B".to_string(),
2175 8
                "C".to_string(),
2176 8
                "D".to_string(),
2177
            ]),
2178 8
            args: Some(vec!["1".to_string(), "2".to_string(), "3".to_string()]),
2179 8
            script: Some(ScriptValue::Text(vec![
2180 8
                "a".to_string(),
2181 8
                "b".to_string(),
2182 8
                "c".to_string(),
2183
            ])),
2184 8
            script_runner: Some("sh2".to_string()),
2185 8
            script_runner_args: Some(vec![
2186 8
                "sr_a1".to_string(),
2187 8
                "sr_a2".to_string(),
2188 8
                "sr_a3".to_string(),
2189
            ]),
2190 8
            script_extension: Some("ext2".to_string()),
2191 8
            run_task: Some(RunTaskInfo::Name("task2".to_string())),
2192 8
            dependencies: Some(vec!["1".to_string(), "2".to_string()]),
2193 8
            toolchain: Some("toolchain2".to_string()),
2194 0
        }),
2195 8
        windows: None,
2196 8
        mac: None,
2197 0
    };
2198

2199 8
    let normalized_task = task.get_normalized_task();
2200

2201 8
    assert!(normalized_task.clear.unwrap());
2202 8
    assert!(normalized_task.install_crate.is_some());
2203 8
    assert!(normalized_task.install_crate_args.is_some());
2204 8
    assert!(normalized_task.command.is_some());
2205 8
    assert!(normalized_task.description.is_some());
2206 8
    assert!(normalized_task.category.is_some());
2207 8
    assert!(normalized_task.workspace.is_some());
2208 8
    assert!(normalized_task.disabled.is_some());
2209 8
    assert!(normalized_task.private.is_some());
2210 8
    assert!(normalized_task.deprecated.is_some());
2211 8
    assert!(normalized_task.extend.is_some());
2212 8
    assert!(normalized_task.watch.is_some());
2213 8
    assert!(normalized_task.condition.is_some());
2214 8
    assert!(normalized_task.condition_script.is_some());
2215 8
    assert!(normalized_task.ignore_errors.is_some());
2216 8
    assert!(normalized_task.force.is_some());
2217 8
    assert!(normalized_task.env_files.is_some());
2218 8
    assert!(normalized_task.env.is_some());
2219 8
    assert!(normalized_task.cwd.is_some());
2220 8
    assert!(normalized_task.alias.is_none());
2221 8
    assert!(normalized_task.linux_alias.is_none());
2222 8
    assert!(normalized_task.windows_alias.is_none());
2223 8
    assert!(normalized_task.mac_alias.is_none());
2224 8
    assert!(normalized_task.install_script.is_some());
2225 8
    assert!(normalized_task.args.is_some());
2226 8
    assert!(normalized_task.script.is_some());
2227 8
    assert!(normalized_task.script_runner.is_some());
2228 8
    assert!(normalized_task.scri