@@ -66,18 +66,18 @@ async fn test_set_size(dir: &Descriptor) {
6666 assert_eq ! ( c. stat( ) . await . unwrap( ) . size, 0 ) ;
6767 assert_eq ! ( r. stat( ) . await . unwrap( ) . size, 0 ) ;
6868
69- // https://github.com/WebAssembly/wasi-filesystem /issues/190
69+ // https://github.com/WebAssembly/WASI /issues/712
7070 match r. set_size ( 100 ) . await {
7171 Ok ( ( ) ) => {
7272 panic ! ( "set-size succeeded on read-only descriptor" ) ;
7373 }
74- Err ( ErrorCode :: Invalid | ErrorCode :: BadDescriptor ) => { }
74+ Err ( ErrorCode :: Invalid | ErrorCode :: BadDescriptor | ErrorCode :: Access ) => { }
7575 Err ( err) => {
7676 panic ! ( "unexpected err: {}" , err)
7777 }
7878 } ;
7979
80- // https://github.com/WebAssembly/wasi-filesystem /issues/190
80+ // https://github.com/WebAssembly/WASI /issues/712
8181 match c. set_size ( u64:: MAX ) . await {
8282 Ok ( ( ) ) => {
8383 panic ! ( "set-size(-1) succeeded" ) ;
@@ -88,17 +88,20 @@ async fn test_set_size(dir: &Descriptor) {
8888 }
8989 } ;
9090
91- rm ( "c.cleanup" ) . await . unwrap ( ) ;
92-
93- // We still have `c` and `r` open, which refer to the file; on POSIX
94- // systems, the `c.cleanup` will have been removed from its dir,
95- // whereas on Windows that will happen when the last open descriptor
96- // (`c` and `r`) is closed. In any case we can still stat our
97- // descriptors, call `set-size` on it, and so on.
98- assert_eq ! ( c. stat( ) . await . unwrap( ) . size, 0 ) ;
99- c. set_size ( 42 ) . await . unwrap ( ) ;
100- assert_eq ! ( c. stat( ) . await . unwrap( ) . size, 42 ) ;
101- assert_eq ! ( r. stat( ) . await . unwrap( ) . size, 42 ) ;
91+ match rm ( "c.cleanup" ) . await {
92+ Ok ( ( ) ) => {
93+ // We still have `c` and `r` open, which refer to the file,
94+ // but we can still stat our descriptors, call `set-size` on
95+ // it, and so on.
96+ assert_eq ! ( c. stat( ) . await . unwrap( ) . size, 0 ) ;
97+ c. set_size ( 42 ) . await . unwrap ( ) ;
98+ assert_eq ! ( c. stat( ) . await . unwrap( ) . size, 42 ) ;
99+ assert_eq ! ( r. stat( ) . await . unwrap( ) . size, 42 ) ;
100+ }
101+ Err ( ErrorCode :: Busy ) => {
102+ // Otherwise if we're on Windows we are unable to remove the
103+ // file while descriptors are open.
104+ }
102105}
103106
104107struct Component ;
0 commit comments