From cd1145d1698f261410efb419623b76de676dcebb Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Mon, 12 Jul 2021 09:44:11 -0400 Subject: [PATCH] [xtro] Do not allow to leave empty todo files in xtro. (#12090) To avoid things like the ones fixed in https://github.com/xamarin/xamarin-macios/pull/12088 we add a new test to ensure that todo files do have content. --- tests/xtro-sharpie/xtro-sanity/Sanitizer.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/xtro-sharpie/xtro-sanity/Sanitizer.cs b/tests/xtro-sharpie/xtro-sanity/Sanitizer.cs index 7b62a30f26..cc7da592dd 100644 --- a/tests/xtro-sharpie/xtro-sanity/Sanitizer.cs +++ b/tests/xtro-sharpie/xtro-sanity/Sanitizer.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Collections.Generic; using System.IO; @@ -169,6 +170,17 @@ namespace Extrospection { } } + static void NoEmptyTodo () + { + foreach (var file in Directory.GetFiles (directory, "*.todo")) { + if (!IsIncluded (file)) + continue; + if (!(File.ReadLines(file).Count() > 0)) { + Log ($"?empty-todo? File '{Path.GetFileName (file)}' is empty. Empty todo files should be removed."); + } + } + } + static string directory; static Dictionary> commons = new Dictionary> (); static int count; @@ -301,6 +313,9 @@ namespace Extrospection { // entries in .todo should be found in .raw files - else it's likely fixed (and out of date) NoFixedTodo (); + // empty files should be removed + NoEmptyTodo (); + if (count == 0) Console.WriteLine ("Sanity check passed"); else