Skip to content

Commit 9dffc7b

Browse files
Skip ShellTest on non-Windows platforms
1 parent 71ac3ca commit 9dffc7b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

dotnet/test/DotNetUnitTest/Domain/ShellTest.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.IO;
2+
using System.Runtime.InteropServices;
23
using GeneXus.Utils;
34
using Xunit;
45

@@ -10,6 +11,10 @@ public class ShellTest
1011
[Fact]
1112
public void ExecutableTest()
1213
{
14+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
15+
{
16+
return; // Skip test on non-Windows platforms
17+
}
1318
string fileName = "hello.bat";
1419
File.WriteAllText(fileName, "echo \"hello %1\"");
1520
int errorCode = GXUtil.Shell($"{fileName} test", 1, 1);
@@ -18,6 +23,10 @@ public void ExecutableTest()
1823
[Fact]
1924
public void ExecutableWithSpacesTest()
2025
{
26+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
27+
{
28+
return; // Skip test on non-Windows platforms
29+
}
2130
string fileName = "hello world.bat";
2231
File.WriteAllText(fileName, "echo \"hello %1\"");
2332
int errorCode = GXUtil.Shell($"'{fileName}' test", 1, 1);
@@ -27,6 +36,10 @@ public void ExecutableWithSpacesTest()
2736
[Fact]
2837
public void WorkingDirWithSpacesTest()
2938
{
39+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
40+
{
41+
return; // Skip test on non-Windows platforms
42+
}
3043
string fileName = Path.Combine(Directory.GetCurrentDirectory(), "my dir", "hello world.bat");
3144
FileInfo fi = new FileInfo(fileName);
3245
Directory.CreateDirectory(fi.DirectoryName);
@@ -37,6 +50,10 @@ public void WorkingDirWithSpacesTest()
3750
[Fact]
3851
public void WorkingDirForFullQualifiedBat()
3952
{
53+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
54+
{
55+
return; // Skip test on non-Windows platforms
56+
}
4057
string pathName = Directory.GetParent(Directory.GetCurrentDirectory()).FullName; //bat is in a different directory to the current dir
4158
string fileName = Path.Combine(pathName, "TestCurrentDir.bat");
4259
string outputFileName = Path.Combine(Directory.GetCurrentDirectory(), "output.txt"); //Current dir of the process must be the main current dir

0 commit comments

Comments
 (0)