From 28fab7bdbaac27cf62c1f83d22a6d9fb4d0f9294 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 29 May 2019 08:58:48 -0700 Subject: [PATCH] [xtro] Implement support for auto-sanitizing the .ignore files by defining an environment variable. (#6158) Going through each failure one-by-one after fixing something that fixed many entries is annoying, so automate the process. --- tests/xtro-sharpie/xtro-sanity/Sanitizer.cs | 22 +++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/xtro-sharpie/xtro-sanity/Sanitizer.cs b/tests/xtro-sharpie/xtro-sanity/Sanitizer.cs index 00119cbce0..f34a152440 100644 --- a/tests/xtro-sharpie/xtro-sanity/Sanitizer.cs +++ b/tests/xtro-sharpie/xtro-sanity/Sanitizer.cs @@ -189,6 +189,7 @@ namespace Extrospection { else raws [i] = new List (); } + var failures = new List (); foreach (var entry in common) { if (!entry.StartsWith ("!", StringComparison.Ordinal)) continue; @@ -198,8 +199,16 @@ namespace Extrospection { if (found) break; } - if (!found) + if (!found) { Log ($"?unknown-entry? {entry} in 'common-{fx}.ignore'"); + failures.Add (entry); + } + } + if (failures.Count > 0 && !string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("AUTO_SANITIZE"))) { + var sanitized = new List (common); + foreach (var failure in failures) + sanitized.Remove (failure); + File.WriteAllLines (Path.Combine (directory, $"common-{fx}.ignore"), sanitized); } } // * a platform ignore must existing in it's corresponding raw file @@ -212,12 +221,21 @@ namespace Extrospection { continue; var rawfile = Path.ChangeExtension (file, ".raw"); var raws = new List (File.ReadAllLines (rawfile)); - foreach (var entry in File.ReadAllLines (file)) { + var failures = new List (); + var lines = File.ReadAllLines (file); + foreach (var entry in lines) { if (!entry.StartsWith ("!", StringComparison.Ordinal)) continue; if (raws.Contains (entry)) continue; Log ($"?unknown-entry? {entry} in '{shortname}'"); + failures.Add (entry); + } + if (failures.Count > 0 && !string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("AUTO_SANITIZE"))) { + var sanitized = new List (lines); + foreach (var failure in failures) + sanitized.Remove (failure); + File.WriteAllLines (file, sanitized); } }