Skip to content
Snippets Groups Projects
Commit 9e5c2556 authored by Simon Rose's avatar Simon Rose
Browse files

E3-731: Add tests for double installs

parent 0a949ace
No related branches found
No related tags found
1 merge request!98E3-731: Improve tests
......@@ -401,13 +401,14 @@ else
ifeq ($(shell echo "${LIBVERSION}" | grep -v -E "^$(VERSIONREGEX)\$$"),)
install:: build
@test ! -d ${MODULE_LOCATION}/lib/${T_A} || \
(echo -e "Error: ${MODULE_LOCATION}/lib/${T_A} already exists.\nNote: If you really want to overwrite then uninstall first."; false)
$(if $(wildcard ${MODULE_LOCATION}/lib/${T_A}),$(error ${MODULE_LOCATION}/lib/${T_A} already exists. If you really want to overwrite then uninstall first.))
else
install:: build
@test ! -d ${MODULE_LOCATION}/lib/${T_A} || \
(echo -e "Warning: Re-installing ${MODULE_LOCATION}/lib/${T_A}"; \
$(RMDIR) ${MODULE_LOCATION}/lib/${T_A})
$(if $(wildcard ${MODULE_LOCATION}/lib/${T_A}),\
$(warning Re-installing ${MODULE_LOCATION}/lib/${T_A})\
$(RMDIR) ${MODULE_LOCATION}/lib/${T_A}\
)
endif
install build debug:: O.${EPICSVERSION}_${T_A}
......
......@@ -591,3 +591,52 @@ def test_build_fails_if_nth_architecture_fails(wrapper: Wrapper, archs, failing_
RE_MISSING_FILE.format(filename=re.escape(f"nonexistent_{failing_arch}.o")),
errs,
)
def test_double_install_fails(wrapper: Wrapper):
RE_ERR_MOD_VER_EXISTS = ".*{module}/{version}.* already exists"
rc, *_ = wrapper.run_make("install", module_version=MODULE_VERSION)
assert rc == 0
rc, _, errs = wrapper.run_make("install", module_version=MODULE_VERSION)
assert rc == 2
assert re.search(
RE_ERR_MOD_VER_EXISTS.format(
module=re.escape(wrapper.name), version=re.escape(MODULE_VERSION)
),
errs,
)
def test_double_install_test_version_succeeds(wrapper: Wrapper):
RE_WARN_MOD_VER_EXISTS = "Re-installing .*{module}/{version}.*"
test_version = "test"
wrapper.write_dot_local_data("CONFIG_MODULE", {"E3_MODULE_VERSION": test_version})
cell_path = wrapper.get_env_var("E3_MODULES_INSTALL_LOCATION")
wrapper.add_file("header.h")
rc, _, errs = wrapper.run_make("install")
assert rc == 0
assert not re.search(
RE_WARN_MOD_VER_EXISTS.format(
module=re.escape(wrapper.name), version=test_version
),
errs,
)
assert not (Path(cell_path) / "include" / "header.h").is_file()
wrapper.add_var_to_module_makefile("HEADERS", "header.h")
rc, _, errs = wrapper.run_make("install")
assert rc == 0
assert re.search(
RE_WARN_MOD_VER_EXISTS.format(
module=re.escape(wrapper.name), version=test_version
),
errs,
)
assert (Path(cell_path) / "include" / "header.h").is_file()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment