diff options
author | Fabio Baltieri <fabiobaltieri@google.com> | 2023-02-15 11:09:56 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-02-15 17:59:55 +0000 |
commit | e8b715d1b2c0b35996413a5439cf63551807873a (patch) | |
tree | d58eb156352e2ec4022912169682a4b596881382 /util/zephyr_check_compliance_unittest.py | |
parent | 192cb39d9c872f8f58ccae263384d4579d3d91bc (diff) | |
download | chrome-ec-e8b715d1b2c0b35996413a5439cf63551807873a.tar.gz |
util: zephyr_check_compliance: exclude all files not under zephyr
Change the zephyr_check_compliance script to actually exclude all files
not under "zephyr" by patching the upstream get_files() to ignore them.
This stops the script from checking file outside of the zephyr/
directory if the commit contains files both in and out of it.
BRANCH=none
BUG=none
TEST=unit test and fake commit
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Change-Id: I44ccba973b8f7f5be606652d076252abaf5a0f22
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4254305
Commit-Queue: Tristan Honscheid <honscheid@google.com>
Reviewed-by: Tristan Honscheid <honscheid@google.com>
Diffstat (limited to 'util/zephyr_check_compliance_unittest.py')
-rwxr-xr-x | util/zephyr_check_compliance_unittest.py | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/util/zephyr_check_compliance_unittest.py b/util/zephyr_check_compliance_unittest.py index 259dfd782d..1d4be968d0 100755 --- a/util/zephyr_check_compliance_unittest.py +++ b/util/zephyr_check_compliance_unittest.py @@ -55,28 +55,32 @@ class TestZephyrCheckCompliance(unittest.TestCase): """Tests for zephyr_check_compliance.""" @mock.patch("check_compliance.get_files") - def test_changed_files_prefix(self, get_files_mock): - """Test _changed_files_prefix.""" + def test_changed_files(self, get_files_mock): + """Test _changed_files.""" get_files_mock.return_value = [ - "a/file", - "b/file", - "c/file", + "file1", + "file2", ] - out = zephyr_check_compliance._changed_files_prefix("x/", "ref") + zephyr_check_compliance._patch_get_files() + out = zephyr_check_compliance._changed_files("ref") self.assertFalse(out) - out = zephyr_check_compliance._changed_files_prefix("b/", "ref") + + get_files_mock.return_value.append("zephyr/file3") + + zephyr_check_compliance._patch_get_files() + out = zephyr_check_compliance._changed_files("ref") self.assertTrue(out) - @mock.patch("zephyr_check_compliance._changed_files_prefix") + @mock.patch("zephyr_check_compliance._changed_files") @mock.patch("check_compliance.main") - def test_main(self, main_mock, changed_files_prefix_mock): + def test_main(self, main_mock, changed_files_mock): """Tests the main function.""" - changed_files_prefix_mock.return_value = True + changed_files_mock.return_value = True zephyr_check_compliance.main(["ref"]) - changed_files_prefix_mock.assert_called_with("zephyr/", "ref~1..ref") + changed_files_mock.assert_called_with("ref~1..ref") main_mock.assert_called_with( [ "--output=", @@ -88,26 +92,26 @@ class TestZephyrCheckCompliance(unittest.TestCase): ] ) - @mock.patch("zephyr_check_compliance._changed_files_prefix") + @mock.patch("zephyr_check_compliance._changed_files") @mock.patch("check_compliance.main") - def test_main_skip_presubmit(self, main_mock, changed_files_prefix_mock): + def test_main_skip_presubmit(self, main_mock, changed_files_mock): """Tests the main function.""" - changed_files_prefix_mock.return_value = False + changed_files_mock.return_value = False zephyr_check_compliance.main([zephyr_check_compliance.PRE_SUBMIT_REF]) - self.assertEqual(changed_files_prefix_mock.call_count, 0) + self.assertEqual(changed_files_mock.call_count, 0) self.assertEqual(main_mock.call_count, 0) - @mock.patch("zephyr_check_compliance._changed_files_prefix") + @mock.patch("zephyr_check_compliance._changed_files") @mock.patch("check_compliance.main") - def test_main_skip_prefix(self, main_mock, changed_files_prefix_mock): + def test_main_skip(self, main_mock, changed_files_mock): """Tests the main function.""" - changed_files_prefix_mock.return_value = False + changed_files_mock.return_value = False zephyr_check_compliance.main(["ref"]) - changed_files_prefix_mock.assert_called_with("zephyr/", "ref~1..ref") + changed_files_mock.assert_called_with("ref~1..ref") self.assertEqual(main_mock.call_count, 0) |