File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1969,6 +1969,31 @@ test "delete a setAsCwd directory on Windows" {
19691969 tmp .parent_dir .close ();
19701970}
19711971
1972+ test "use Lock.none on Windows" {
1973+ if (native_os != .windows ) return error .SkipZigTest ;
1974+
1975+ var tmp = tmpDir (.{});
1976+ defer tmp .cleanup ();
1977+
1978+ // Create a locked file.
1979+ const test_file = try tmp .dir .createFile ("test_file" , .{ .lock = .exclusive , .lock_nonblocking = true });
1980+ defer test_file .close ();
1981+
1982+ // Attempt to unlock the file via fs.lock with Lock.none.
1983+ try File .lock (test_file , .none );
1984+
1985+ // Attempt to open the file now that it should be unlocked.
1986+ const test_file2 = try tmp .dir .openFile ("test_file" , .{ .lock = .exclusive , .lock_nonblocking = true });
1987+ defer test_file2 .close ();
1988+
1989+ // Make sure Lock.none works with tryLock as well.
1990+ try testing .expect (try File .tryLock (test_file2 , .none ));
1991+
1992+ // Attempt to open the file since it should be unlocked again.
1993+ const test_file3 = try tmp .dir .openFile ("test_file" , .{});
1994+ test_file3 .close ();
1995+ }
1996+
19721997test "invalid UTF-8/WTF-8 paths" {
19731998 const expected_err = switch (native_os ) {
19741999 .wasi = > error .InvalidUtf8 ,
You can’t perform that action at this time.
0 commit comments