sagiegurari / cargo-make
1
use super::*;
2
use crate::types::{
3
    Config, ConfigSection, CrateInfo, EnvInfo, FlowInfo, RustVersionCondition, Step, Task,
4
    TaskCondition,
5
};
6
use ci_info;
7
use git_info::types::GitInfo;
8
use indexmap::IndexMap;
9
use rust_info::types::{RustChannel, RustInfo};
10

11
#[test]
12 8
fn validate_env_set_empty() {
13 8
    let condition = TaskCondition {
14 8
        fail_message: None,
15 8
        profiles: None,
16 8
        platforms: None,
17 8
        channels: None,
18 8
        env_set: None,
19 8
        env_not_set: None,
20 8
        env_true: None,
21 8
        env_false: None,
22 8
        env: None,
23 8
        env_contains: None,
24 8
        rust_version: None,
25 8
        files_exist: None,
26 8
        files_not_exist: None,
27
    };
28

29 8
    let enabled = validate_env_set(&condition);
30

31 8
    assert!(enabled);
32 8
}
33

34
#[test]
35
#[ignore]
36 2
fn validate_env_set_valid() {
37 2
    envmnt::set("ENV_SET1", "");
38 2
    envmnt::set("ENV_SET2", "value");
39

40 2
    let condition = TaskCondition {
41 2
        fail_message: None,
42 2
        profiles: None,
43 2
        platforms: None,
44 2
        channels: None,
45 2
        env_set: Some(vec!["ENV_SET1".to_string(), "ENV_SET2".to_string()]),
46 2
        env_not_set: None,
47 2
        env_true: None,
48 2
        env_false: None,
49 2
        env: None,
50 2
        env_contains: None,
51 2
        rust_version: None,
52 2
        files_exist: None,
53 2
        files_not_exist: None,
54 0
    };
55

56 2
    let enabled = validate_env_set(&condition);
57

58 2
    assert!(enabled);
59 2
}
60

61
#[test]
62 8
fn validate_env_set_invalid() {
63 8
    let condition = TaskCondition {
64 8
        fail_message: None,
65 8
        profiles: None,
66 8
        platforms: None,
67 8
        channels: None,
68 8
        env_set: Some(vec!["BAD_ENV_SET1".to_string(), "BAD_ENV_SET2".to_string()]),
69 8
        env_not_set: None,
70 8
        env_true: None,
71 8
        env_false: None,
72 8
        env: None,
73 8
        env_contains: None,
74 8
        rust_version: None,
75 8
        files_exist: None,
76 8
        files_not_exist: None,
77 0
    };
78

79 8
    let enabled = validate_env_set(&condition);
80

81 8
    assert!(!enabled);
82 8
}
83

84
#[test]
85
#[ignore]
86 2
fn validate_env_set_invalid_partial_found() {
87 2
    envmnt::set("ENV_SET1", "");
88 2
    envmnt::set("ENV_SET2", "value");
89

90 2
    let condition = TaskCondition {
91 2
        fail_message: None,
92 2
        profiles: None,
93 2
        platforms: None,
94 2
        channels: None,
95 2
        env_set: Some(vec![
96 2
            "ENV_SET1".to_string(),
97 2
            "ENV_SET2".to_string(),
98 2
            "BAD_ENV_SET1".to_string(),
99
        ]),
100 2
        env_not_set: None,
101 2
        env_true: None,
102 2
        env_false: None,
103 2
        env: None,
104 2
        env_contains: None,
105 2
        rust_version: None,
106 2
        files_exist: None,
107 2
        files_not_exist: None,
108 0
    };
109

110 2
    let enabled = validate_env_set(&condition);
111

112 2
    assert!(!enabled);
113 2
}
114

115
#[test]
116 8
fn validate_env_not_set_empty() {
117 8
    let condition = TaskCondition {
118 8
        fail_message: None,
119 8
        profiles: None,
120 8
        platforms: None,
121 8
        channels: None,
122 8
        env_set: None,
123 8
        env_not_set: None,
124 8
        env_true: None,
125 8
        env_false: None,
126 8
        env: None,
127 8
        env_contains: None,
128 8
        rust_version: None,
129 8
        files_exist: None,
130 8
        files_not_exist: None,
131
    };
132

133 8
    let enabled = validate_env_not_set(&condition);
134

135 8
    assert!(enabled);
136 8
}
137

138
#[test]
139
#[ignore]
140 2
fn validate_env_not_set_valid() {
141 2
    let condition = TaskCondition {
142 2
        fail_message: None,
143 2
        profiles: None,
144 2
        platforms: None,
145 2
        channels: None,
146 2
        env_set: None,
147 2
        env_not_set: Some(vec!["BAD_ENV_SET1".to_string(), "BAD_ENV_SET2".to_string()]),
148 2
        env_true: None,
149 2
        env_false: None,
150 2
        env: None,
151 2
        env_contains: None,
152 2
        rust_version: None,
153 2
        files_exist: None,
154 2
        files_not_exist: None,
155 0
    };
156

157 2
    let enabled = validate_env_not_set(&condition);
158

159 2
    assert!(enabled);
160 2
}
161

162
#[test]
163
#[ignore]
164 2
fn validate_env_not_set_invalid() {
165 2
    envmnt::set("ENV_SET1", "");
166 2
    envmnt::set("ENV_SET2", "value");
167

168 2
    let condition = TaskCondition {
169 2
        fail_message: None,
170 2
        profiles: None,
171 2
        platforms: None,
172 2
        channels: None,
173 2
        env_set: None,
174 2
        env_not_set: Some(vec!["ENV_SET1".to_string(), "ENV_SET2".to_string()]),
175 2
        env_true: None,
176 2
        env_false: None,
177 2
        env: None,
178 2
        env_contains: None,
179 2
        rust_version: None,
180 2
        files_exist: None,
181 2
        files_not_exist: None,
182 0
    };
183

184 2
    let enabled = validate_env_not_set(&condition);
185

186 2
    assert!(!enabled);
187 2
}
188

189
#[test]
190
#[ignore]
191 2
fn validate_env_not_set_invalid_partial_found() {
192 2
    envmnt::set("ENV_SET1", "");
193 2
    envmnt::set("ENV_SET2", "value");
194

195 2
    let condition = TaskCondition {
196 2
        fail_message: None,
197 2
        profiles: None,
198 2
        platforms: None,
199 2
        channels: None,
200 2
        env_set: None,
201 2
        env_not_set: Some(vec![
202 2
            "ENV_SET1".to_string(),
203 2
            "ENV_SET2".to_string(),
204 2
            "BAD_ENV_SET1".to_string(),
205
        ]),
206 2
        env_true: None,
207 2
        env_false: None,
208 2
        env: None,
209 2
        env_contains: None,
210 2
        rust_version: None,
211 2
        files_exist: None,
212 2
        files_not_exist: None,
213 0
    };
214

215 2
    let enabled = validate_env_not_set(&condition);
216

217 2
    assert!(!enabled);
218 2
}
219

220
#[test]
221 8
fn validate_env_bool_true_empty() {
222 8
    let condition = TaskCondition {
223 8
        fail_message: None,
224 8
        profiles: None,
225 8
        platforms: None,
226 8
        channels: None,
227 8
        env_set: None,
228 8
        env_not_set: None,
229 8
        env_true: None,
230 8
        env_false: None,
231 8
        env: None,
232 8
        env_contains: None,
233 8
        rust_version: None,
234 8
        files_exist: None,
235 8
        files_not_exist: None,
236
    };
237

238 8
    let enabled = validate_env_bool(&condition, true);
239

240 8
    assert!(enabled);
241 8
}
242

243
#[test]
244
#[ignore]
245 2
fn validate_env_bool_true_valid() {
246 2
    envmnt::set_bool("ENV_TRUE1", true);
247 2
    envmnt::set_bool("ENV_TRUE2", true);
248

249 2
    let condition = TaskCondition {
250 2
        fail_message: None,
251 2
        profiles: None,
252 2
        platforms: None,
253 2
        channels: None,
254 2
        env_set: None,
255 2
        env_not_set: None,
256 2
        env_true: Some(vec!["ENV_TRUE1".to_string(), "ENV_TRUE2".to_string()]),
257 2
        env_false: None,
258 2
        env: None,
259 2
        env_contains: None,
260 2
        rust_version: None,
261 2
        files_exist: None,
262 2
        files_not_exist: None,
263 0
    };
264

265 2
    let enabled = validate_env_bool(&condition, true);
266

267 2
    assert!(enabled);
268 2
}
269

