@@ -1934,39 +1934,39 @@ mod tests {
1934
1934
#[ test]
1935
1935
fn copy_file_ok( ) {
1936
1936
unsafe {
1937
- let tempdir = getcwd( ) ; // would like to use $TMPDIR,
1938
- // doesn't seem to work on Linux
1939
- assert!( ( tempdir. to_str( ) . len( ) > 0 u) ) ;
1940
- let input = tempdir. push( "in.txt" ) ;
1941
- let out = tempdir. push( "out.txt" ) ;
1937
+ let tempdir = getcwd( ) ; // would like to use $TMPDIR,
1938
+ // doesn't seem to work on Linux
1939
+ assert!( ( tempdir. to_str( ) . len( ) > 0 u) ) ;
1940
+ let input = tempdir. push( "in.txt" ) ;
1941
+ let out = tempdir. push( "out.txt" ) ;
1942
1942
1943
- /* Write the temp input file */
1943
+ /* Write the temp input file */
1944
1944
let ostream = do input. to_str( ) . as_c_str |fromp| {
1945
1945
do "w+b" . as_c_str |modebuf| {
1946
1946
libc:: fopen( fromp, modebuf)
1947
1947
}
1948
- } ;
1949
- assert!( ( ostream as uint != 0 u) ) ;
1950
- let s = ~"hello";
1951
- let mut buf = s.to_owned().to_c_str();
1952
- let len = buf.len();
1953
- do buf.as_mut_buf |b, _len| {
1954
- assert_eq!(libc::fwrite(b as *c_void, 1u as size_t,
1955
- (s.len() + 1u) as size_t, ostream),
1956
- len as size_t)
1957
- }
1958
- assert_eq!(libc::fclose(ostream), (0u as c_int));
1959
- let in_mode = input.get_mode();
1960
- let rs = os::copy_file(&input, &out);
1961
- if (!os::path_exists(&input)) {
1962
- fail!(" %s doesn' t exist", input.to_str());
1963
- }
1964
- assert!((rs));
1965
- let rslt = run::process_status(" diff", [input.to_str(), out.to_str()]);
1966
- assert_eq!(rslt, 0);
1967
- assert_eq!(out.get_mode(), in_mode);
1968
- assert!((remove_file(&input)));
1969
- assert!((remove_file(&out)));
1948
+ } ;
1949
+ assert!( ( ostream as uint != 0 u) ) ;
1950
+ let s = ~"hello";
1951
+ let mut buf = s.to_owned().to_c_str();
1952
+ let len = buf.len();
1953
+ do buf.as_mut_buf |b, _len| {
1954
+ assert_eq!(libc::fwrite(b as *c_void, 1u as size_t,
1955
+ (s.len() + 1u) as size_t, ostream),
1956
+ len as size_t)
1957
+ }
1958
+ assert_eq!(libc::fclose(ostream), (0u as c_int));
1959
+ let in_mode = input.get_mode();
1960
+ let rs = os::copy_file(&input, &out);
1961
+ if (!os::path_exists(&input)) {
1962
+ fail!(" %s doesn' t exist", input.to_str());
1963
+ }
1964
+ assert!((rs));
1965
+ let rslt = run::process_status(" diff", [input.to_str(), out.to_str()]);
1966
+ assert_eq!(rslt, 0);
1967
+ assert_eq!(out.get_mode(), in_mode);
1968
+ assert!((remove_file(&input)));
1969
+ assert!((remove_file(&out)));
1970
1970
}
1971
1971
}
1972
1972
0 commit comments