Fix argument mismatch in split_cl.py

When adding tests, the LoadDescription function accidentally got called
with the wrong arguments in the main function. This fixes that; a future
CL (uploading shortly) adds more robust tests that would have caught this.

Bug: 389568463, 389069356
Change-Id: Icaf5e83cd8caa9f3975173f8c8ee7d92ef44ee56
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6170638
Commit-Queue: Andy Perelson <ajp@google.com>
Reviewed-by: Brian Ryner <bryner@google.com>
Reviewed-by: Andy Perelson <ajp@google.com>
Auto-Submit: Devon Loehr <dloehr@google.com>
changes/38/6170638/4
Devon Loehr 3 months ago committed by LUCI CQ
parent b60b40cc31
commit f546ee068c

@ -218,8 +218,12 @@ def PrintClInfo(cl_index, num_cls, directories, file_paths, description,
print()
def LoadDescription(description_file):
def LoadDescription(description_file, dry_run):
if not description_file:
if not dry_run:
# Parser checks this as well, so should be impossible
raise ValueError(
"Must provide a description file except during dry runs")
return ('Dummy description for dry run.\n'
'directory = $directory')

@ -196,11 +196,21 @@ class SplitClTest(unittest.TestCase):
@mock.patch("gclient_utils.FileRead", return_value="Description")
def testLoadDescription(self, mock_file_read):
# No description provided, use the dummy:
self.assertTrue(split_cl.LoadDescription(None).startswith("Dummy"))
self.assertTrue(
split_cl.LoadDescription(None, True).startswith("Dummy"))
self.assertEqual(mock_file_read.call_count, 0)
# Description file provided, load it
self.assertEqual(split_cl.LoadDescription("SomeFile.txt"),
# No description provided during a real run
self.assertRaises(ValueError, split_cl.LoadDescription, None, False)
self.assertEqual(mock_file_read.call_count, 0)
# Description file provided, load it regardless of dry run
self.assertEqual(split_cl.LoadDescription("SomeFile.txt", False),
"Description")
self.assertEqual(mock_file_read.call_count, 1)
mock_file_read.reset_mock()
self.assertEqual(split_cl.LoadDescription("SomeFile.txt", True),
"Description")
self.assertEqual(mock_file_read.call_count, 1)

Loading…
Cancel
Save