Newer
Older
}
"""
PATCH_FILE = """
diff --git database.db database.db
index 1806ff6..8701832 100644
--- database.db
+++ database.db
@@ -1,3 +1,3 @@
record(ai, "TEST") {{
def create_patch_file(path, desc):
path.parent.mkdir(parents=True, exist_ok=True)
with open(path, "w") as f:
f.write(PATCH_FILE.format(desc=desc))
@pytest.mark.parametrize(
"wrapper",
[{"templates": "database.db", "sources": "", "dbds": "", "headers": ""}],
indirect=True,
)
def test_patch(wrapper):
db_path = wrapper / TEST_MODULE_NAME / "database.db"
with open(db_path, "w") as f:
f.write(DB_FILE)
patch_dir = wrapper / "patch" / "Site"
create_patch_file(patch_dir / MODULE_VERSION / "apply.p0.patch", "OK")
create_patch_file(
patch_dir / MODULE_VERSION_NO_BUILD / "dont-apply.p0.patch", "Bad"
)
create_patch_file(patch_dir / (MODULE_VERSION + "-dont-apply.p0.patch"), "Bad")
assert "You are in the local source mode" in outs.decode("utf-8")
rc, _, _ = run_make(wrapper, "patch", E3_MODULE_VERSION=MODULE_VERSION)
db_contents = f.read()
assert 'field(DESC, "OK")' in db_contents
rc, _, _ = run_make(wrapper, "build", E3_MODULE_VERSION=MODULE_VERSION)
assert any((wrapper / TEST_MODULE_NAME).glob("O.*"))
rc, _, _ = run_make(wrapper, "cellinstall", E3_MODULE_VERSION=MODULE_VERSION)
assert any((wrapper / "cellMods").glob("**/*.db"))
@pytest.mark.parametrize(
"wrapper",
[{"templates": "", "sources": "", "dbds": "nonexistent.dbd", "headers": ""}],
indirect=True,
)
def test_missing_file(wrapper):
# TODO: This should probably be a regex, since the quote marks seem to
# depend on the make version.
assert "No rule to make target `../nonexistent.dbd'" in errs.decode("utf-8")
assert rc == 2