270
#[test]
271
#[ignore]
272 2
fn validate_env_bool_true_invalid() {
273 2
    envmnt::set_bool("ENV_TRUE1", false);
274 2
    envmnt::set_bool("ENV_TRUE2", false);
275

276 2
    let condition = TaskCondition {
277 2
        fail_message: None,
278 2
        profiles: None,
279 2
        platforms: None,
280 2
        channels: None,
281 2
        env_set: None,
282 2
        env_not_set: None,
283 2
        env_true: Some(vec!["ENV_TRUE1".to_string(), "ENV_TRUE2".to_string()]),
284 2
        env_false: None,
285 2
        env: None,
286 2
        env_contains: None,
287 2
        rust_version: None,
288 2
        files_exist: None,
289 2
        files_not_exist: None,
290 0
    };
291

292 2
    let enabled = validate_env_bool(&condition, true);
293

294 2
    assert!(!enabled);
295 2
}
296

297
#[test]
298
#[ignore]
299 2
fn validate_env_bool_true_invalid_partial_found() {
300 2
    envmnt::remove("ENV_TRUE1");
301 2
    envmnt::set_bool("ENV_TRUE2", true);
302

303 2
    let condition = TaskCondition {
304 2
        fail_message: None,
305 2
        profiles: None,
306 2
        platforms: None,
307 2
        channels: None,
308 2
        env_set: None,
309 2
        env_not_set: None,
310 2
        env_true: Some(vec!["ENV_TRUE1".to_string(), "ENV_TRUE2".to_string()]),
311 2
        env_false: None,
312 2
        env: None,
313 2
        env_contains: None,
314 2
        rust_version: None,
315 2
        files_exist: None,
316 2
        files_not_exist: None,
317 0
    };
318

319 2
    let enabled = validate_env_bool(&condition, true);
320

321 2
    assert!(!enabled);
322 2
}
323

324
#[test]
325
#[ignore]
326 2
fn validate_env_bool_true_invalid_partial_valid() {
327 2
    envmnt::set_bool("ENV_TRUE2", true);
328 2
    envmnt::set_bool("ENV_TRUE2", false);
329

330 2
    let condition = TaskCondition {
331 2
        fail_message: None,
332 2
        profiles: None,
333 2
        platforms: None,
334 2
        channels: None,
335 2
        env_set: None,
336 2
        env_not_set: None,
337 2
        env_true: Some(vec!["ENV_TRUE1".to_string(), "ENV_TRUE2".to_string()]),
338 2
        env_false: None,
339 2
        env: None,
340 2
        env_contains: None,
341 2
        rust_version: None,
342 2
        files_exist: None,
343 2
        files_not_exist: None,
344 0
    };
345

346 2
    let enabled = validate_env_bool(&condition, true);
347

348 2
    assert!(!enabled);
349 2
}
350

351
#[test]
352 8
fn validate_env_bool_false_empty() {
353 8
    let condition = TaskCondition {
354 8
        fail_message: None,
355 8
        profiles: None,
356 8
        platforms: None,
357 8
        channels: None,
358 8
        env_set: None,
359 8
        env_not_set: None,
360 8
        env_true: None,
361 8
        env_false: None,
362 8
        env: None,
363 8
        env_contains: None,
364 8
        rust_version: None,
365 8
        files_exist: None,
366 8
        files_not_exist: None,
367
    };
368

369 8
    let enabled = validate_env_bool(&condition, false);
370

371 8
    assert!(enabled);
372 8
}
373

374
#[test]
375
#[ignore]
376 2
fn validate_env_bool_false_valid() {
377 2
    envmnt::set_bool("ENV_FALSE1", false);
378 2
    envmnt::set_bool("ENV_FALSE2", false);
379

380 2
    let condition = TaskCondition {
381 2
        fail_message: None,
382 2
        profiles: None,
383 2
        platforms: None,
384 2
        channels: None,
385 2
        env_set: None,
386 2
        env_not_set: None,
387 2
        env_true: None,
388 2
        env_false: Some(vec!["ENV_FALSE1".to_string(), "ENV_FALSE2".to_string()]),
389 2
        env: None,
390 2
        env_contains: None,
391 2
        rust_version: None,
392 2
        files_exist: None,
393 2
        files_not_exist: None,
394 0
    };
395

396 2
    let enabled = validate_env_bool(&condition, false);
397

398 2
    assert!(enabled);
399 2
}
400

401
#[test]
402
#[ignore]
403 2
fn validate_env_bool_false_invalid() {
404 2
    envmnt::set_bool("ENV_FALSE1", true);
405 2
    envmnt::set_bool("ENV_FALSE2", true);
406

407 2
    let condition = TaskCondition {
408 2
        fail_message: None,
409 2
        profiles: None,
410 2
        platforms: None,
411 2
        channels: None,
412 2
        env_set: None,
413 2
        env_not_set: None,
414 2
        env_true: None,
415 2
        env_false: Some(vec!["ENV_FALSE1".to_string(), "ENV_FALSE2".to_string()]),
416 2
        env: None,
417 2
        env_contains: None,
418 2
        rust_version: None,
419 2
        files_exist: None,
420 2
        files_not_exist: None,
421 0
    };
422

423 2
    let enabled = validate_env_bool(&condition, false);
424

425 2
    assert!(!enabled);
426 2
}
427

428
#[test]
429
#[ignore]
430 2
fn validate_env_bool_false_invalid_partial_found() {
431 2
    envmnt::remove("ENV_FALSE1");
432 2
    envmnt::set_bool("ENV_FALSE2", false);
433

434 2
    let condition = TaskCondition {
435 2
        fail_message: None,
436 2
        profiles: None,
437 2
        platforms: None,
438 2
        channels: None,
439 2
        env_set: None,
440 2
        env_not_set: None,
441 2
        env_true: None,
442 2
        env_false: Some(vec!["ENV_FALSE1".to_string(), "ENV_FALSE2".to_string()]),
443 2
        env: None,
444 2
        env_contains: None,
445 2
        rust_version: None,
446 2
        files_exist: None,
447 2
        files_not_exist: None,
448 0
    };
449

450 2
    let enabled = validate_env_bool(&condition, false);
451

452 2
    assert!(!enabled);
453 2
}
454

455
#[test]
456
#[ignore]
457 2
fn validate_env_bool_false_invalid_partial_valid() {
458 2
    envmnt::set_bool("ENV_FALSE2", false);
459 2
    envmnt::set_bool("ENV_FALSE2", true);
460

461 2
    let condition = TaskCondition {
462 2
        fail_message: None,
463 2
        profiles: None,
464 2
        platforms: None,
465 2
        channels: None,
466 2
        env_set: None,
467 2
        env_not_set: None,
468 2
        env_true: None,
469 2
        env_false: Some(vec!["ENV_FALSE1".to_string(), "ENV_FALSE2".to_string()]),
470 2
        env: None,
471 2
        env_contains: None,
472 2
        rust_version: None,
473 2
        files_exist: None,
474 2
        files_not_exist: None,
475 0
    };
476

477 2
    let enabled = validate_env_bool(&condition, false);
478

479 2
    assert!(!enabled);
480 2
}
481

482
#[test]
483 8
fn validate_env_empty() {
484 8
    let condition = TaskCondition {
485 8
        fail_message: None,
486 8
        profiles: None,
487 8
        platforms: None,
488 8
        channels: None,
489 8
        env_set: None,
490 8
        env_not_set: None,
491 8
        env_true: None,
492 8
        env_false: None,
493 8
        env: None,
494 8
        env_contains: None,
495 8
        rust_version: None,
496 8
        files_exist: None,
497 8
        files_not_exist: None,
498
    };
499

500 8
    let enabled = validate_env(&condition);
501

502 8
    assert!(enabled);
503 8
}
504

505
#[test]
506
#[ignore]
507 2
fn validate_env_valid() {
508 2
    envmnt::set("ENV_SET1", "");
509 2
    envmnt::set("ENV_SET2", "value");
510

511 2
    let mut env_values = IndexMap::<String, String>::new();
512 2
    env_values.insert("ENV_SET1".to_string(), "".to_string());
513 2
    env_values.insert("ENV_SET2".to_string(), "value".to_string());
514

515 2
    let condition = TaskCondition {
516 2
        fail_message: None,
517 2
        profiles: None,
518 2
        platforms: None,
519 2
        channels: None,
520 2
        env_set: None,
521 2
        env_not_set: None,
522 2
        env_true: None,
523 2
        env_false: None,
524 2
        env: Some(env_values),
525 2
        env_contains: None,
526 2
        rust_version: None,
527 2
        files_exist: None,
528 2
        files_not_exist: None,
529
    };
530

531 2
    let enabled = validate_env(&condition);
532

533 2
    assert!(enabled);
534 2
}
535

536
#[test]
537
#[ignore]
538 2
fn validate_env_invalid_not_found() {
539 2
    let mut env_values = IndexMap::<String, String>::new();
540 2
    env_values.insert("BAD_ENV_SET1".to_string(), "".to_string());
541 2
    env_values.insert("BAD_ENV_SET2".to_string(), "value".to_string());
542

543 2
    let condition = TaskCondition {
544 2
        fail_message: None,
545 2
        profiles: None,
546 2
        platforms: None,
547 2
        channels: None,
548 2
        env_set: None,
549 2
        env_not_set: None,
550 2
        env_true: None,
551 2
        env_false: None,
552 2
        env: Some(env_values),
553 2
        env_contains: None,
554 2
        rust_version: None,
555 2
        files_exist: None,
556 2
        files_not_exist: None,
557
    };
558

559 2
    let enabled = validate_env(&condition);
560

561 2
    assert!(!enabled);
562 2
}
563

564
#[test]
565
#[ignore]
566 2
fn validate_env_invalid_not_equal() {
567 2
    envmnt::set("ENV_SET2", "value");
568

569 2
    let mut env_values = IndexMap::<String, String>::new();
570 2
    env_values.insert("ENV_SET2".to_string(), "value2".to_string());
571

572 2
    let condition = TaskCondition {
573 2
        fail_message: None,
574 2
        profiles: None,
575 2
        platforms: None,
576 2
        channels: None,
577 2
        env_set: None,
578 2
        env_not_set: None,
579 2
        env_true: None,
580 2
        env_false: None,
581 2
        env: Some(env_values),
582 2
        env_contains: None,
583 2
        rust_version: None,
584 2
        files_exist: None,
585 2
        files_not_exist: None,
586
    };
587

588 2
    let enabled = validate_env(&condition);
589

590 2
    assert!(!enabled);
591 2
}
592

593
#[test]
594
#[ignore]
595 2
fn validate_env_invalid_partial_found() {
596 2
    envmnt::set("ENV_SET1", "good");
597 2
    envmnt::set("ENV_SET2", "good");
598

599 2
    let mut env_values = IndexMap::<String, String>::new();
600 2
    env_values.insert("ENV_SET1".to_string(), "good".to_string());
601 2
    env_values.insert("ENV_SET2".to_string(), "bad".to_string());
602

603 2
    let condition = TaskCondition {
604 2
        fail_message: None,
605 2
        profiles: None,
606 2
        platforms: None,
607 2
        channels: None,
608 2
        env_set: None,
609 2
        env_not_set: None,
610 2
        env_true: None,
611 2
        env_false: None,
612 2
        env: Some(env_values),
613 2
        env_contains: None,
614 2
        rust_version: None,
615 2
        files_exist: None,
616 2
        files_not_exist: None,
617
    };
618

619 2
    let enabled = validate_env(&condition);
620

621 2
    assert!(!enabled);
622 2
}
623

624
#[test]
625
#[ignore]
626 2
fn validate_env_contains_valid_same() {
627 2
    envmnt::set("ENV_SET1", "");
628 2
    envmnt::set("ENV_SET2", "value");
629

630 2
    let mut env_values = IndexMap::<String, String>::new();
631 2
    env_values.insert("ENV_SET1".to_string(), "".to_string());
632 2
    env_values.insert("ENV_SET2".to_string(), "value".to_string());
633

634 2
    let condition = TaskCondition {
635 2
        fail_message: None,
636 2
        profiles: None,
637 2
        platforms: None,
638 2
        channels: None,
639 2
        env_set: None,
640 2
        env_not_set: None,
641 2
        env_true: None,
642 2
        env_false: None,
643 2
        env: None,
644 2
        env_contains: Some(env_values),
645 2
        rust_version: None,
646 2
        files_exist: None,
647 2
        files_not_exist: None,
648
    };
649

650 2
    let enabled = validate_env_contains(&condition);
651

652 2
    assert!(enabled);
653 2
}
654

655
#[test]
656
#[ignore]
657 2
fn validate_env_contains_valid() {
658 2
    envmnt::set("ENV_SET1", "");
659 2
    envmnt::set("ENV_SET2", "value");
660

661 2
    let mut env_values = IndexMap::<String, String>::new();
662 2
    env_values.insert("ENV_SET1".to_string(), "".to_string());
663 2
    env_values.insert("ENV_SET2".to_string(), "val".to_string());
664

665 2
    let condition = TaskCondition {
666 2
        fail_message: None,
667 2
        profiles: None,
668 2
        platforms: None,
669 2
        channels: None,
670 2
        env_set: None,
671 2
        env_not_set: None,
672 2
        env_true: None,
673 2
        env_false: None,
674 2
        env: None,
675 2
        env_contains: Some(env_values),
676 2
        rust_version: None,
677 2
        files_exist: None,
678 2
        files_not_exist: None,
679
    };
680

681 2
    let enabled = validate_env_contains(&condition);
682

683 2
    assert!(enabled);
684 2
}
685

686
#[test]
687
#[ignore]
688 2
fn validate_env_contains_invalid_not_found() {
689 2
    let mut env_values = IndexMap::<String, String>::new();
690 2
    env_values.insert("BAD_ENV_SET1".to_string(), "".to_string());
691 2
    env_values.insert("BAD_ENV_SET2".to_string(), "value".to_string());
692

693 2
    let condition = TaskCondition {
694 2
        fail_message: None,
695 2
        profiles: None,
696 2
        platforms: None,
697 2
        channels: None,
698 2
        env_set: None,
699 2
        env_not_set: None,
700 2
        env_true: None,
701 2
        env_false: None,
702 2
        env: None,
703 2
        env_contains: Some(env_values),
704 2
        rust_version: None,
705 2
        files_exist: None,
706 2
        files_not_exist: None,
707
    };
708

709 2
    let enabled = validate_env_contains(&condition);
710

711 2
    assert!(!enabled);
712 2
}
713

714
#[test]
715
#[ignore]
716 2
fn validate_env_contains_invalid_not_equal() {
717 2
    envmnt::set("ENV_SET2", "value");
718

719 2
    let mut env_values = IndexMap::<String, String>::new();
720 2
    env_values.insert("ENV_SET2".to_string(), "value2".to_string());
721

722 2
    let condition = TaskCondition {
723 2
        fail_message: None,
724 2
        profiles: None,
725 2
        platforms: None,
726 2
        channels: None,
727 2
        env_set: None,
728 2
        env_not_set: None,
729 2
        env_true: None,
730 2
        env_false: None,
731 2
        env: None,
732 2
        env_contains: Some(env_values),
733 2
        rust_version: None,
734 2
        files_exist: None,
735 2
        files_not_exist: None,
736
    };
737

738 2
    let enabled = validate_env_contains(&condition);
739

740 2
    assert!(!enabled);
741 2
}
742

743
#[test]
744
#[ignore]
745 2
fn validate_env_contains_invalid_partial_found() {
746 2
    envmnt::set("ENV_SET1", "good");
747 2
    envmnt::set("ENV_SET2", "good");
748

749 2
    let mut env_values = IndexMap::<String, String>::new();
750 2
    env_values.insert("ENV_SET1".to_string(), "good".to_string());
751 2
    env_values.insert("ENV_SET2".to_string(), "bad".to_string());
752

753 2
    let condition = TaskCondition {
754 2
        fail_message: None,
755 2
        profiles: None,
756 2
        platforms: None,
757 2
        channels: None,
758 2
        env_set: None,
759 2
        env_not_set: None,
760 2
        env_true: None,
761 2
        env_false: None,
762 2
        env: None,
763 2
        env_contains: Some(env_values),
764 2
        rust_version: None,
765 2
        files_exist: None,
766 2
        files_not_exist: None,
767
    };
768

769 2
    let enabled = validate_env_contains(&condition);
770

771 2
    assert!(!enabled);
772 2
}
773

774
#[test]
775 8
fn validate_script_empty() {
776 8
    let enabled = validate_script(&None, None);
777

778 8
    assert!(enabled);
779 8
}
780

781
#[test]
782 8
fn validate_script_valid() {
783 8
    let enabled = validate_script(&Some(vec!["exit 0".to_string()]), None);
784

785 8
    assert!(enabled);
786 8
}
787

788
#[test]
789 8
fn validate_script_invalid() {
790 8
    let enabled = validate_script(&Some(vec!["exit 1".to_string()]), None);
791

792 8
    assert!(!enabled);
793 8
}
794

795
#[test]
796
#[ignore]
797 2
fn validate_profile_valid() {
798 2
    profile::set("my_profile");
799

800 2
    let condition = TaskCondition {
801 2
        fail_message: None,
802 2
        profiles: Some(vec![
803 2
            "bad1".to_string(),
804 2
            "my_profile".to_string(),
805 2
            "bad2".to_string(),
806
        ]),
807 2
        platforms: None,
808 2
        channels: None,
809 2
        env_set: None,
810 2
        env_not_set: None,
811 2
        env_true: None,
812 2
        env_false: None,
813 2
        env: None,
814 2
        env_contains: None,
815 2
        rust_version: None,
816 2
        files_exist: None,
817 2
        files_not_exist: None,
818 0
    };
819

820 2
    let enabled = validate_profile(&condition);
821

822 2
    assert!(enabled);
823 2
}
824

