Skip to content

Commit 5e84928

Browse files
Copilotjozkee
andcommitted
Address review feedback: drop IsPrivilegedProcess from NTFS guard, simplify ConditionalFact for not-ready drive tests
Co-authored-by: jozkee <16040868+jozkee@users.noreply.github.com>
1 parent efabc18 commit 5e84928

4 files changed

Lines changed: 10 additions & 12 deletions

File tree

src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/CreateDirectory.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ public void SubdirectoryOnNonExistentDriveAsPath_ThrowsDirectoryNotFoundExceptio
519519
});
520520
}
521521

522-
[ConditionalFact(nameof(HasNotReadyDrive))]
522+
[ConditionalFact]
523523
[PlatformSpecific(TestPlatforms.Windows)] // testing drive labels
524524
public void NotReadyDriveAsPath_ThrowsDirectoryNotFoundException()
525525
{ // Behavior is suspect, should really have thrown IOException similar to the SubDirectory case
@@ -531,7 +531,7 @@ public void NotReadyDriveAsPath_ThrowsDirectoryNotFoundException()
531531
});
532532
}
533533

534-
[ConditionalFact(nameof(HasNotReadyDrive))]
534+
[ConditionalFact]
535535
[PlatformSpecific(TestPlatforms.Windows)] // testing drive labels
536536
public void SubdirectoryOnNotReadyDriveAsPath_ThrowsIOException()
537537
{
@@ -545,7 +545,6 @@ public void SubdirectoryOnNotReadyDriveAsPath_ThrowsIOException()
545545
}
546546

547547
private static readonly string? s_notReadyDrive = IOServices.GetNotReadyDrive();
548-
private static bool HasNotReadyDrive => s_notReadyDrive is not null;
549548

550549
#if !TEST_WINRT // Cannot set current directory to root from appcontainer with it's default ACL
551550
/*

src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Delete_MountVolume.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ public class Directory_Delete_MountVolume
2424
private delegate void ExceptionCode();
2525
private static bool s_pass = true;
2626

27-
private static bool IsPrivilegedAndNtfs =>
28-
PlatformDetection.IsPrivilegedProcess && FileSystemDebugInfo.IsCurrentDriveNTFS();
27+
private static bool IsNtfs =>
28+
FileSystemDebugInfo.IsCurrentDriveNTFS();
2929

30-
[ConditionalFact(nameof(IsPrivilegedAndNtfs))]
30+
[ConditionalFact(nameof(IsNtfs))]
3131
[PlatformSpecific(TestPlatforms.Windows)] // testing volumes / mounts / drive letters
3232
public static void RunTest()
3333
{

src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/Exists.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public void DirectoryWithComponentLongerThanMaxComponentAsPath_ReturnsFalse(stri
302302
Assert.False(Exists(component));
303303
}
304304

305-
[ConditionalFact(nameof(HasNotReadyDrive))]
305+
[ConditionalFact]
306306
[PlatformSpecific(TestPlatforms.Windows)] // drive labels
307307
public void NotReadyDriveAsPath_ReturnsFalse()
308308
{
@@ -313,7 +313,7 @@ public void NotReadyDriveAsPath_ReturnsFalse()
313313
Assert.False(result);
314314
}
315315

316-
[ConditionalFact(nameof(HasNotReadyDrive))]
316+
[ConditionalFact]
317317
[PlatformSpecific(TestPlatforms.Windows)] // drive labels
318318
public void SubdirectoryOnNotReadyDriveAsPath_ReturnsFalse()
319319
{
@@ -325,7 +325,6 @@ public void SubdirectoryOnNotReadyDriveAsPath_ReturnsFalse()
325325
}
326326

327327
private static readonly string? s_notReadyDrive = IOServices.GetNotReadyDrive();
328-
private static bool HasNotReadyDrive => s_notReadyDrive is not null;
329328

330329
// Not all drives may be accessible (locked, no rights, etc.), and as such would return false.
331330
// eg. Create a new volume, bitlocker it, and lock it. This new volume is no longer accessible

src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/Directory/ReparsePoints_MountVolume.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ public class Directory_ReparsePoints_MountVolume
2020
private delegate void ExceptionCode();
2121
private static bool s_pass = true;
2222

23-
private static bool IsPrivilegedAndNtfs =>
24-
PlatformDetection.IsPrivilegedProcess && FileSystemDebugInfo.IsCurrentDriveNTFS();
23+
private static bool IsNtfs =>
24+
FileSystemDebugInfo.IsCurrentDriveNTFS();
2525

26-
[ConditionalFact(nameof(IsPrivilegedAndNtfs))]
26+
[ConditionalFact(nameof(IsNtfs))]
2727
[PlatformSpecific(TestPlatforms.Windows)] // testing mounting volumes and reparse points
2828
public static void runTest()
2929
{

0 commit comments

Comments
 (0)