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