From d7d82215816cc0e2932a73a84108eacb0d36414c Mon Sep 17 00:00:00 2001 From: Fumitoshi Ukai Date: Wed, 3 Jul 2024 00:58:07 +0000 Subject: [PATCH] gn_helper: ignore spaces on gn lines Change-Id: I2f676411a5282c938fc1d095acbbde0bbe6efde3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5668281 Commit-Queue: Junji Watanabe Auto-Submit: Fumitoshi Ukai Reviewed-by: Junji Watanabe Commit-Queue: Fumitoshi Ukai --- gn_helper.py | 2 +- tests/gn_helper_test.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gn_helper.py b/gn_helper.py index fedc9e0ef0..29e8e49b09 100644 --- a/gn_helper.py +++ b/gn_helper.py @@ -48,7 +48,7 @@ def lines(output_dir): yield line_without_comment -_gn_arg_pattern = re.compile(r"(^|\s)([^=\s]*)\s*=\s*(\S*)\s*$") +_gn_arg_pattern = re.compile(r"(^|\s*)([^=\s]*)\s*=\s*(\S*)\s*$") def args(output_dir): diff --git a/tests/gn_helper_test.py b/tests/gn_helper_test.py index 9c03f60eb1..f85cce4242 100644 --- a/tests/gn_helper_test.py +++ b/tests/gn_helper_test.py @@ -67,6 +67,21 @@ class GnHelperTest(trial_dir.TestCase): ('use_remoteexec', 'true'), ]) + def test_args_spaces(self): + out_dir = os.path.join('out', 'dir') + # Make sure nested import directives work. This is based on the + # reclient test. + write(os.path.join(out_dir, 'args.gn'), 'import("//out/common.gni")') + write(os.path.join('out', 'common.gni'), 'import("common_2.gni")') + write(os.path.join('out', 'common_2.gni'), ' use_remoteexec = true ') + + lines = list(gn_helper.args(out_dir)) + + # The test will only pass if both imports work and + # 'use_remoteexec=true' is seen. + self.assertListEqual(lines, [ + ('use_remoteexec', 'true'), + ]) if __name__ == '__main__': unittest.main()