@@ -54,25 +54,34 @@ fn main() -> anyhow::Result<()> {
5454        . filter_module ( "test_with_generated_opts" ,  LevelFilter :: Info ) 
5555        . init ( ) ; 
5656
57-     let  Tests  {  tests  }  = fs:: read_to_string ( & config) 
57+     let  Config  {  examples  }  = fs:: read_to_string ( & config) 
5858        . map_err ( anyhow:: Error :: from) 
5959        . and_then ( |s| toml:: from_str ( & s) . map_err ( Into :: into) ) 
6060        . with_context ( || format ! ( "Failed to read {}" ,  config. display( ) ) ) ?; 
6161
6262    let  tempdir = TempDir :: new ( "atcoder-rust-base-test-with-generated-opts" ) ?; 
6363
64-     let  tests = tests 
64+     let  tests = examples 
6565        . into_iter ( ) 
66-         . map ( |( slug,  Test  {  name,  matching } ) | { 
67-             let  src = Path :: new ( "./examples" ) . join ( & slug) . with_extension ( "rs" ) ; 
68-             let  testsets = Path :: new ( "./examples/testsets" ) . join ( & slug) ; 
69-             let  binary = compile ( & src,  tempdir. path ( ) ,  & slug) ?; 
70-             Ok ( ( name,  matching,  testsets,  binary) ) 
71-         } ) 
66+         . map ( 
67+             |( 
68+                 slug, 
69+                 Example  { 
70+                     name, 
71+                     url, 
72+                     matching, 
73+                 } , 
74+             ) | { 
75+                 let  src = Path :: new ( "./examples" ) . join ( & slug) . with_extension ( "rs" ) ; 
76+                 let  testsets = Path :: new ( "./examples/testsets" ) . join ( & slug) ; 
77+                 let  binary = compile ( & src,  tempdir. path ( ) ,  & slug) ?; 
78+                 Ok ( ( name,  url,  matching,  testsets,  binary) ) 
79+             } , 
80+         ) 
7281        . collect :: < anyhow:: Result < Vec < _ > > > ( ) ?; 
7382
74-     for  ( name,  matching,  testsets,  binary)  in  tests { 
75-         test ( & name,  matching,  & testsets,  & binary) ?; 
83+     for  ( name,  url ,   matching,  testsets,  binary)  in  tests { 
84+         test ( & name,  & url ,   matching,  & testsets,  & binary) ?; 
7685    } 
7786    Ok ( ( ) ) 
7887} 
@@ -142,20 +151,31 @@ fn compile(src: &Path, tempdir: &Path, dir_name: &str) -> anyhow::Result<PathBuf
142151    Ok ( out) 
143152} 
144153
145- fn  test ( task_name :  & str ,  matching :  Matching ,  testsets :  & Path ,  binary :  & Path )  -> anyhow:: Result < ( ) >  { 
154+ fn  test ( 
155+     task_name :  & str , 
156+     url :  & str , 
157+     matching :  Matching , 
158+     testsets :  & Path , 
159+     binary :  & Path , 
160+ )  -> anyhow:: Result < ( ) >  { 
146161    let  testsets = { 
147-         let  find_files = |dir :  & str | -> _  { 
148-             fs:: read_dir ( testsets. join ( dir) ) ?
149-                 . map ( |entry| { 
150-                     let  path = entry?. path ( ) ; 
151-                     let  name = path
152-                         . file_stem ( ) 
153-                         . unwrap_or_default ( ) 
154-                         . to_string_lossy ( ) 
155-                         . into_owned ( ) ; 
156-                     Ok ( ( name,  path) ) 
162+         let  find_files = |dir_file_name :  & str | -> _  { 
163+             let  dir = testsets. join ( dir_file_name) ; 
164+             fs:: read_dir ( & dir) 
165+                 . and_then ( |read_dir| { 
166+                     read_dir
167+                         . map ( |entry| { 
168+                             let  path = entry?. path ( ) ; 
169+                             let  name = path
170+                                 . file_stem ( ) 
171+                                 . unwrap_or_default ( ) 
172+                                 . to_string_lossy ( ) 
173+                                 . into_owned ( ) ; 
174+                             Ok ( ( name,  path) ) 
175+                         } ) 
176+                         . collect :: < io:: Result < HashMap < _ ,  _ > > > ( ) 
157177                } ) 
158-                 . collect :: < io :: Result < HashMap < _ ,   _ > > > ( ) 
178+                 . with_context ( ||  format ! ( "Failed to read {}" ,  dir . display ( ) ) ) 
159179        } ; 
160180
161181        let  ( ins,  outs)  = ( find_files ( "in" ) ?,  find_files ( "out" ) ?) ; 
@@ -168,7 +188,9 @@ fn test(task_name: &str, matching: Matching, testsets: &Path, binary: &Path) ->
168188            . collect :: < BTreeMap < _ ,  _ > > ( ) 
169189    } ; 
170190
171-     info ! ( "Testing {} for {:?}" ,  binary. display( ) ,  task_name) ; 
191+     info ! ( "Testing {}" ,  binary. display( ) ) ; 
192+     info ! ( "  Name: {:?}" ,  task_name) ; 
193+     info ! ( "  URL: {}" ,  url) ; 
172194
173195    for  ( test_name,  ( path_in,  path_out) )  in  testsets { 
174196        fn  read_to_string ( path :  & Path )  -> anyhow:: Result < String >  { 
@@ -218,13 +240,14 @@ fn test(task_name: &str, matching: Matching, testsets: &Path, binary: &Path) ->
218240} 
219241
220242#[ derive( Debug ,  Deserialize ) ]  
221- struct  Tests  { 
222-     tests :  IndexMap < String ,  Test > , 
243+ struct  Config  { 
244+     examples :  IndexMap < String ,  Example > , 
223245} 
224246
225247#[ derive( Debug ,  Deserialize ) ]  
226- struct  Test  { 
248+ struct  Example  { 
227249    name :  String , 
250+     url :  String , 
228251    matching :  Matching , 
229252} 
230253
0 commit comments