diff --git a/require-ess/tools/expandDBD b/require-ess/tools/expandDBD index 9e894f5b5e67dc930cc1f8db62b16ec2c5929f24..a4eb61d9bf587a20b652b1f74407efe61dcb7e51 100755 --- a/require-ess/tools/expandDBD +++ b/require-ess/tools/expandDBD @@ -39,9 +39,10 @@ def open_dbd_file(current_file, filename, includes=None): if dbd_file is None: print("File '{basename}' not found".format(basename=basename), file=sys.stderr) sys.exit(1) - SCANNED_FILES.add(basename) + if basename != "dbCommon.dbd": + SCANNED_FILES.add(basename) with open(dbd_file, "r") as f: - return [line.strip() for line in f.readlines()] + return [line.rstrip() for line in f.readlines()] def expand_dbd_file(current_file, dbdlines, includes): diff --git a/tests/test_expand_dbd.py b/tests/test_expand_dbd.py index f1384d6d91470be7b4b170175c66c84db8fae255..ee7d081ef2cbcdc7cc4642539476f9c2dc00028c 100644 --- a/tests/test_expand_dbd.py +++ b/tests/test_expand_dbd.py @@ -60,6 +60,23 @@ def test_skip_repeated_includes(tmp_path, expanddbdtcl): assert "Info: skipping duplicate file b.dbd included from" in result.stderr +def test_do_not_skip_repeated_include_common_dbd(tmp_path, expanddbdtcl): + dbd_a = tmp_path / "a.dbd" + dbd_a.write_text("include dbCommon.dbd\ninclude dbCommon.dbd") + + dbd_b = tmp_path / "dbCommon.dbd" + dbd_b.write_text("content") + + result = subprocess.run( + [expanddbdtcl, "-I", str(tmp_path), dbd_a], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + encoding="utf-8", + ) + assert result.returncode == 0 + assert result.stdout == "content\ncontent\n" + + def test_record_names_from_dbds(tmp_path, expanddbdtcl): dbd_a = tmp_path / "a.dbd" dbd_a.write_text("include aRecord.dbd")