825
#[test]
826
#[ignore]
827 2
fn validate_profile_invalid() {
828 2
    profile::set("my_profile");
829

830 2
    let condition = TaskCondition {
831 2
        fail_message: None,
832 2
        profiles: Some(vec!["bad1".to_string(), "bad2".to_string()]),
833 2
        platforms: None,
834 2
        channels: None,
835 2
        env_set: None,
836 2
        env_not_set: None,
837 2
        env_true: None,
838 2
        env_false: None,
839 2
        env: None,
840 2
        env_contains: None,
841 2
        rust_version: None,
842 2
        files_exist: None,
843 2
        files_not_exist: None,
844 0
    };
845

846 2
    let enabled = validate_profile(&condition);
847

848 2
    assert!(!enabled);
849 2
}
850

851
#[test]
852 8
fn validate_platform_valid() {
853 8
    let condition = TaskCondition {
854 8
        fail_message: None,
855 8
        profiles: None,
856 8
        platforms: Some(vec![
857 8
            "bad1".to_string(),
858 8
            types::get_platform_name(),
859 8
            "bad2".to_string(),
860
        ]),
861 8
        channels: None,
862 8
        env_set: None,
863 8
        env_not_set: None,
864 8
        env_true: None,
865 8
        env_false: None,
866 8
        env: None,
867 8
        env_contains: None,
868 8
        rust_version: None,
869 8
        files_exist: None,
870 8
        files_not_exist: None,
871 0
    };
872

873 8
    let enabled = validate_platform(&condition);
874

875 8
    assert!(enabled);
876 8
}
877

878
#[test]
879 8
fn validate_platform_invalid() {
880 8
    let condition = TaskCondition {
881 8
        fail_message: None,
882 8
        profiles: None,
883 8
        platforms: Some(vec!["bad1".to_string(), "bad2".to_string()]),
884 8
        channels: None,
885 8
        env_set: None,
886 8
        env_not_set: None,
887 8
        env_true: None,
888 8
        env_false: None,
889 8
        env: None,
890 8
        env_contains: None,
891 8
        rust_version: None,
892 8
        files_exist: None,
893 8
        files_not_exist: None,
894 0
    };
895

896 8
    let enabled = validate_platform(&condition);
897

898 8
    assert!(!enabled);
899 8
}
900

901
#[test]
902 8
fn validate_channel_valid() {
903 8
    let config = Config {
904 8
        config: ConfigSection::new(),
905 8
        env_files: vec![],
906 8
        env: IndexMap::new(),
907 8
        env_scripts: vec![],
908 8
        tasks: IndexMap::new(),
909 0
    };
910 8
    let mut flow_info = FlowInfo {
911 8
        config,
912 8
        task: "test".to_string(),
913 8
        env_info: EnvInfo {
914 8
            rust_info: RustInfo::new(),
915 8
            crate_info: CrateInfo::new(),
916 8
            git_info: GitInfo::new(),
917 8
            ci_info: ci_info::get(),
918 0
        },
919
        disable_workspace: false,
920
        disable_on_error: false,
921
        allow_private: false,
922
        skip_init_end_tasks: false,
923 8
        cli_arguments: None,
924 0
    };
925

926 8
    flow_info.env_info.rust_info.channel = Some(RustChannel::Stable);
927 8
    let mut condition = TaskCondition {
928 8
        fail_message: None,
929 8
        profiles: None,
930 8
        platforms: None,
931 8
        channels: Some(vec![
932 8
            "bad1".to_string(),
933 8
            "stable".to_string(),
934 8
            "bad2".to_string(),
935
        ]),
936 8
        env_set: None,
937 8
        env_not_set: None,
938 8
        env_true: None,
939 8
        env_false: None,
940 8
        env: None,
941 8
        env_contains: None,
942 8
        rust_version: None,
943 8
        files_exist: None,
944 8
        files_not_exist: None,
945 0
    };
946 8
    let mut enabled = validate_channel(&condition, Some(&flow_info));
947 8
    assert!(enabled);
948

949 8
    flow_info.env_info.rust_info.channel = Some(RustChannel::Beta);
950 8
    condition = TaskCondition {
951 8
        fail_message: None,
952 8
        profiles: None,
953 8
        platforms: None,
954 8
        channels: Some(vec![
955 8
            "bad1".to_string(),
956 8
            "beta".to_string(),
957 8
            "bad2".to_string(),
958
        ]),
959 8
        env_set: None,
960 8
        env_not_set: None,
961 8
        env_true: None,
962 8
        env_false: None,
963 8
        env: None,
964 8
        env_contains: None,
965 8
        rust_version: None,
966 8
        files_exist: None,
967 8
        files_not_exist: None,
968 0
    };
969 8
    enabled = validate_channel(&condition, Some(&flow_info));
970

971 8
    assert!(enabled);
972

973 8
    flow_info.env_info.rust_info.channel = Some(RustChannel::Nightly);
974 8
    condition = TaskCondition {
975 8
        fail_message: None,
976 8
        profiles: None,
977 8
        platforms: None,
978 8
        channels: Some(vec![
979 8
            "bad1".to_string(),
980 8
            "nightly".to_string(),
981 8
            "bad2".to_string(),
982
        ]),
983 8
        env_set: None,
984 8
        env_not_set: None,
985 8
        env_true: None,
986 8
        env_false: None,
987 8
        env: None,
988 8
        env_contains: None,
989 8
        rust_version: None,
990 8
        files_exist: None,
991 8
        files_not_exist: None,
992 0
    };
993 8
    enabled = validate_channel(&condition, Some(&flow_info));
994

995 8
    assert!(enabled);
996 8
}
997

998
#[test]
999 8
fn validate_channel_invalid() {
1000 8
    let config = Config {
1001 8
        config: ConfigSection::new(),
1002 8
        env_files: vec![],
1003 8
        env: IndexMap::new(),
1004 8
        env_scripts: vec![],
1005 8
        tasks: IndexMap::new(),
1006 0
    };
1007 8
    let mut flow_info = FlowInfo {
1008 8
        config,
1009 8
        task: "test".to_string(),
1010 8
        env_info: EnvInfo {
1011 8
            rust_info: RustInfo::new(),
1012 8
            crate_info: CrateInfo::new(),
1013 8
            git_info: GitInfo::new(),
1014 8
            ci_info: ci_info::get(),
1015 0
        },
1016
        disable_workspace: false,
1017
        disable_on_error: false,
1018
        allow_private: false,
1019
        skip_init_end_tasks: false,
1020 8
        cli_arguments: None,
1021 0
    };
1022

1023 8
    flow_info.env_info.rust_info.channel = Some(RustChannel::Stable);
1024 8
    let condition = TaskCondition {
1025 8
        fail_message: None,
1026 8
        profiles: None,
1027 8
        platforms: None,
1028 8
        channels: Some(vec!["bad1".to_string(), "bad2".to_string()]),
1029 8
        env_set: None,
1030 8
        env_not_set: None,
1031 8
        env_true: None,
1032 8
        env_false: None,
1033 8
        env: None,
1034 8
        env_contains: None,
1035 8
        rust_version: None,
1036 8
        files_exist: None,
1037 8
        files_not_exist: None,
1038 0
    };
1039 8
    let enabled = validate_channel(&condition, Some(&flow_info));
1040

1041 8
    assert!(!enabled);
1042 8
}
1043

1044
#[test]
1045 8
fn validate_file_exists_valid() {
1046 8
    let condition = TaskCondition {
1047 8
        fail_message: None,
1048 8
        profiles: None,
1049 8
        platforms: None,
1050 8
        channels: None,
1051 8
        env_set: None,
1052 8
        env_not_set: None,
1053 8
        env_true: None,
1054 8
        env_false: None,
1055 8
        env: None,
1056 8
        env_contains: None,
1057 8
        rust_version: None,
1058 8
        files_exist: Some(vec![
1059 8
            "${CARGO_MAKE_WORKING_DIRECTORY}/Cargo.toml".to_string()
1060
        ]),
1061 8
        files_not_exist: None,
1062 0
    };
1063

1064 8
    let enabled = validate_files_exist(&condition);
1065

1066 8
    assert!(enabled);
1067 8
}
1068

