Skip to content

Commit 3b97d32

Browse files
committed
Update tests and CreateAar
1 parent 95253ed commit 3b97d32

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

Diff for: src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AndroidLibraries.targets

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ projects.
7777
Outputs="$(_AarOutputPath)">
7878
<CreateAar
7979
AssetDirectory="$(MonoAndroidAssetsPrefix)"
80+
PrefixProperty="MonoAndroidAssetsPrefix"
8081
AndroidAssets="@(AndroidAsset)"
8182
AndroidResources="@(_AndroidResourceDest)"
8283
AndroidEnvironment="@(AndroidEnvironment)"

Diff for: src/Xamarin.Android.Build.Tasks/Tasks/CreateAar.cs

+6
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ public class CreateAar : AndroidTask
3434
[Required]
3535
public string OutputFile { get; set; }
3636

37+
public string PrefixProperty { get; set; }
38+
3739
public override bool RunTask ()
3840
{
41+
if (Path.IsPathRooted (AssetDirectory)) {
42+
Log.LogCodedError ("XA1041", message: Properties.Resources.XA1041, PrefixProperty, AssetDirectory);
43+
return false;
44+
}
3945
Directory.CreateDirectory (Path.GetDirectoryName (OutputFile));
4046

4147
using (var stream = File.Create (OutputFile))

Diff for: src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ public void FullPath ()
181181

182182
[Test]
183183
[Category ("SmokeTests")]
184-
public void FullAssetPathRaisesError()
184+
[TestCase("MonoAndroidAssetsPrefix")]
185+
[TestCase("MonoAndroidResourcePrefix")]
186+
public void FullPrefixRaisesError(string prefix)
185187
{
186188
var proj = new XamarinAndroidLibraryProject {
187189
OtherBuildItems = {
@@ -200,16 +202,14 @@ public void FullAssetPathRaisesError()
200202
},
201203
},
202204
};
203-
var envar = new Dictionary<string, string> {
204-
{ "MonoAndroidAssetsPrefix", Path.GetFullPath (Path.Combine (Root, "temp", TestName, "App")) },
205-
{ "MonoAndroidResourcePrefix", Path.GetFullPath (Path.Combine (Root, "temp", TestName, "App")) },
206-
};
205+
using var b = CreateDllBuilder (Path.Combine ("temp", TestName, "Library"));
207206
using var appb = CreateApkBuilder (Path.Combine ("temp", TestName, "App"));
208207
appb.ThrowOnBuildFailure = false;
209-
appb.Save (app);
210-
using var b = CreateDllBuilder (Path.Combine ("temp", TestName, "Library"));
211208
b.ThrowOnBuildFailure = false;
212209
Directory.CreateDirectory (Path.Combine (Root, "temp", TestName, "App"));
210+
var envar = new Dictionary<string, string> {
211+
{ prefix, Path.Combine (Root, "temp", TestName, "App") },
212+
};
213213
Assert.IsFalse (b.Build (proj, environmentVariables: envar), "Build should have failed.");
214214
Assert.IsTrue (b.LastBuildOutput.ContainsText ("error XA1041"), "XA1041 should have been raised.");
215215
Assert.IsFalse (appb.Build (app, environmentVariables: envar), "Build should have failed.");

0 commit comments

Comments
 (0)