Skip to content

Commit

Permalink
[tests] SkipConvertResourcesCases is more precise
Browse files Browse the repository at this point in the history
Now if this test fails, it will report the file it was looking for.

If new assemblies or resources are added in the future, the test won't
fail: as long as existing ones are still present.
  • Loading branch information
jonathanpeppers committed Oct 30, 2018
1 parent 0ae044d commit 55736cc
Showing 1 changed file with 32 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,41 +68,49 @@ public void SkipConvertResourcesCases ()
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
Assert.IsFalse (b.Output.IsTargetSkipped (target), $"`{target}` should not be skipped.");

int skipped = 0, processed = 0;
List<string> skipped = new List<string> (), processed = new List<string> ();
bool convertResourcesCases = false;
foreach (var line in b.LastBuildOutput) {
if (!convertResourcesCases) {
convertResourcesCases = line.StartsWith ($"Task \"{target}\"", StringComparison.OrdinalIgnoreCase);
} else if (line.StartsWith ($"Done executing task \"{target}\"", StringComparison.OrdinalIgnoreCase)) {
break; //end of target
} else if (line.IndexOf ("Processing:", StringComparison.OrdinalIgnoreCase) >= 0) {
processed++;
//Processing: obj\Debug\res\layout\main.xml 10/29/2018 8:19:36 PM > 1/1/0001 12:00:00 AM
processed.Add (line);
} else if (line.IndexOf ("Skipping:", StringComparison.OrdinalIgnoreCase) >= 0) {
skipped++;
//Skipping: `obj\Debug\lp\5\jl\res` via `SkipAndroidResourceProcessing`, original file: `bin\TestDebug\temp\packages\Xamarin.Android.Support.Compat.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Compat.dll`...
skipped.Add (line);
}
}

/*
Processing: obj\Debug\res\layout\main.xml 10/29/2018 8:19:36 PM > 1/1/0001 12:00:00 AM
Processing: obj\Debug\res\layout\tabbar.xml 10/29/2018 8:19:36 PM > 1/1/0001 12:00:00 AM
Processing: obj\Debug\res\layout\toolbar.xml 10/29/2018 8:19:36 PM > 1/1/0001 12:00:00 AM
Processing: obj\Debug\res\values\colors.xml 10/29/2018 8:19:36 PM > 1/1/0001 12:00:00 AM
Processing: obj\Debug\res\values\strings.xml 10/29/2018 8:19:36 PM > 1/1/0001 12:00:00 AM
Processing: obj\Debug\res\values\styles.xml 10/29/2018 8:19:36 PM > 1/1/0001 12:00:00 AM
*/
Assert.AreEqual (6, processed, "A total of 6 layouts should be processed.");

/*
Skipping: `obj\Debug\lp\5\jl\res` via `SkipAndroidResourceProcessing`, original file: `bin\TestDebug\temp\packages\Xamarin.Android.Support.Compat.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Compat.dll`...
Skipping: `obj\Debug\lp\8\jl\res` via `SkipAndroidResourceProcessing`, original file: `bin\TestDebug\temp\packages\Xamarin.Android.Support.Design.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Design.dll`...
Skipping: `obj\Debug\lp\10\jl\res` via `SkipAndroidResourceProcessing`, original file: `bin\TestDebug\temp\packages\Xamarin.Android.Support.Media.Compat.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Media.Compat.dll`...
Skipping: `obj\Debug\lp\11\jl\res` via `SkipAndroidResourceProcessing`, original file: `bin\TestDebug\temp\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.dll`...
Skipping: `obj\Debug\lp\12\jl\res` via `SkipAndroidResourceProcessing`, original file: `bin\TestDebug\temp\packages\Xamarin.Android.Support.v7.CardView.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.v7.CardView.dll`...
Skipping: `obj\Debug\lp\13\jl\res` via `SkipAndroidResourceProcessing`, original file: `bin\TestDebug\temp\packages\Xamarin.Android.Support.v7.MediaRouter.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.v7.MediaRouter.dll`...
Skipping: `obj\Debug\lp\14\jl\res` via `SkipAndroidResourceProcessing`, original file: `bin\TestDebug\temp\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.dll`...
Skipping: `obj\Debug\lp\20\jl\res` via `SkipAndroidResourceProcessing`, original file: `bin\TestDebug\temp\SkipConvertResourcesCases\Jars\material-menu-1.1.0.aar`...
*/
Assert.AreEqual (8, skipped, "A total of 8 resource directories should be skipped.");
var resources = new [] {
Path.Combine ("layout", "main.xml"),
Path.Combine ("layout", "tabbar.xml"),
Path.Combine ("layout", "toolbar.xml"),
Path.Combine ("values", "colors.xml"),
Path.Combine ("values", "strings.xml"),
Path.Combine ("values", "styles.xml"),
};
foreach (var resource in resources) {
Assert.IsTrue (StringAssertEx.ContainsText (processed, resource), $"`{target}` should process `{resource}`.");
}

var files = new [] {
"Xamarin.Android.Support.Compat.dll",
"Xamarin.Android.Support.Design.dll",
"Xamarin.Android.Support.Media.Compat.dll",
"Xamarin.Android.Support.Transition.dll",
"Xamarin.Android.Support.v4.dll",
"Xamarin.Android.Support.v7.AppCompat.dll",
"Xamarin.Android.Support.v7.CardView.dll",
"Xamarin.Android.Support.v7.MediaRouter.dll",
"Xamarin.Android.Support.v7.RecyclerView.dll",
"material-menu-1.1.0.aar",
};
foreach (var file in skipped) {
Assert.IsTrue (StringAssertEx.ContainsText (skipped, file), $"`{target}` should skip `{file}`.");
}
}
}

Expand Down

0 comments on commit 55736cc

Please sign in to comment.