1069
#[test]
1070 8
fn validate_file_exists_partial_invalid() {
1071 8
    let condition = TaskCondition {
1072 8
        fail_message: None,
1073 8
        profiles: None,
1074 8
        platforms: None,
1075 8
        channels: None,
1076 8
        env_set: None,
1077 8
        env_not_set: None,
1078 8
        env_true: None,
1079 8
        env_false: None,
1080 8
        env: None,
1081 8
        env_contains: None,
1082 8
        rust_version: None,
1083 8
        files_exist: Some(vec![
1084 8
            "${CARGO_MAKE_WORKING_DIRECTORY}/Cargo.toml".to_string(),
1085 8
            "${CARGO_MAKE_WORKING_DIRECTORY}/Cargo2.toml".to_string(),
1086
        ]),
1087 8
        files_not_exist: None,
1088 0
    };
1089

1090 8
    let enabled = validate_files_exist(&condition);
1091

1092 8
    assert!(!enabled);
1093 8
}
1094

1095
#[test]
1096 8
fn validate_file_exists_invalid() {
1097 8
    let condition = TaskCondition {
1098 8
        fail_message: None,
1099 8
        profiles: None,
1100 8
        platforms: None,
1101 8
        channels: None,
1102 8
        env_set: None,
1103 8
        env_not_set: None,
1104 8
        env_true: None,
1105 8
        env_false: None,
1106 8
        env: None,
1107 8
        env_contains: None,
1108 8
        rust_version: None,
1109 8
        files_exist: Some(vec![
1110 8
            "${CARGO_MAKE_WORKING_DIRECTORY}/Cargo2.toml".to_string()
1111
        ]),
1112 8
        files_not_exist: None,
1113 0
    };
1114

1115 8
    let enabled = validate_files_exist(&condition);
1116

1117 8
    assert!(!enabled);
1118 8
}
1119

1120
#[test]
1121 8
fn validate_file_not_exists_valid() {
1122 8
    let condition = TaskCondition {
1123 8
        fail_message: None,
1124 8
        profiles: None,
1125 8
        platforms: None,
1126 8
        channels: None,
1127 8
        env_set: None,
1128 8
        env_not_set: None,
1129 8
        env_true: None,
1130 8
        env_false: None,
1131 8
        env: None,
1132 8
        env_contains: None,
1133 8
        rust_version: None,
1134 8
        files_exist: None,
1135 8
        files_not_exist: Some(vec![
1136 8
            "${CARGO_MAKE_WORKING_DIRECTORY}/Cargo2.toml".to_string()
1137
        ]),
1138 0
    };
1139

1140 8
    let enabled = validate_files_not_exist(&condition);
1141

1142 8
    assert!(enabled);
1143 8
}
1144

1145
#[test]
1146 8
fn validate_file_not_exists_partial_invalid() {
1147 8
    let condition = TaskCondition {
1148 8
        fail_message: None,
1149 8
        profiles: None,
1150 8
        platforms: None,
1151 8
        channels: None,
1152 8
        env_set: None,
1153 8
        env_not_set: None,
1154 8
        env_true: None,
1155 8
        env_false: None,
1156 8
        env: None,
1157 8
        env_contains: None,
1158 8
        rust_version: None,
1159 8
        files_exist: None,
1160 8
        files_not_exist: Some(vec![
1161 8
            "${CARGO_MAKE_WORKING_DIRECTORY}/Cargo.toml".to_string(),
1162 8
            "${CARGO_MAKE_WORKING_DIRECTORY}/Cargo2.toml".to_string(),
1163
        ]),
1164 0
    };
1165

1166 8
    let enabled = validate_files_not_exist(&condition);
1167

1168 8
    assert!(!enabled);
1169 8
}
1170

1171
#[test]
1172 8
fn validate_file_not_exists_invalid() {
1173 8
    let condition = TaskCondition {
1174 8
        fail_message: None,
1175 8
        profiles: None,
1176 8
        platforms: None,
1177 8
        channels: None,
1178 8
        env_set: None,
1179 8
        env_not_set: None,
1180 8
        env_true: None,
1181 8
        env_false: None,
1182 8
        env: None,
1183 8
        env_contains: None,
1184 8
        rust_version: None,
1185 8
        files_exist: None,
1186 8
        files_not_exist: Some(vec![
1187 8
            "${CARGO_MAKE_WORKING_DIRECTORY}/Cargo.toml".to_string()
1188
        ]),
1189 0
    };
1190

1191 8
    let enabled = validate_files_not_exist(&condition);
1192

1193 8
    assert!(!enabled);
1194 8
}
1195

1196
#[test]
1197 8
fn validate_criteria_empty() {
1198 8
    let config = Config {
1199 8
        config: ConfigSection::new(),
1200 8
        env_files: vec![],
1201 8
        env: IndexMap::new(),
1202 8
        env_scripts: vec![],
1203 8
        tasks: IndexMap::new(),
1204 0
    };
1205 8
    let flow_info = FlowInfo {
1206 8
        config,
1207 8
        task: "test".to_string(),
1208 8
        env_info: EnvInfo {
1209 8
            rust_info: RustInfo::new(),
1210 8
            crate_info: CrateInfo::new(),
1211 8
            git_info: GitInfo::new(),
1212 8
            ci_info: ci_info::get(),
1213 0
        },
1214
        disable_workspace: false,
1215
        disable_on_error: false,
1216
        allow_private: false,
1217
        skip_init_end_tasks: false,
1218 8
        cli_arguments: None,
1219 0
    };
1220

1221 8
    let enabled = validate_criteria(
1222 8
        Some(&flow_info),
1223 2
        &Some(TaskCondition {
1224
            fail_message: None,
1225
            profiles: None,
1226
            platforms: None,
1227
            channels: None,
1228
            env_set: None,
1229
            env_not_set: None,
1230
            env_true: None,
1231
            env_false: None,
1232
            env: None,
1233
            env_contains: None,
1234
            rust_version: None,
1235
            files_exist: None,
1236
            files_not_exist: None,
1237
        }),
1238
    );
1239

1240 8
    assert!(enabled);
1241 8
}
1242

1243
#[test]
1244 8
fn validate_criteria_valid_platform() {
1245 8
    let config = Config {
1246 8
        config: ConfigSection::new(),
1247 8
        env_files: vec![],
1248 8
        env: IndexMap::new(),
1249 8
        env_scripts: vec![],
1250 8
        tasks: IndexMap::new(),
1251 0
    };
1252 8
    let flow_info = FlowInfo {
1253 8
        config,
1254 8
        task: "test".to_string(),
1255 8
        env_info: EnvInfo {
1256 8
            rust_info: RustInfo::new(),
1257 8
            crate_info: CrateInfo::new(),
1258 8
            git_info: GitInfo::new(),
1259 8
            ci_info: ci_info::get(),
1260 0
        },
1261
        disable_workspace: false,
1262
        disable_on_error: false,
1263
        allow_private: false,
1264
        skip_init_end_tasks: false,
1265 8
        cli_arguments: None,
1266 0
    };
1267

1268 8
    let enabled = validate_criteria(
1269 8
        Some(&flow_info),
1270 8
        &Some(TaskCondition {
1271 8
            fail_message: None,
1272 8
            profiles: None,
1273 8
            platforms: Some(vec![
1274 8
                "bad1".to_string(),
1275 8
                types::get_platform_name(),
1276 8
                "bad2".to_string(),
1277
            ]),
1278 8
            channels: None,
1279 8
            env_set: None,
1280 8
            env_not_set: None,
1281 8
            env_true: None,
1282 8
            env_false: None,
1283 8
            env: None,
1284 8
            env_contains: None,
1285 8
            rust_version: None,
1286 8
            files_exist: None,
1287 8
            files_not_exist: None,
1288 0
        }),
1289 8
    );
1290

1291 8
    assert!(enabled);
1292 8
}
1293

1294
#[test]
1295 8
fn validate_criteria_invalid_platform() {
1296 8
    let config = Config {
1297 8
        config: ConfigSection::new(),
1298 8
        env_files: vec![],
1299 8
        env: IndexMap::new(),
1300 8
        env_scripts: vec![],
1301 8
        tasks: IndexMap::new(),
1302 0
    };
1303 8
    let flow_info = FlowInfo {
1304 8
        config,
1305 8
        task: "test".to_string(),
1306 8
        env_info: EnvInfo {
1307 8
            rust_info: RustInfo::new(),
1308 8
            crate_info: CrateInfo::new(),
1309 8
            git_info: GitInfo::new(),
1310 8
            ci_info: ci_info::get(),
1311 0
        },
1312
        disable_workspace: false,
1313
        disable_on_error: false,
1314
        allow_private: false,
1315
        skip_init_end_tasks: false,
1316 8
        cli_arguments: None,
1317 0
    };
1318

1319 8
    let enabled = validate_criteria(
1320 8
        Some(&flow_info),
1321 8
        &Some(TaskCondition {
1322 8
            fail_message: None,
1323 8
            profiles: None,
1324 8
            platforms: Some(vec!["bad1".to_string(), "bad2".to_string()]),
1325 8
            channels: None,
1326 8
            env_set: None,
1327 8
            env_not_set: None,
1328 8
            env_true: None,
1329 8
            env_false: None,
1330 8
            env: None,
1331 8
            env_contains: None,
1332 8
            rust_version: None,
1333 8
            files_exist: None,
1334 8
            files_not_exist: None,
1335 0
        }),
1336 8
    );
1337

1338 8
    assert!(!enabled);
1339 8
}
1340

