Skip to content

Commit a4d736d

Browse files
committed
adjuting path for files in folder so that tests can wiork on nix with mono
1 parent 619c107 commit a4d736d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

source/TestAdapter/Discover.cs

+14-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using System.IO;
1515
using System.Linq;
1616
using System.Reflection;
17+
using System.Runtime.InteropServices;
1718
using System.Text.RegularExpressions;
1819

1920
namespace nanoFramework.TestPlatform.TestAdapter
@@ -222,7 +223,19 @@ private static string[] GetAllCsFiles(FileInfo[] nfprojFiles)
222223

223224
foreach (System.Text.RegularExpressions.Match compileItem in compileItems)
224225
{
225-
allCsFiles.Add($"{Path.Combine(Path.GetFullPath(nfproj.DirectoryName), compileItem.Groups["source_file"].Value)}");
226+
// Depending on the platform Windows/Other, need to transform the path delimiter for compileItem.Groups["source_file"].Value) from / to \ or vice versa
227+
var filePath = compileItem.Groups["source_file"].Value;
228+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
229+
{
230+
// Transfor the / into \ in filePath
231+
filePath = filePath.Replace("/", "\\");
232+
}
233+
else
234+
{
235+
filePath = filePath.Replace("\\", "/");
236+
}
237+
238+
allCsFiles.Add($"{Path.Combine(Path.GetFullPath(nfproj.DirectoryName), filePath)}");
226239
}
227240
}
228241

0 commit comments

Comments
 (0)