From 8f52888593e1642024050e380d52b4842f6b2f33 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Fri, 11 Jun 2021 09:59:39 -0400 Subject: [PATCH 1/4] Increase the visibility of the static methods in FirebaseTest to 'public' --- testing/test_framework/src/firebase_test_framework.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/testing/test_framework/src/firebase_test_framework.h b/testing/test_framework/src/firebase_test_framework.h index 6466a4259..5f4e1fa18 100644 --- a/testing/test_framework/src/firebase_test_framework.h +++ b/testing/test_framework/src/firebase_test_framework.h @@ -236,6 +236,10 @@ class FirebaseTest : public testing::Test { // fully-automated tests should be run. bool AreInteractiveTestsAllowed(); + // Give the static helper methods "public" visibility so that they can be used + // by helper functions defined outside of subclasses of `FirebaseTest`, such as + // functions defined in anonymous namespaces. + public: // Get a persistent string value that was previously set via // SetPersistentString. Returns true if the value was set, false if not or if // something went wrong. From e666adf6d27800137a5fedd9fc074413632f0c68 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Fri, 11 Jun 2021 13:07:18 -0400 Subject: [PATCH 2/4] Temporarily cherry-pick #462 so I can figure out why format_code.py is complaining --- scripts/format_code.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/scripts/format_code.py b/scripts/format_code.py index 2a2499140..a8a184d67 100755 --- a/scripts/format_code.py +++ b/scripts/format_code.py @@ -28,6 +28,7 @@ because -noformat_file was set. 2: The application wasn't configured properly and could not execute. """ +import difflib import io import os import subprocess @@ -58,6 +59,30 @@ """ # Functions: +def get_formatting_diff_lines(filename): + """Calculates and returns a printable diff of the formatting changes that + would be applied to the given file by clang-format. + + Args: + filename (string): path to the file whose formatting diff to calculate. + + Returns: + Iterable[str]: The diff of the formatted file against the original file; + each string in the returned iterable is a "line" of the diff; they could + be printed individually or joined into a single string using something + like os.linesep.join(diff_lines), where `diff_lines` is the return value. + """ + args = ['clang-format', '-style=file', filename] + result = subprocess.run(args, stdout=subprocess.PIPE, check=True) + + formatted_lines = [line.rstrip('\r\n') + for line in result.stdout.decode('utf8', errors='replace').splitlines()] + with open(filename, 'rt', encoding='utf8', errors='replace') as f: + original_lines = [line.rstrip('\r\n') for line in f] + + return [line.rstrip() + for line in difflib.unified_diff(original_lines, formatted_lines)] + def does_file_need_formatting(filename): """Executes clang-format on the file to determine if it includes any formatting changes the user needs to fix. @@ -246,6 +271,10 @@ def main(argv): count += 1 if FLAGS.verbose: print(' - Requires reformatting: "{0}"'.format(filename)) + print('------ BEGIN FORMATTING DIFF OF {0}'.format(filename)) + for diff_line in get_formatting_diff_lines(filename): + print(diff_line) + print('------ END FORMATTING DIFF OF {0}'.format(filename)) if FLAGS.verbose: print(' > Done. {0} file(s) need formatting.'.format(count)) else: From 4694ac6f80334b8571e8cf58f98f0d042c018359 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Fri, 11 Jun 2021 13:08:28 -0400 Subject: [PATCH 3/4] Revert "Temporarily cherry-pick #462 so I can figure out why format_code.py is complaining" This reverts commit e666adf6d27800137a5fedd9fc074413632f0c68. --- scripts/format_code.py | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/scripts/format_code.py b/scripts/format_code.py index a8a184d67..2a2499140 100755 --- a/scripts/format_code.py +++ b/scripts/format_code.py @@ -28,7 +28,6 @@ because -noformat_file was set. 2: The application wasn't configured properly and could not execute. """ -import difflib import io import os import subprocess @@ -59,30 +58,6 @@ """ # Functions: -def get_formatting_diff_lines(filename): - """Calculates and returns a printable diff of the formatting changes that - would be applied to the given file by clang-format. - - Args: - filename (string): path to the file whose formatting diff to calculate. - - Returns: - Iterable[str]: The diff of the formatted file against the original file; - each string in the returned iterable is a "line" of the diff; they could - be printed individually or joined into a single string using something - like os.linesep.join(diff_lines), where `diff_lines` is the return value. - """ - args = ['clang-format', '-style=file', filename] - result = subprocess.run(args, stdout=subprocess.PIPE, check=True) - - formatted_lines = [line.rstrip('\r\n') - for line in result.stdout.decode('utf8', errors='replace').splitlines()] - with open(filename, 'rt', encoding='utf8', errors='replace') as f: - original_lines = [line.rstrip('\r\n') for line in f] - - return [line.rstrip() - for line in difflib.unified_diff(original_lines, formatted_lines)] - def does_file_need_formatting(filename): """Executes clang-format on the file to determine if it includes any formatting changes the user needs to fix. @@ -271,10 +246,6 @@ def main(argv): count += 1 if FLAGS.verbose: print(' - Requires reformatting: "{0}"'.format(filename)) - print('------ BEGIN FORMATTING DIFF OF {0}'.format(filename)) - for diff_line in get_formatting_diff_lines(filename): - print(diff_line) - print('------ END FORMATTING DIFF OF {0}'.format(filename)) if FLAGS.verbose: print(' > Done. {0} file(s) need formatting.'.format(count)) else: From 53f23565ebb2ccfdf3f2cb4f2e9a1fd903efafd5 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Fri, 11 Jun 2021 13:09:22 -0400 Subject: [PATCH 4/4] Fix formatting issues in firebase_test_framework.h reported by clang-format --- testing/test_framework/src/firebase_test_framework.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testing/test_framework/src/firebase_test_framework.h b/testing/test_framework/src/firebase_test_framework.h index 5f4e1fa18..8975565e2 100644 --- a/testing/test_framework/src/firebase_test_framework.h +++ b/testing/test_framework/src/firebase_test_framework.h @@ -236,9 +236,9 @@ class FirebaseTest : public testing::Test { // fully-automated tests should be run. bool AreInteractiveTestsAllowed(); - // Give the static helper methods "public" visibility so that they can be used - // by helper functions defined outside of subclasses of `FirebaseTest`, such as - // functions defined in anonymous namespaces. + // Give the static helper methods "public" visibility so that they can be used + // by helper functions defined outside of subclasses of `FirebaseTest`, such + // as functions defined in anonymous namespaces. public: // Get a persistent string value that was previously set via // SetPersistentString. Returns true if the value was set, false if not or if