1341
#[test]
1342
#[ignore]
1343 2
fn validate_criteria_valid_profile() {
1344 2
    let config = Config {
1345 2
        config: ConfigSection::new(),
1346 2
        env_files: vec![],
1347 2
        env: IndexMap::new(),
1348 2
        env_scripts: vec![],
1349 2
        tasks: IndexMap::new(),
1350 0
    };
1351 2
    let flow_info = FlowInfo {
1352 2
        config,
1353 2
        task: "test".to_string(),
1354 2
        env_info: EnvInfo {
1355 2
            rust_info: RustInfo::new(),
1356 2
            crate_info: CrateInfo::new(),
1357 2
            git_info: GitInfo::new(),
1358 2
            ci_info: ci_info::get(),
1359 0
        },
1360
        disable_workspace: false,
1361
        disable_on_error: false,
1362
        allow_private: false,
1363
        skip_init_end_tasks: false,
1364 2
        cli_arguments: None,
1365 0
    };
1366

1367 2
    let enabled = validate_criteria(
1368 2
        Some(&flow_info),
1369 2
        &Some(TaskCondition {
1370 2
            fail_message: None,
1371 2
            profiles: Some(vec!["bad1".to_string(), profile::get(), "bad2".to_string()]),
1372 2
            platforms: None,
1373 2
            channels: None,
1374 2
            env_set: None,
1375 2
            env_not_set: None,
1376 2
            env_true: None,
1377 2
            env_false: None,
1378 2
            env: None,
1379 2
            env_contains: None,
1380 2
            rust_version: None,
1381 2
            files_exist: None,
1382 2
            files_not_exist: None,
1383 0
        }),
1384 2
    );
1385

1386 2
    assert!(enabled);
1387 2
}
1388

1389
#[test]
1390
#[ignore]
1391 2
fn validate_criteria_invalid_profile() {
1392 2
    let config = Config {
1393 2
        config: ConfigSection::new(),
1394 2
        env_files: vec![],
1395 2
        env: IndexMap::new(),
1396 2
        env_scripts: vec![],
1397 2
        tasks: IndexMap::new(),
1398 0
    };
1399 2
    let flow_info = FlowInfo {
1400 2
        config,
1401 2
        task: "test".to_string(),
1402 2
        env_info: EnvInfo {
1403 2
            rust_info: RustInfo::new(),
1404 2
            crate_info: CrateInfo::new(),
1405 2
            git_info: GitInfo::new(),
1406 2
            ci_info: ci_info::get(),
1407 0
        },
1408
        disable_workspace: false,
1409
        disable_on_error: false,
1410
        allow_private: false,
1411
        skip_init_end_tasks: false,
1412 2
        cli_arguments: None,
1413 0
    };
1414

1415 2
    let enabled = validate_criteria(
1416 2
        Some(&flow_info),
1417 2
        &Some(TaskCondition {
1418 2
            fail_message: None,
1419 2
            profiles: Some(vec!["bad1".to_string(), "bad2".to_string()]),
1420 2
            platforms: None,
1421 2
            channels: None,
1422 2
            env_set: None,
1423 2
            env_not_set: None,
1424 2
            env_true: None,
1425 2
            env_false: None,
1426 2
            env: None,
1427 2
            env_contains: None,
1428 2
            rust_version: None,
1429 2
            files_exist: None,
1430 2
            files_not_exist: None,
1431 0
        }),
1432 2
    );
1433

1434 2
    assert!(!enabled);
1435 2
}
1436

1437
#[test]
1438 8
fn validate_criteria_valid_channel() {
1439 8
    let config = Config {
1440 8
        config: ConfigSection::new(),
1441 8
        env_files: vec![],
1442 8
        env: IndexMap::new(),
1443 8
        env_scripts: vec![],
1444 8
        tasks: IndexMap::new(),
1445 0
    };
1446 8
    let mut flow_info = FlowInfo {
1447 8
        config,
1448 8
        task: "test".to_string(),
1449 8
        env_info: EnvInfo {
1450 8
            rust_info: RustInfo::new(),
1451 8
            crate_info: CrateInfo::new(),
1452 8
            git_info: GitInfo::new(),
1453 8
            ci_info: ci_info::get(),
1454 0
        },
1455
        disable_workspace: false,
1456
        disable_on_error: false,
1457
        allow_private: false,
1458
        skip_init_end_tasks: false,
1459 8
        cli_arguments: None,
1460 0
    };
1461

1462 8
    flow_info.env_info.rust_info.channel = Some(RustChannel::Stable);
1463 8
    let mut enabled = validate_criteria(
1464 8
        Some(&flow_info),
1465 8
        &Some(TaskCondition {
1466 8
            fail_message: None,
1467 8
            profiles: None,
1468 8
            platforms: None,
1469 8
            channels: Some(vec![
1470 8
                "bad1".to_string(),
1471 8
                "stable".to_string(),
1472 8
                "bad2".to_string(),
1473
            ]),
1474 8
            env_set: None,
1475 8
            env_not_set: None,
1476 8
            env_true: None,
1477 8
            env_false: None,
1478 8
            env: None,
1479 8
            env_contains: None,
1480 8
            rust_version: None,
1481 8
            files_exist: None,
1482 8
            files_not_exist: None,
1483 0
        }),
1484 8
    );
1485

1486 8
    assert!(enabled);
1487

1488 8
    flow_info.env_info.rust_info.channel = Some(RustChannel::Beta);
1489 8
    enabled = validate_criteria(
1490 8
        Some(&flow_info),
1491 8
        &Some(TaskCondition {
1492 8
            fail_message: None,
1493 8
            profiles: None,
1494 8
            platforms: None,
1495 8
            channels: Some(vec![
1496 8
                "bad1".to_string(),
1497 8
                "beta".to_string(),
1498 8
                "bad2".to_string(),
1499
            ]),
1500 8
            env_set: None,
1501 8
            env_not_set: None,
1502 8
            env_true: None,
1503 8
            env_false: None,
1504 8
            env: None,
1505 8
            env_contains: None,
1506 8
            rust_version: None,
1507 8
            files_exist: None,
1508 8
            files_not_exist: None,
1509 0
        }),
1510 8
    );
1511

1512 8
    assert!(enabled);
1513

1514 8
    flow_info.env_info.rust_info.channel = Some(RustChannel::Nightly);
1515 8
    enabled = validate_criteria(
1516 8
        Some(&flow_info),
1517 8
        &Some(TaskCondition {
1518 8
            fail_message: None,
1519 8
            profiles: None,
1520 8
            platforms: None,
1521 8
            channels: Some(vec![
1522 8
                "bad1".to_string(),
1523 8
                "nightly".to_string(),
1524 8
                "bad2".to_string(),
1525
            ]),
1526 8
            env_set: None,
1527 8
            env_not_set: None,
1528 8
            env_true: None,
1529 8
            env_false: None,
1530 8
            env: None,
1531 8
            env_contains: None,
1532 8
            rust_version: None,
1533 8
            files_exist: None,
1534 8
            files_not_exist: None,
1535 0
        }),
1536 8
    );
1537

1538 8
    assert!(enabled);
1539 8
}
1540

1541
#[test]
1542 8
fn validate_criteria_invalid_channel() {
1543 8
    let config = Config {
1544 8
        config: ConfigSection::new(),
1545 8
        env_files: vec![],
1546 8
        env: IndexMap::new(),
1547 8
        env_scripts: vec![],
1548 8
        tasks: IndexMap::new(),
1549 0
    };
1550 8
    let mut flow_info = FlowInfo {
1551 8
        config,
1552 8
        task: "test".to_string(),
1553 8
        env_info: EnvInfo {
1554 8
            rust_info: RustInfo::new(),
1555 8
            crate_info: CrateInfo::new(),
1556 8
            git_info: GitInfo::new(),
1557 8
            ci_info: ci_info::get(),
1558 0
        },
1559
        disable_workspace: false,
1560
        disable_on_error: false,
1561
        allow_private: false,
1562
        skip_init_end_tasks: false,
1563 8
        cli_arguments: None,
1564 0
    };
1565

1566 8
    flow_info.env_info.rust_info.channel = Some(RustChannel::Stable);
1567 8
    let enabled = validate_criteria(
1568 8
        Some(&flow_info),
1569 8
        &Some(TaskCondition {
1570 8
            fail_message: None,
1571 8
            profiles: None,
1572 8
            platforms: None,
1573 8
            channels: Some(vec!["bad1".to_string(), "bad2".to_string()]),
1574 8
            env_set: None,
1575 8
            env_not_set: None,
1576 8
            env_true: None,
1577 8
            env_false: None,
1578 8
            env: None,
1579 8
            env_contains: None,
1580 8
            rust_version: None,
1581 8
            files_exist: None,
1582 8
            files_not_exist: None,
1583 0
        }),
1584 8
    );
1585

1586 8
    assert!(!enabled);
1587 8
}
1588

