Skip to content

Commit 95abe16

Browse files
committed
[tests] Does monodroid-config.xml exist?
Context: #7081 Context: #7073 (comment) Trying to figure out why the `InstallAndroidDependenciesTest()` is failing. My *guess* is that `monodroid-config.xml` exists, causing the `$(_AndroidSdkPath)` output property to use a *system-wide* installation path, instead of the desired `$(AndoridSdkDirectory)` input value. PR #7081 tested behavior against main, and determined that `monodroid-config.xml` doesn't exist, which may be why this test passes on main. Update #7073 to also assert the (non-?)existence of `monodroid-config.xml`. If it *does* exist, this would explain why it's failing. *If* it's failing because of `monodroid-config.xml`, the next question becomes *why* it exists. Update `BaseTest.TestSetup()` to assert that it doesn't exist; when it does exist, tests will begin failing.
1 parent 24a4781 commit 95abe16

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidDependenciesTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ public void InstallAndroidDependenciesTest ()
4040
"AndroidManifestType=GoogleV2", // Need GoogleV2 so we can install API-32
4141
}), "InstallAndroidDependencies should have succeeded.");
4242
b.Target = defaultTarget;
43+
TestContext.Out.WriteLine ($"[TESTLOG] `{_configPath}` exists? {File.Exists (_configPath)}");
4344
Assert.IsTrue (b.Build (proj, true), "build should have succeeded.");
4445
Assert.IsTrue (b.LastBuildOutput.ContainsText ($"Output Property: _AndroidSdkDirectory={sdkPath}"), "_AndroidSdkDirectory was not set to new SDK path.");
4546
Assert.IsTrue (b.LastBuildOutput.ContainsText ($"JavaPlatformJarPath={sdkPath}"), "JavaPlatformJarPath did not contain new SDK path.");
4647
}
4748
} finally {
4849
Environment.SetEnvironmentVariable ("ANDROID_SDK_PATH", old);
4950
}
51+
throw new Exception ($"# jonp: deliberate test failure! File.Exist(\"{_configPath}\")? {File.Exists (_configPath)}");
5052
}
5153

5254
[Test]

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,11 +630,17 @@ protected void AssertExtractNativeLibs (string manifest, bool extractNativeLibs)
630630
}
631631
}
632632

633+
protected static string _configPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "xbuild", "monodroid-config.xml");
634+
633635
[SetUp]
634636
public void TestSetup ()
635637
{
636638
TestContext.Out.WriteLine ($"[TESTLOG] Test {TestName} Starting");
637639
TestContext.Out.Flush ();
640+
if (System.IO.File.Exists (_configPath)) {
641+
TestContext.Out.WriteLine ($"[TESTLOG] `{_configPath}` exists!");
642+
throw new Exception ($"# jonp: deliberate test failure! File.Exist(\"{_configPath}\")!");
643+
}
638644
}
639645

640646
[TearDown]

0 commit comments

Comments
 (0)