]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Speed up tests even more (#2205)
authorRichard Si <63936253+ichard26@users.noreply.github.com>
Sat, 8 May 2021 09:34:25 +0000 (05:34 -0400)
committerGitHub <noreply@github.com>
Sat, 8 May 2021 09:34:25 +0000 (11:34 +0200)
There's three optimizations in this commit:

1. Don't check if Black's output is stable or equivalant if no changes
   were made in the first place. It's not like passing the same code
   (for both source and actual) through black.assert_equivalent or
   black.assert_stable is useful. It's not a big deal for the smaller
   tests, but it eats a lot of time in tests/test_format.py since
   its test cases are big. This is also closer to how Black works IRL.

2. Use a smaller file for `test_root_logger_not_used_directly` since
   the logging it's checking happens during blib2to3's startup so the
   file doesn't really matter.

3. If we're checking a file is formatting (i.e. test_source_is_formatted)
   don't run Black over it again with `black.format_file_in_place`.
   `tests/test_format.py::TestSimpleFormat.check_file` is good enough.

tests/test_black.py
tests/test_format.py

index 29a0731dd9d467dc0bc53a229e17dedf84b87536..347eaf621fe45b2a711e001a3796bce013c00525 100644 (file)
@@ -175,8 +175,9 @@ class BlackTestCase(BlackBaseTestCase):
         )
         self.assertEqual(result.exit_code, 0)
         self.assertFormatEqual(expected, result.output)
-        black.assert_equivalent(source, result.output)
-        black.assert_stable(source, result.output, DEFAULT_MODE)
+        if source != result.output:
+            black.assert_equivalent(source, result.output)
+            black.assert_stable(source, result.output, DEFAULT_MODE)
 
     def test_piping_diff(self) -> None:
         diff_header = re.compile(
@@ -1904,7 +1905,7 @@ class BlackTestCase(BlackBaseTestCase):
             critical=fail,
             log=fail,
         ):
-            ff(THIS_FILE)
+            ff(THIS_DIR / "util.py")
 
     def test_invalid_config_return_code(self) -> None:
         tmp_file = Path(black.dump_to_file())
index e59d5218d2e84bd457929e9ccff73f32a1eb1f6a..5c78afe0ba686f35fdfc0de44779c6ecaa115371 100644 (file)
@@ -7,7 +7,6 @@ from parameterized import parameterized
 from tests.util import (
     BlackBaseTestCase,
     fs,
-    ff,
     DEFAULT_MODE,
     dump_to_stderr,
     read_data,
@@ -135,11 +134,11 @@ class TestSimpleFormat(BlackBaseTestCase):
     def test_source_is_formatted(self, filename: str) -> None:
         path = THIS_DIR.parent / filename
         self.check_file(str(path), DEFAULT_MODE, data=False)
-        self.assertFalse(ff(path))
 
     def check_file(self, filename: str, mode: black.Mode, *, data: bool = True) -> None:
         source, expected = read_data(filename, data=data)
         actual = fs(source, mode=mode)
         self.assertFormatEqual(expected, actual)
-        black.assert_equivalent(source, actual)
-        black.assert_stable(source, actual, mode)
+        if source != actual:
+            black.assert_equivalent(source, actual)
+            black.assert_stable(source, actual, mode)