1589
#[test]
1590 8
fn validate_criteria_valid_file_exists() {
1591 8
    let config = Config {
1592 8
        config: ConfigSection::new(),
1593 8
        env_files: vec![],
1594 8
        env: IndexMap::new(),
1595 8
        env_scripts: vec![],
1596 8
        tasks: IndexMap::new(),
1597 0
    };
1598 8
    let flow_info = FlowInfo {
1599 8
        config,
1600 8
        task: "test".to_string(),
1601 8
        env_info: EnvInfo {
1602 8
            rust_info: RustInfo::new(),
1603 8
            crate_info: CrateInfo::new(),
1604 8
            git_info: GitInfo::new(),
1605 8
            ci_info: ci_info::get(),
1606 0
        },
1607
        disable_workspace: false,
1608
        disable_on_error: false,
1609
        allow_private: false,
1610
        skip_init_end_tasks: false,
1611 8
        cli_arguments: None,
1612 0
    };
1613

1614 8
    let enabled = validate_criteria(
1615 8
        Some(&flow_info),
1616 8
        &Some(TaskCondition {
1617 8
            fail_message: None,
1618 8
            profiles: None,
1619 8
            platforms: None,
1620 8
            channels: None,
1621 8
            env_set: None,
1622 8
            env_not_set: None,
1623 8
            env_true: None,
1624 8
            env_false: None,
1625 8
            env: None,
1626 8
            env_contains: None,
1627 8
            rust_version: None,
1628 8
            files_exist: Some(vec![
1629 8
                "${CARGO_MAKE_WORKING_DIRECTORY}/Cargo.toml".to_string()
1630
            ]),
1631 8
            files_not_exist: None,
1632 0
        }),
1633 8
    );
1634

1635 8
    assert!(enabled);
1636 8
}
1637

1638
#[test]
1639 8
fn validate_criteria_invalid_file_exists() {
1640 8
    let config = Config {
1641 8
        config: ConfigSection::new(),
1642 8
        env_files: vec![],
1643 8
        env: IndexMap::new(),
1644 8
        env_scripts: vec![],
1645 8
        tasks: IndexMap::new(),
1646 0
    };
1647 8
    let flow_info = FlowInfo {
1648 8
        config,
1649 8
        task: "test".to_string(),
1650 8
        env_info: EnvInfo {
1651 8
            rust_info: RustInfo::new(),
1652 8
            crate_info: CrateInfo::new(),
1653 8
            git_info: GitInfo::new(),
1654 8
            ci_info: ci_info::get(),
1655 0
        },
1656
        disable_workspace: false,
1657
        disable_on_error: false,
1658
        allow_private: false,
1659
        skip_init_end_tasks: false,
1660 8
        cli_arguments: None,
1661 0
    };
1662

1663 8
    let enabled = validate_criteria(
1664 8
        Some(&flow_info),
1665 8
        &Some(TaskCondition {
1666 8
            fail_message: None,
1667 8
            profiles: None,
1668 8
            platforms: None,
1669 8
            channels: None,
1670 8
            env_set: None,
1671 8
            env_not_set: None,
1672 8
            env_true: None,
1673 8
            env_false: None,
1674 8
            env: None,
1675 8
            env_contains: None,
1676 8
            rust_version: None,
1677 8
            files_exist: Some(vec![
1678 8
                "${CARGO_MAKE_WORKING_DIRECTORY}/Cargo2.toml".to_string()
1679
            ]),
1680 8
            files_not_exist: None,
1681 0
        }),
1682 8
    );
1683

1684 8
    assert!(!enabled);
1685 8
}
1686

1687
#[test]
1688 8
fn validate_criteria_valid_file_not_exists() {
1689 8
    let config = Config {
1690 8
        config: ConfigSection::new(),
1691 8
        env_files: vec![],
1692 8
        env: IndexMap::new(),
1693 8
        env_scripts: vec![],
1694 8
        tasks: IndexMap::new(),
1695 0
    };
1696 8
    let flow_info = FlowInfo {
1697 8
        config,
1698 8
        task: "test".to_string(),
1699 8
        env_info: EnvInfo {
1700 8
            rust_info: RustInfo::new(),
1701 8
            crate_info: CrateInfo::new(),
1702 8
            git_info: GitInfo::new(),
1703 8
            ci_info: ci_info::get(),
1704 0
        },
1705
        disable_workspace: false,
1706
        disable_on_error: false,
1707
        allow_private: false,
1708
        skip_init_end_tasks: false,
1709 8
        cli_arguments: None,
1710 0
    };
1711

1712 8
    let enabled = validate_criteria(
1713 8
        Some(&flow_info),
1714 8
        &Some(TaskCondition {
1715 8
            fail_message: None,
1716 8
            profiles: None,
1717 8
            platforms: None,
1718 8
            channels: None,
1719 8
            env_set: None,
1720 8
            env_not_set: None,
1721 8
            env_true: None,
1722 8
            env_false: None,
1723 8
            env: None,
1724 8
            env_contains: None,
1725 8
            rust_version: None,
1726 8
            files_exist: None,
1727 8
            files_not_exist: Some(vec![
1728 8
                "${CARGO_MAKE_WORKING_DIRECTORY}/Cargo2.toml".to_string()
1729
            ]),
1730 0
        }),
1731 8
    );
1732

1733 8
    assert!(enabled);
1734 8
}
1735

1736
#[test]
1737 8
fn validate_criteria_invalid_file_not_exists() {
1738 8
    let config = Config {
1739 8
        config: ConfigSection::new(),
1740 8
        env_files: vec![],
1741 8
        env: IndexMap::new(),
1742 8
        env_scripts: vec![],
1743 8
        tasks: IndexMap::new(),
1744 0
    };
1745 8
    let flow_info = FlowInfo {
1746 8
        config,
1747 8
        task: "test".to_string(),
1748 8
        env_info: EnvInfo {
1749 8
            rust_info: RustInfo::new(),
1750 8
            crate_info: CrateInfo::new(),
1751 8
            git_info: GitInfo::new(),
1752 8
            ci_info: ci_info::get(),
1753 0
        },
1754
        disable_workspace: false,
1755
        disable_on_error: false,
1756
        allow_private: false,
1757
        skip_init_end_tasks: false,
1758 8
        cli_arguments: None,
1759 0
    };
1760

1761 8
    let enabled = validate_criteria(
1762 8
        Some(&flow_info),
1763 8
        &Some(TaskCondition {
1764 8
            fail_message: None,
1765 8
            profiles: None,
1766 8
            platforms: None,
1767 8
            channels: None,
1768 8
            env_set: None,
1769 8
            env_not_set: None,
1770 8
            env_true: None,
1771 8
            env_false: None,
1772 8
            env: None,
1773 8
            env_contains: None,
1774 8
            rust_version: None,
1775 8
            files_exist: None,
1776 8
            files_not_exist: Some(vec![
1777 8
                "${CARGO_MAKE_WORKING_DIRECTORY}/Cargo.toml".to_string()
1778
            ]),
1779 0
        }),
1780 8
    );
1781

1782 8
    assert!(!enabled);
1783 8
}
1784

1785
#[test]
1786 8
fn validate_condition_for_step_both_valid() {
1787 8
    let mut step = Step {
1788 8
        name: "test".to_string(),
1789 8
        config: Task::new(),
1790 0
    };
1791

1792 8
    let config = Config {
1793 8
        config: ConfigSection::new(),
1794 8
        env_files: vec![],
1795 8
        env: IndexMap::new(),
1796 8
        env_scripts: vec![],
1797 8
        tasks: IndexMap::new(),
1798 0
    };
1799 8
    let flow_info = FlowInfo {
1800 8
        config,
1801 8
        task: "test".to_string(),
1802 8
        env_info: EnvInfo {
1803 8
            rust_info: RustInfo::new(),
1804 8
            crate_info: CrateInfo::new(),
1805 8
            git_info: GitInfo::new(),
1806 8
            ci_info: ci_info::get(),
1807 0
        },
1808
        disable_workspace: false,
1809
        disable_on_error: false,
1810
        allow_private: false,
1811
        skip_init_end_tasks: false,
1812 8
        cli_arguments: None,
1813 0
    };
1814

1815 8
    step.config.condition = Some(TaskCondition {
1816 8
        fail_message: None,
1817 8
        profiles: None,
1818 8
        platforms: Some(vec![
1819 8
            "bad1".to_string(),
1820 8
            types::get_platform_name(),
1821 8
            "bad2".to_string(),
1822
        ]),
1823 8
        channels: None,
1824 8
        env_set: None,
1825 8
        env_not_set: None,
1826 8
        env_true: None,
1827 8
        env_false: None,
1828 8
        env: None,
1829 8
        env_contains: None,
1830 8
        rust_version: None,
1831 8
        files_exist: None,
1832 8
        files_not_exist: None,
1833 0
    });
1834 8
    step.config.condition_script = Some(vec!["exit 0".to_string()]);
1835

1836 8
    let enabled = validate_condition_for_step(&flow_info, &step);
1837

1838 8
    assert!(enabled);
1839 8
}
1840

