File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ use std:: fs;
2+ use std:: path:: Path ;
3+
4+ use technique:: parsing;
5+
6+ #[ test]
7+ fn ensure_fail ( ) {
8+ let dir = Path :: new ( "tests/broken/" ) ;
9+
10+ assert ! ( dir. exists( ) , "broken directory missing" ) ;
11+
12+ let entries = fs:: read_dir ( dir) . expect ( "Failed to read broken directory" ) ;
13+
14+ let mut files = Vec :: new ( ) ;
15+ for entry in entries {
16+ let entry = entry. expect ( "Failed to read directory entry" ) ;
17+ let path = entry. path ( ) ;
18+
19+ if path
20+ . extension ( )
21+ . and_then ( |s| s. to_str ( ) )
22+ == Some ( "tq" )
23+ {
24+ files. push ( path) ;
25+ }
26+ }
27+
28+ assert ! ( !files. is_empty( ) , "No .tq files found in broken directory" ) ;
29+
30+ let mut unexpected_successes = Vec :: new ( ) ;
31+
32+ for file in & files {
33+ let content = parsing:: load ( & file)
34+ . unwrap_or_else ( |e| panic ! ( "Failed to load file {:?}: {:?}" , file, e) ) ;
35+
36+ match parsing:: parse ( & file, & content) {
37+ Ok ( _) => {
38+ println ! ( "File {:?} unexpectedly parsed successfully" , file) ;
39+ unexpected_successes. push ( file. clone ( ) ) ;
40+ }
41+ Err ( _) => { }
42+ }
43+ }
44+
45+ if !unexpected_successes. is_empty ( ) {
46+ panic ! (
47+ "Broken files should not to parse successfully, but {} files passed" ,
48+ unexpected_successes. len( )
49+ ) ;
50+ }
51+ }
You can’t perform that action at this time.
0 commit comments