From c23a10afe726b3f1f5f496e67312c7c76beaf8c8 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Sun, 28 Jul 2024 11:36:46 -0700 Subject: [PATCH 1/4] Fix typo douple -> double --- tests/test_apply_format.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_apply_format.py b/tests/test_apply_format.py index 0c62f5a..f0e65c6 100644 --- a/tests/test_apply_format.py +++ b/tests/test_apply_format.py @@ -159,8 +159,8 @@ def test_two_files(self): # Two files need changes. self.repo.write_file(data.FILENAME_ALT, data.CODE) output = self.apply_format_output() - douple_patch = data.PATCH + data.PATCH.replace(data.FILENAME, data.FILENAME_ALT) - self.assertEqual(self.simplify_diff(output), douple_patch) + double_patch = data.PATCH + data.PATCH.replace(data.FILENAME, data.FILENAME_ALT) + self.assertEqual(self.simplify_diff(output), double_patch) # Stage the second file. Two need changes, one is staged the other isn't. self.repo.add(data.FILENAME_ALT) From b90649d3e1b55f7e30095b670167a342ad509378 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Sun, 28 Jul 2024 11:37:47 -0700 Subject: [PATCH 2/4] tests: Print output when git command fails This helps debug what is happening when a git command fails in a test. --- tests/mixin_git.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/mixin_git.py b/tests/mixin_git.py index 84169f5..8c490ce 100644 --- a/tests/mixin_git.py +++ b/tests/mixin_git.py @@ -68,7 +68,11 @@ def check_output(self, *args, **kwargs): kwargs['stderr'] = subprocess.STDOUT kwargs['universal_newlines'] = True with self.work_dir(): - return subprocess.check_output(args, **kwargs) + try: + return subprocess.check_output(args, **kwargs) + except subprocess.CalledProcessError as exc: + exc.add_note(exc.output) + raise exc def git_check_call(self, *args): return self.check_call('git', *args) From 8c6e90198194c6e5922bbf5f0dd5ff14a07da585 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Sun, 28 Jul 2024 11:38:19 -0700 Subject: [PATCH 3/4] tests: Allow file protocol when creating git submodules for tests Newer versions of git don't allow this by default. Specify the appropriate config option on the command line to allow it. --- tests/mixin_scripts_repo.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/mixin_scripts_repo.py b/tests/mixin_scripts_repo.py index 7c45e4b..db202b3 100644 --- a/tests/mixin_scripts_repo.py +++ b/tests/mixin_scripts_repo.py @@ -137,7 +137,8 @@ def setUp(self): self.repo = GitRepository(worktree_branch_path) # The new module may have submodules, make sure they are synced. - self.repo.git_check_output('submodule', 'update', '--init', '--recursive') + self.repo.git_check_output('-c', 'protocol.file.allow=always', + 'submodule', 'update', '--init', '--recursive') # If case we cloned the current repo but there's unstaged content. self.update_scripts() @@ -169,7 +170,8 @@ def config_repo(self): def new_repo_with_submodule(self): repo = self.new_repo() - repo.git_check_output('submodule', 'add', self.this_repo_path(), self.SUBMODULE_DIR) + repo.git_check_output('-c', 'protocol.file.allow=always', 'submodule', 'add', + self.this_repo_path(), self.SUBMODULE_DIR) repo.commit() return repo From e1dbe132dd798572293eb5a59c515df108794122 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Sun, 28 Jul 2024 11:39:01 -0700 Subject: [PATCH 4/4] Ignore exit code of clang-format-diff Starting with 18.x, clang-format-diff exits with a nonzero exit code if there was a diff to be applied. This breaks the apply-format script because it will exit without printing the diff. Instead, ignore the exit code and proceed to print the diff. Closes: #33 --- apply-format | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apply-format b/apply-format index 8bcc839..94e019e 100755 --- a/apply-format +++ b/apply-format @@ -325,8 +325,7 @@ else # Diff-only. -p1 \ -style="$style" \ -iregex="$exclusions_regex"'.*\.(c|cpp|cxx|cc|h|hpp|m|mm|js|java)' \ - > "$patch_dest" \ - || exit 1 + > "$patch_dest" if [ "$apply_to_staged" = true ]; then if [ ! -s "$patch_dest" ]; then