Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/3] support/testing/tests: improve get-developers test
@ 2022-07-24 23:52 Ricardo Martincoski
  2022-07-24 23:53 ` [Buildroot] [PATCH 2/3] utils/get-developers: bail out on parsing errors Ricardo Martincoski
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ricardo Martincoski @ 2022-07-24 23:52 UTC (permalink / raw)
  To: buildroot; +Cc: Ricardo Martincoski

Change the test into a characterization test for all warnings and errors
get-developers can return when parsing the DEVELOPERS files.

It will be helpful when changing the behavior of get-developers to bail
out on all syntax checking warnings.

Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
---
 .../tests/utils/test_get_developers.py        | 67 +++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/support/testing/tests/utils/test_get_developers.py b/support/testing/tests/utils/test_get_developers.py
index e4420bc6dc..12710fe8d3 100644
--- a/support/testing/tests/utils/test_get_developers.py
+++ b/support/testing/tests/utils/test_get_developers.py
@@ -47,31 +47,98 @@ class TestGetDevelopers(unittest.TestCase):
 
         # -v generating error, called from the main dir
         developers = b'text1\n'
         out, err, rc = call_get_developers("./utils/get-developers", ["-v"], self.WITH_EMPTY_PATH, topdir, developers)
         self.assertIn("Syntax error in DEVELOPERS file, line 0: 'text1'", err)
         self.assertEqual(rc, 1)
         self.assertEqual(len(out), 0)
+        self.assertEqual(len(err), 1)
 
         # -v generating error, called from path
         developers = b'text2\n'
         out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers)
         self.assertIn("Syntax error in DEVELOPERS file, line 0: 'text2'", err)
         self.assertEqual(rc, 1)
         self.assertEqual(len(out), 0)
+        self.assertEqual(len(err), 1)
+
+        # -v generating error for file entry with no developer entry
+        developers = b'# comment\n' \
+                     b'\n' \
+                     b'F:\tutils/get-developers\n' \
+                     b'\n' \
+                     b'N:\tAuthor2 <email>\n' \
+                     b'F:\tutils/get-developers\n'
+        out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers)
+        self.assertIn("Syntax error in DEVELOPERS file, line 1", err)
+        self.assertEqual(rc, 0)
+        self.assertEqual(len(out), 0)
+        self.assertEqual(len(err), 1)
+
+        # -v generating error for developer entry with no file entries
+        developers = b'# comment\n' \
+                     b'# comment\n' \
+                     b'\n' \
+                     b'N:\tAuthor1 <email>\n' \
+                     b'N:\tAuthor2 <email>\n' \
+                     b'N:\tAuthor3 <email>\n' \
+                     b'F:\tutils/get-developers\n'
+        out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers)
+        self.assertIn("Syntax error in DEVELOPERS file, line 1", err)
+        self.assertIn("Syntax error in DEVELOPERS file, line 2", err)
+        self.assertEqual(rc, 0)
+        self.assertEqual(len(out), 0)
+        self.assertEqual(len(err), 2)
+
+        # -v not generating error for developer entry with empty list of file entries
+        developers = b'# comment\n' \
+                     b'# comment\n' \
+                     b'\n' \
+                     b'N:\tAuthor1 <email>\n' \
+                     b'\n' \
+                     b'N:\tAuthor2 <email>\n' \
+                     b'\n' \
+                     b'N:\tAuthor3 <email>\n' \
+                     b'F:\tutils/get-developers\n'
+        out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers)
+        self.assertEqual(rc, 0)
+        self.assertEqual(len(out), 0)
+        self.assertEqual(len(err), 0)
+
+        # -v generating warning for old file entry
+        developers = b'N:\tAuthor <email>\n' \
+                     b'F:\tpath/that/does/not/exists/1\n' \
+                     b'F:\tpath/that/does/not/exists/2\n'
+        out, err, rc = call_get_developers("get-developers", ["-v"], self.WITH_UTILS_IN_PATH, topdir, developers)
+        self.assertIn("WARNING: 'path/that/does/not/exists/1' doesn't match any file", err)
+        self.assertIn("WARNING: 'path/that/does/not/exists/2' doesn't match any file", err)
+        self.assertEqual(rc, 0)
+        self.assertEqual(len(out), 0)
+        self.assertEqual(len(err), 2)
 
         # -c generating warning and printing lots of files with no developer
         developers = b'N:\tAuthor <email>\n' \
                      b'F:\tpath/that/does/not/exists/1\n' \
                      b'F:\tpath/that/does/not/exists/2\n'
         out, err, rc = call_get_developers("./utils/get-developers", ["-c"], self.WITH_EMPTY_PATH, topdir, developers)
         self.assertIn("WARNING: 'path/that/does/not/exists/1' doesn't match any file", err)
         self.assertIn("WARNING: 'path/that/does/not/exists/2' doesn't match any file", err)
         self.assertEqual(rc, 0)
         self.assertGreater(len(out), 1000)
+        self.assertEqual(len(err), 2)
+
+        # -c printing lots of files with no developer
+        developers = b'# comment\n' \
+                     b'\n' \
+                     b'N:\tAuthor <email>\n' \
+                     b'F:\tutils/get-developers\n'
+        out, err, rc = call_get_developers("./utils/get-developers", ["-c"], self.WITH_EMPTY_PATH, topdir, developers)
+        self.assertEqual(rc, 0)
+        self.assertGreater(len(out), 1000)
+        self.assertEqual(len(err), 0)
 
         # -p lists more than one developer
         developers = b'N:\tdev1\n' \
                      b'F:\ttoolchain/\n' \
                      b'\n' \
                      b'N:\tdev2\n' \
                      b'F:\ttoolchain/\n'
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-01 21:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-24 23:52 [Buildroot] [PATCH 1/3] support/testing/tests: improve get-developers test Ricardo Martincoski
2022-07-24 23:53 ` [Buildroot] [PATCH 2/3] utils/get-developers: bail out on parsing errors Ricardo Martincoski
2022-08-01 21:03   ` Thomas Petazzoni via buildroot
2022-07-24 23:53 ` [Buildroot] [PATCH 3/3] utils/get-developers: print error for correct line Ricardo Martincoski
2022-08-01 21:04   ` Thomas Petazzoni via buildroot
2022-08-01 20:59 ` [Buildroot] [PATCH 1/3] support/testing/tests: improve get-developers test Thomas Petazzoni via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox