1
+ use assert_fs:: fixture:: FileWriteStr ;
1
2
use assert_fs:: { prelude:: PathChild , TempDir } ;
2
3
use indoc:: indoc;
3
4
use scarb_test_support:: {
@@ -19,18 +20,20 @@ fn lint_main_package() {
19
20
"# } )
20
21
. build ( & t) ;
21
22
22
- Scarb :: quick_snapbox ( )
23
+ Scarb :: quick_snapbox ( ) . env ( "CLICOLOR" , "0" )
23
24
. arg ( "lint" )
24
25
. current_dir ( & t)
25
26
. assert ( )
27
+ // Current expected values include ANSI color codes because lint has custom renderer.
26
28
. stdout_matches ( indoc ! { r#"
27
- Checking hello v1.0.0 ([..]Scarb.toml)
28
- warning: Plugin diagnostic: Unnecessary comparison with a boolean value. Use the variable directly.
29
- --> [..]
30
- |
31
- 3 | if x == false {
32
- | ----------
33
- |
29
+ Checking hello v1.0.0 ([..]/Scarb.toml)
30
+ [1m[33mwarning[0m: [1mPlugin diagnostic: Unnecessary comparison with a boolean value. Use the variable directly.[0m
31
+ [1m[94m-->[0m [..]/lib.cairo:3:8
32
+ [1m[94m|[0m
33
+ [1m[94m3 |[0m if x == false {
34
+ [1m[94m|[0m [1m[33m----------[0m
35
+ [1m[94m|[0m
36
+
34
37
"# } )
35
38
. success ( ) ;
36
39
}
@@ -79,27 +82,82 @@ fn lint_workspace() {
79
82
. arg ( "--workspace" )
80
83
. current_dir ( & t)
81
84
. assert ( )
85
+ // Current expected values include ANSI color codes because lint has custom renderer.
82
86
. stdout_matches ( indoc ! { r#"
83
- Checking first v1.0.0 ([..]first/Scarb.toml)
84
- warning: Plugin diagnostic: Unnecessary comparison with a boolean value. Use the variable directly.
85
- --> [..]/lib.cairo:3:8
86
- |
87
- 3 | if first == false {
88
- | --------------
89
- |
90
- Checking main v1.0.0 ([..]/Scarb.toml)
91
- warning: Plugin diagnostic: Unnecessary comparison with a boolean value. Use the variable directly.
92
- --> [..]/lib.cairo:3:8
93
- |
94
- 3 | if _main == false {
95
- | --------------
96
- |
97
- Checking second v1.0.0 ([..]second/Scarb.toml)
98
- warning: Plugin diagnostic: Unnecessary comparison with a boolean value. Use the variable directly.
99
- --> [..]/lib.cairo:3:8
100
- |
101
- 3 | if second == false {
102
- | ---------------
103
- |
87
+ Checking first v1.0.0 ([..]/first/Scarb.toml)
88
+ [1m[33mwarning[0m: [1mPlugin diagnostic: Unnecessary comparison with a boolean value. Use the variable directly.[0m
89
+ [1m[94m-->[0m [..]/lib.cairo:3:8
90
+ [1m[94m|[0m
91
+ [1m[94m3 |[0m if first == false {
92
+ [1m[94m|[0m [1m[33m--------------[0m
93
+ [1m[94m|[0m
94
+
95
+ Checking main v1.0.0 ([..]/Scarb.toml)
96
+ [1m[33mwarning[0m: [1mPlugin diagnostic: Unnecessary comparison with a boolean value. Use the variable directly.[0m
97
+ [1m[94m-->[0m [..]/lib.cairo:3:8
98
+ [1m[94m|[0m
99
+ [1m[94m3 |[0m if _main == false {
100
+ [1m[94m|[0m [1m[33m--------------[0m
101
+ [1m[94m|[0m
102
+
103
+ Checking second v1.0.0 ([..]/second/Scarb.toml)
104
+ [1m[33mwarning[0m: [1mPlugin diagnostic: Unnecessary comparison with a boolean value. Use the variable directly.[0m
105
+ [1m[94m-->[0m [..]/lib.cairo:3:8
106
+ [1m[94m|[0m
107
+ [1m[94m3 |[0m if second == false {
108
+ [1m[94m|[0m [1m[33m---------------[0m
109
+ [1m[94m|[0m
110
+
104
111
"# } ) . success ( ) ;
105
112
}
113
+
114
+ #[ test]
115
+ fn lint_integration_tests ( ) {
116
+ let t = TempDir :: new ( ) . unwrap ( ) ;
117
+ ProjectBuilder :: start ( )
118
+ . name ( "hello" )
119
+ . lib_cairo ( indoc ! { r#"
120
+ pub fn f1() -> u32 {
121
+ 42
122
+ }
123
+
124
+ fn main() {
125
+ // This is a comment
126
+ }
127
+ "# } )
128
+ . dep_cairo_test ( )
129
+ . build ( & t) ;
130
+ t. child ( "tests/test1.cairo" )
131
+ . write_str ( indoc ! { r#"
132
+ use hello::f1;
133
+ #[test]
134
+ fn it_works() {
135
+ let x = true;
136
+ if false == x {
137
+ println!("x is false");
138
+ }
139
+ assert_eq!(1, f1());
140
+ }
141
+ "# } )
142
+ . unwrap ( ) ;
143
+
144
+ Scarb :: quick_snapbox ( )
145
+ . arg ( "lint" )
146
+ . arg ( "-t" )
147
+ . current_dir ( & t)
148
+ . assert ( )
149
+ // Current expected values include ANSI color codes because lint has custom renderer.
150
+ . stdout_matches ( indoc ! { r#"
151
+ Checking hello v1.0.0 ([..]/Scarb.toml)
152
+ Checking test(hello_unittest) hello v1.0.0 ([..]/Scarb.toml)
153
+ Checking test(hello_integrationtest) hello_integrationtest v1.0.0 ([..]/Scarb.toml)
154
+ [1m[33mwarning[0m: [1mPlugin diagnostic: Unnecessary comparison with a boolean value. Use the variable directly.[0m
155
+ [1m[94m-->[0m [..]/tests/test1.cairo:5:8
156
+ [1m[94m|[0m
157
+ [1m[94m5 |[0m if false == x {
158
+ [1m[94m|[0m [1m[33m----------[0m
159
+ [1m[94m|[0m
160
+
161
+ "# } )
162
+ . success ( ) ;
163
+ }
0 commit comments