[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.
This commit is contained in:
Rolf Bjarne Kvinge 2019-05-29 08:58:48 -07:00 коммит произвёл Sebastien Pouliot
Родитель 3cd018b55c
Коммит 309da40ee4
1 изменённых файлов: 20 добавлений и 2 удалений

Просмотреть файл

@ -189,6 +189,7 @@ namespace Extrospection {
else
raws [i] = new List<string> ();
}
var failures = new List<string> ();
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<string> (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<string> (File.ReadAllLines (rawfile));
foreach (var entry in File.ReadAllLines (file)) {
var failures = new List<string> ();
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<string> (lines);
foreach (var failure in failures)
sanitized.Remove (failure);
File.WriteAllLines (file, sanitized);
}
}