11#![ cfg( test) ]
22
33use assert_cmd:: assert:: OutputAssertExt ;
4+ use elaborate:: std:: {
5+ env:: { set_current_dir_wc, var_wc} ,
6+ fs:: { read_to_string_wc, write_wc} ,
7+ path:: PathContext ,
8+ process:: CommandContext ,
9+ } ;
410use regex:: Regex ;
511use similar_asserts:: SimpleDiff ;
612use std:: {
7- env:: { remove_var, set_current_dir , var } ,
13+ env:: remove_var,
814 ffi:: OsStr ,
9- fs:: { read_to_string, write} ,
1015 ops:: Range ,
1116 path:: Path ,
1217 process:: { Command , ExitStatus } ,
@@ -21,7 +26,7 @@ fn initialize() {
2126 unsafe {
2227 remove_var ( "CARGO_TERM_COLOR" ) ;
2328 }
24- set_current_dir ( ".." ) ;
29+ let _ = set_current_dir_wc ( ".." ) ;
2530}
2631
2732#[ test]
@@ -55,7 +60,7 @@ fn dylint() {
5560#[ test]
5661fn elaborate_disallowed_methods ( ) {
5762 elaborate:: disallowed_methods ( )
58- . args ( [ "--all-features" , "--all-targets" ] )
63+ . args ( [ "--workspace" , "-- all-features", "--all-targets" ] )
5964 . env ( "RUSTUP_TOOLCHAIN" , "nightly" )
6065 . assert ( )
6166 . success ( ) ;
@@ -174,7 +179,7 @@ fn prettier() {
174179 // smoelius: Copied from Necessist:
175180 // Prettier's handling of `..` seems to have changed between versions 3.4 and 3.5.
176181 // Manually collapsing the `..` avoids the problem.
177- let parent = Path :: new ( env ! ( "CARGO_MANIFEST_DIR" ) ) . parent ( ) . unwrap ( ) ;
182+ let parent = Path :: new ( env ! ( "CARGO_MANIFEST_DIR" ) ) . parent_wc ( ) . unwrap ( ) ;
178183
179184 let tempdir = tempdir ( ) . unwrap ( ) ;
180185
@@ -197,10 +202,10 @@ fn prettier() {
197202
198203#[ test]
199204fn readme_contains_expected_contents ( ) {
200- let contents = read_to_string ( "ei/tests/rustsec_advisories.stdout" ) . unwrap ( ) ;
205+ let contents = read_to_string_wc ( "ei/tests/rustsec_advisories.stdout" ) . unwrap ( ) ;
201206 let ( _, middle_expected, bottom_expected) = split_at_cut_lines ( & contents) . unwrap ( ) ;
202207
203- let readme = read_to_string ( "README.md" ) . unwrap ( ) ;
208+ let readme = read_to_string_wc ( "README.md" ) . unwrap ( ) ;
204209 let lines = readme. lines ( ) ;
205210
206211 let mut lines = lines. skip_while ( |& line| line != "<!-- as-of start -->" ) ;
@@ -225,7 +230,7 @@ fn readme_contains_expected_contents() {
225230#[ cfg_attr( target_os = "windows" , ignore) ]
226231#[ test]
227232fn readme_contains_usage ( ) {
228- let readme = read_to_string ( "README.md" ) . unwrap ( ) ;
233+ let readme = read_to_string_wc ( "README.md" ) . unwrap ( ) ;
229234
230235 let assert = Command :: new ( "cargo" )
231236 . args ( [
@@ -256,7 +261,7 @@ fn readme_contains_usage() {
256261#[ test]
257262fn readme_reference_links_are_sorted ( ) {
258263 let re = Regex :: new ( r"^\[[^\]]*\]:" ) . unwrap ( ) ;
259- let readme = read_to_string ( "README.md" ) . unwrap ( ) ;
264+ let readme = read_to_string_wc ( "README.md" ) . unwrap ( ) ;
260265 let links = readme
261266 . lines ( )
262267 . filter ( |line| re. is_match ( line) )
@@ -269,7 +274,7 @@ fn readme_reference_links_are_sorted() {
269274#[ test]
270275fn readme_reference_links_are_used ( ) {
271276 let re = Regex :: new ( r"(?m)^(\[[^\]]*\]):" ) . unwrap ( ) ;
272- let readme = read_to_string ( "README.md" ) . unwrap ( ) ;
277+ let readme = read_to_string_wc ( "README.md" ) . unwrap ( ) ;
273278 for captures in re. captures_iter ( & readme) {
274279 assert_eq ! ( 2 , captures. len( ) ) ;
275280 let m = captures. get ( 1 ) . unwrap ( ) ;
@@ -289,7 +294,7 @@ fn dependencies_are_sorted() {
289294 . filter ( |e| e. file_name ( ) == OsStr :: new ( "Cargo.toml" ) )
290295 {
291296 let path = entry. path ( ) ;
292- let contents = read_to_string ( path) . unwrap ( ) ;
297+ let contents = read_to_string_wc ( path) . unwrap ( ) ;
293298 let document = contents. parse :: < toml_edit:: Document < _ > > ( ) . unwrap ( ) ;
294299 for table_name in [ "dependencies" , "dev-dependencies" , "build-dependencies" ] {
295300 let Some ( span) = key_value_pair_span ( & document, table_name) else {
@@ -366,7 +371,7 @@ fn group_starts<S: AsRef<str>>(
366371fn supply_chain ( ) {
367372 let mut command = Command :: new ( "cargo" ) ;
368373 command. args ( [ "supply-chain" , "update" , "--cache-max-age=0s" ] ) ;
369- let _: ExitStatus = command. status ( ) . unwrap ( ) ;
374+ let _: ExitStatus = command. status_wc ( ) . unwrap ( ) ;
370375
371376 let mut command = Command :: new ( "cargo" ) ;
372377 command. args ( [ "supply-chain" , "json" , "--no-dev" ] ) ;
@@ -380,9 +385,9 @@ fn supply_chain() {
380385 let path_buf = Path :: new ( env ! ( "CARGO_MANIFEST_DIR" ) ) . join ( "supply_chain.json" ) ;
381386
382387 if enabled ( "BLESS" ) {
383- write ( path_buf, stdout_normalized) . unwrap ( ) ;
388+ write_wc ( path_buf, stdout_normalized) . unwrap ( ) ;
384389 } else {
385- let stdout_expected = read_to_string ( & path_buf) . unwrap ( ) ;
390+ let stdout_expected = read_to_string_wc ( & path_buf) . unwrap ( ) ;
386391
387392 assert ! (
388393 stdout_expected == stdout_normalized,
@@ -416,5 +421,5 @@ fn remove_avatars(value: &mut serde_json::Value) {
416421}
417422
418423fn enabled ( key : & str ) -> bool {
419- var ( key) . is_ok_and ( |value| value != "0" )
424+ var_wc ( key) . is_ok_and ( |value| value != "0" )
420425}
0 commit comments