1 include!("../build/rustc.rs");
2 
3 #[test]
test_parse()4 fn test_parse() {
5     let cases = &[
6         (
7             "rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)",
8             Version {
9                 minor: 0,
10                 patch: 0,
11                 channel: Stable,
12             },
13         ),
14         (
15             "rustc 1.18.0",
16             Version {
17                 minor: 18,
18                 patch: 0,
19                 channel: Stable,
20             },
21         ),
22         (
23             "rustc 1.24.1 (d3ae9a9e0 2018-02-27)",
24             Version {
25                 minor: 24,
26                 patch: 1,
27                 channel: Stable,
28             },
29         ),
30         (
31             "rustc 1.35.0-beta.3 (c13114dc8 2019-04-27)",
32             Version {
33                 minor: 35,
34                 patch: 0,
35                 channel: Beta,
36             },
37         ),
38         (
39             "rustc 1.36.0-nightly (938d4ffe1 2019-04-27)",
40             Version {
41                 minor: 36,
42                 patch: 0,
43                 channel: Nightly(Date {
44                     year: 2019,
45                     month: 4,
46                     day: 27,
47                 }),
48             },
49         ),
50         (
51             "rustc 1.36.0-dev",
52             Version {
53                 minor: 36,
54                 patch: 0,
55                 channel: Dev,
56             },
57         ),
58         (
59             "rustc 1.36.0-nightly",
60             Version {
61                 minor: 36,
62                 patch: 0,
63                 channel: Dev,
64             },
65         ),
66         (
67             "warning: invalid logging spec 'warning', ignoring it
68              rustc 1.30.0-nightly (3bc2ca7e4 2018-09-20)",
69             Version {
70                 minor: 30,
71                 patch: 0,
72                 channel: Nightly(Date {
73                     year: 2018,
74                     month: 9,
75                     day: 20,
76                 }),
77             },
78         ),
79     ];
80 
81     for (string, expected) in cases {
82         assert_eq!(parse(string).unwrap(), *expected);
83     }
84 }
85