From 55c4b3f4e9490e1a401473475cd1eb2a9f6fa1eb Mon Sep 17 00:00:00 2001 From: Simon Rose <simon.rose@ess.eu> Date: Thu, 25 May 2023 15:47:36 +0200 Subject: [PATCH] Fix issue with multiple records that include dbCommon.dbd --- require-ess/tools/expandDBD | 5 +++-- tests/test_expand_dbd.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/require-ess/tools/expandDBD b/require-ess/tools/expandDBD index 9e894f5b..a4eb61d9 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 f1384d6d..ee7d081e 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") -- GitLab