Commit 1c4b1278 authored by Chris Lamb's avatar Chris Lamb 💬

Try and ensure that new test data files are generated dynamically, ie. at...

Try and ensure that new test data files are generated dynamically, ie. at least no new ones are added without "good" reasons.
parent 02497c9c
......@@ -18,11 +18,225 @@
# along with diffoscope. If not, see <>.
import os
import glob
import diffoscope
import subprocess
from import skip_unless_tools_exist
# Data files we would prefer to generate dynamically
# Outputs
# Outputs
def test_code_is_black_clean():
......@@ -34,3 +248,40 @@ def test_code_is_black_clean():
assert len(output) == 0
def test_does_not_add_new_test_files():
For a variety of reasons we are now prefering to generate any test data
dynamically (via pytest fixtures, etc.) rather than committing and shipping
such files.
Exceptions to this may be appropriate (or even required) but this test
ensures that test files that could be dynamically generated are not added
"automatically", for example by following previous/older commits.
test_dir = os.path.join(os.path.dirname(__file__), 'data')
seen = set()
for x in glob.iglob(os.path.join(test_dir, '**'), recursive=True):
if os.path.isdir(x):
# Strip off common prefix
x = x[len(test_dir) + 1 :]
# Skip some known expected diff filename patterns
if (
or x.endswith('_diffs')
or x.endswith('.diff')
or '_diff_' in x
or 'diff.' in x
assert seen - ALLOWED_TEST_FILES - {''} == set()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment