Skip to content

Commit 9e78d6e

Browse files
[tests] fix test failures on Windows (#47)
Context: https://github.com/xamarin/xamarin-android/blob/b0e6c579f773e55419573e210b648d81b78360ef/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs#L237 Just a few minor things to get these working: - We need `@echo off` on Windows - `echo` doesn't need quotes, or it echos the quotes - We don't need to emit `jvm.dll` as `jvm.dll.cmd` - There is one test checking `PATH`, which doesn't occur on Windows. It doesn't look in `%PATH%`, so we should ignore it on Windows.
1 parent bdf0158 commit 9e78d6e

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/Xamarin.Android.Tools.AndroidSdk/Tests/AndroidSdkInfoTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public void Constructor_Paths ()
6767
[Test]
6868
public void Constructor_SetValuesFromPath ()
6969
{
70+
if (OS.IsWindows)
71+
Assert.Ignore ("Windows does not look for values in %PATH%");
72+
7073
CreateSdks (out string root, out string jdk, out string ndk, out string sdk);
7174
JdkInfoTests.CreateFauxJdk (jdk, releaseVersion: "1.8.0", releaseBuildNumber: "42", javaVersion: "100.100.100_100");
7275

src/Xamarin.Android.Tools.AndroidSdk/Tests/JdkInfoTests.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,19 @@ internal static void CreateFauxJdk (string dir, string releaseVersion, string re
6060
Directory.CreateDirectory (jli);
6161
Directory.CreateDirectory (jre);
6262

63-
63+
string quote = OS.IsWindows ? "" : "\"";
6464
string java =
6565
$"echo Property settings:{Environment.NewLine}" +
66-
$"echo \" java.home = {dir}\"{Environment.NewLine}" +
67-
$"echo \" java.vendor = Xamarin.Android Unit Tests\"{Environment.NewLine}" +
68-
$"echo \" java.version = {javaVersion}\"{Environment.NewLine}" +
69-
$"echo \" xamarin.multi-line = line the first\"{Environment.NewLine}" +
70-
$"echo \" line the second\"{Environment.NewLine}" +
71-
$"echo \" .\"{Environment.NewLine}";
66+
$"echo {quote} java.home = {dir}{quote}{Environment.NewLine}" +
67+
$"echo {quote} java.vendor = Xamarin.Android Unit Tests{quote}{Environment.NewLine}" +
68+
$"echo {quote} java.version = {javaVersion}{quote}{Environment.NewLine}" +
69+
$"echo {quote} xamarin.multi-line = line the first{quote}{Environment.NewLine}" +
70+
$"echo {quote} line the second{quote}{Environment.NewLine}" +
71+
$"echo {quote} .{quote}{Environment.NewLine}";
72+
73+
if (OS.IsWindows) {
74+
java = $"@echo off{Environment.NewLine}{java}";
75+
}
7276

7377
CreateShellScript (Path.Combine (bin, "jar"), "");
7478
CreateShellScript (Path.Combine (bin, "java"), java);
@@ -86,7 +90,7 @@ public void DeleteFauxJdk ()
8690

8791
static void CreateShellScript (string path, string contents)
8892
{
89-
if (OS.IsWindows)
93+
if (OS.IsWindows && string.Compare (Path.GetExtension (path), ".dll", true) != 0)
9094
path += ".cmd";
9195
using (var script = new StreamWriter (path)) {
9296
if (!OS.IsWindows) {

0 commit comments

Comments
 (0)