1841
#[test]
1842 8
fn validate_condition_for_step_valid_script_invalid() {
1843 8
    let mut step = Step {
1844 8
        name: "test".to_string(),
1845 8
        config: Task::new(),
1846 0
    };
1847

1848 8
    let config = Config {
1849 8
        config: ConfigSection::new(),
1850 8
        env_files: vec![],
1851 8
        env: IndexMap::new(),
1852 8
        env_scripts: vec![],
1853 8
        tasks: IndexMap::new(),
1854 0
    };
1855 8
    let flow_info = FlowInfo {
1856 8
        config,
1857 8
        task: "test".to_string(),
1858 8
        env_info: EnvInfo {
1859 8
            rust_info: RustInfo::new(),
1860 8
            crate_info: CrateInfo::new(),
1861 8
            git_info: GitInfo::new(),
1862 8
            ci_info: ci_info::get(),
1863 0
        },
1864
        disable_workspace: false,
1865
        disable_on_error: false,
1866
        allow_private: false,
1867
        skip_init_end_tasks: false,
1868 8
        cli_arguments: None,
1869 0
    };
1870

1871 8
    step.config.condition = Some(TaskCondition {
1872 8
        fail_message: None,
1873 8
        profiles: None,
1874 8
        platforms: Some(vec![
1875 8
            "bad1".to_string(),
1876 8
            types::get_platform_name(),
1877 8
            "bad2".to_string(),
1878
        ]),
1879 8
        channels: None,
1880 8
        env_set: None,
1881 8
        env_not_set: None,
1882 8
        env_true: None,
1883 8
        env_false: None,
1884 8
        env: None,
1885 8
        env_contains: None,
1886 8
        rust_version: None,
1887 8
        files_exist: None,
1888 8
        files_not_exist: None,
1889 0
    });
1890 8
    step.config.condition_script = Some(vec!["exit 1".to_string()]);
1891

1892 8
    let enabled = validate_condition_for_step(&flow_info, &step);
1893

1894 8
    assert!(!enabled);
1895 8
}
1896

1897
#[test]
1898 8
fn validate_condition_for_step_invalid_script_valid() {
1899 8
    let mut step = Step {
1900 8
        name: "test".to_string(),
1901 8
        config: Task::new(),
1902 0
    };
1903

1904 8
    let config = Config {
1905 8
        config: ConfigSection::new(),
1906 8
        env_files: vec![],
1907 8
        env: IndexMap::new(),
1908 8
        env_scripts: vec![],
1909 8
        tasks: IndexMap::new(),
1910 0
    };
1911 8
    let flow_info = FlowInfo {
1912 8
        config,
1913 8
        task: "test".to_string(),
1914 8
        env_info: EnvInfo {
1915 8
            rust_info: RustInfo::new(),
1916 8
            crate_info: CrateInfo::new(),
1917 8
            git_info: GitInfo::new(),
1918 8
            ci_info: ci_info::get(),
1919 0
        },
1920
        disable_workspace: false,
1921
        disable_on_error: false,
1922
        allow_private: false,
1923
        skip_init_end_tasks: false,
1924 8
        cli_arguments: None,
1925 0
    };
1926

1927 8
    step.config.condition = Some(TaskCondition {
1928 8
        fail_message: None,
1929 8
        profiles: None,
1930 8
        platforms: Some(vec!["bad1".to_string(), "bad2".to_string()]),
1931 8
        channels: None,
1932 8
        env_set: None,
1933 8
        env_not_set: None,
1934 8
        env_true: None,
1935 8
        env_false: None,
1936 8
        env: None,
1937 8
        env_contains: None,
1938 8
        rust_version: None,
1939 8
        files_exist: None,
1940 8
        files_not_exist: None,
1941 0
    });
1942 8
    step.config.condition_script = Some(vec!["exit 0".to_string()]);
1943

1944 8
    let enabled = validate_condition_for_step(&flow_info, &step);
1945

1946 8
    assert!(!enabled);
1947 8
}
1948

1949
#[test]
1950
#[ignore]
1951 2
fn validate_condition_for_step_invalid_env_set() {
1952 2
    let mut step = Step {
1953 2
        name: "test".to_string(),
1954 2
        config: Task::new(),
1955 0
    };
1956

1957 2
    let config = Config {
1958 2
        config: ConfigSection::new(),
1959 2
        env_files: vec![],
1960 2
        env: IndexMap::new(),
1961 2
        env_scripts: vec![],
1962 2
        tasks: IndexMap::new(),
1963 0
    };
1964 2
    let flow_info = FlowInfo {
1965 2
        config,
1966 2
        task: "test".to_string(),
1967 2
        env_info: EnvInfo {
1968 2
            rust_info: RustInfo::new(),
1969 2
            crate_info: CrateInfo::new(),
1970 2
            git_info: GitInfo::new(),
1971 2
            ci_info: ci_info::get(),
1972 0
        },
1973
        disable_workspace: false,
1974
        disable_on_error: false,
1975
        allow_private: false,
1976
        skip_init_end_tasks: false,
1977 2
        cli_arguments: None,
1978 0
    };
1979

1980 2
    step.config.condition = Some(TaskCondition {
1981 2
        fail_message: None,
1982 2
        profiles: None,
1983 2
        platforms: None,
1984 2
        channels: None,
1985 2
        env_set: Some(vec!["BAD_ENV_SET1".to_string()]),
1986 2
        env_not_set: None,
1987 2
        env_true: None,
1988 2
        env_false: None,
1989 2
        env: None,
1990 2
        env_contains: None,
1991 2
        rust_version: None,
1992 2
        files_exist: None,
1993 2
        files_not_exist: None,
1994 0
    });
1995 2
    step.config.condition_script = Some(vec!["exit 0".to_string()]);
1996

1997 2
    let enabled = validate_condition_for_step(&flow_info, &step);
1998

1999 2
    assert!(!enabled);
2000 2
}
2001

2002
#[test]
2003
#[ignore]
2004 2
fn validate_condition_for_step_invalid_env_not_set() {
2005 2
    let mut step = Step {
2006 2
        name: "test".to_string(),
2007 2
        config: Task::new(),
2008 0
    };
2009

2010 2
    let config = Config {
2011 2
        config: ConfigSection::new(),
2012 2
        env_files: vec![],
2013 2
        env: IndexMap::new(),
2014 2
        env_scripts: vec![],
2015 2
        tasks: IndexMap::new(),
2016 0
    };
2017 2
    let flow_info = FlowInfo {
2018 2
        config,
2019 2
        task: "test".to_string(),
2020 2
        env_info: EnvInfo {
2021 2
            rust_info: RustInfo::new(),
2022 2
            crate_info: CrateInfo::new(),
2023 2
            git_info: GitInfo::new(),
2024 2
            ci_info: ci_info::get(),
2025 0
        },
2026
        disable_workspace: false,
2027
        disable_on_error: false,
2028
        allow_private: false,
2029
        skip_init_end_tasks: false,
2030 2
        cli_arguments: None,
2031 0
    };
2032

2033 2
    envmnt::set("ENV_SET1", "bad");
2034

2035 2
    step.config.condition = Some(TaskCondition {
2036 2
        fail_message: None,
2037 2
        profiles: None,
2038 2
        platforms: None,
2039 2
        channels: None,
2040 2
        env_set: None,
2041 2
        env_not_set: Some(vec!["ENV_SET1".to_string()]),
2042 2
        env_true: None,
2043 2
        env_false: None,
2044 2
        env: None,
2045 2
        env_contains: None,
2046 2
        rust_version: None,
2047 2
        files_exist: None,
2048 2
        files_not_exist: None,
2049 0
    });
2050 2
    step.config.condition_script = Some(vec!["exit 0".to_string()]);
2051

2052 2
    let enabled = validate_condition_for_step(&flow_info, &step);
2053

2054 2
    assert!(!enabled);
2055 2
}
2056

2057
#[test]
2058
#[ignore]
2059 2
fn validate_condition_for_step_valid_env() {
2060 2
    let mut step = Step {
2061 2
        name: "test".to_string(),
2062 2
        config: T