Skip to content

Commit

Permalink
add test for #7968, use format string (#7972)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgsogo committed Oct 30, 2020
1 parent 706e9b9 commit e0a53a1
Showing 1 changed file with 75 additions and 72 deletions.
147 changes: 75 additions & 72 deletions conans/test/functional/hooks/hook_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,132 +23,134 @@ def package_info(self):
def pre_export(output, conanfile, conanfile_path, reference, **kwargs):
assert conanfile
assert conanfile.recipe_folder == os.path.dirname(conanfile_path)
output.info("conanfile_path=%s" % conanfile_path)
output.info("reference=%s" % reference.full_str())
output.info("conanfile_path={}".format(conanfile_path))
output.info("reference={}".format(reference.full_str()))
def post_export(output, conanfile, conanfile_path, reference, **kwargs):
assert conanfile
# In this case the recipe folder is different than the final export folder
# TODO: If export_folder will be defined it should match
assert conanfile.recipe_folder != os.path.dirname(conanfile_path)
output.info("conanfile_path=%s" % conanfile_path)
output.info("reference=%s" % reference.full_str())
output.info("conanfile_path={}".format(conanfile_path))
output.info("reference={}".format(reference.full_str()))
def pre_source(output, conanfile, conanfile_path, **kwargs):
assert conanfile
assert conanfile.recipe_folder == os.path.dirname(conanfile_path)
output.info("conanfile_path=%s" % conanfile_path)
output.info("conanfile_path={}".format(conanfile_path))
if conanfile.in_local_cache:
output.info("reference=%s" % kwargs["reference"].full_str())
output.info("reference={}".format(kwargs["reference"].full_str()))
def post_source(output, conanfile, conanfile_path, **kwargs):
assert conanfile
assert conanfile.recipe_folder == os.path.dirname(conanfile_path)
output.info("conanfile_path=%s" % conanfile_path)
output.info("conanfile_path={}".format(conanfile_path))
if conanfile.in_local_cache:
output.info("reference=%s" % kwargs["reference"].full_str())
output.info("reference={}".format(kwargs["reference"].full_str()))
def pre_build(output, conanfile, **kwargs):
assert conanfile
if conanfile.in_local_cache:
output.info("reference=%s" % kwargs["reference"].full_str())
output.info("package_id=%s" % kwargs["package_id"])
output.info("reference={}".format(kwargs["reference"].full_str()))
output.info("package_id={}".format(kwargs["package_id"]))
else:
output.info("conanfile_path=%s" % kwargs["conanfile_path"])
output.info("conanfile_path={}".format(kwargs["conanfile_path"]))
def post_build(output, conanfile, **kwargs):
assert conanfile
if conanfile.in_local_cache:
output.info("reference=%s" % kwargs["reference"].full_str())
output.info("package_id=%s" % kwargs["package_id"])
output.info("reference={}".format(kwargs["reference"].full_str()))
output.info("package_id={}".format(kwargs["package_id"]))
else:
output.info("conanfile_path=%s" % kwargs["conanfile_path"])
output.info("conanfile_path={}".format(kwargs["conanfile_path"]))
def pre_package(output, conanfile, conanfile_path, **kwargs):
assert conanfile
assert conanfile.recipe_folder == os.path.dirname(conanfile_path)
output.info("conanfile_path=%s" % conanfile_path)
output.info("conanfile_path={}".format(conanfile_path))
if conanfile.in_local_cache:
output.info("reference=%s" % kwargs["reference"].full_str())
output.info("package_id=%s" % kwargs["package_id"])
output.info("reference={}".format(kwargs["reference"].full_str()))
output.info("package_id={}".format(kwargs["package_id"]))
def post_package(output, conanfile, conanfile_path, **kwargs):
assert conanfile
assert conanfile.recipe_folder == os.path.dirname(conanfile_path)
output.info("conanfile_path=%s" % conanfile_path)
output.info("conanfile_path={}".format(conanfile_path))
if conanfile.in_local_cache:
output.info("reference=%s" % kwargs["reference"].full_str())
output.info("package_id=%s" % kwargs["package_id"])
output.info("reference={}".format(kwargs["reference"].full_str()))
output.info("package_id={}".format(kwargs["package_id"]))
def pre_upload(output, conanfile_path, reference, remote, **kwargs):
output.info("conanfile_path=%s" % conanfile_path)
output.info("reference=%s" % reference.full_str())
output.info("remote.name=%s" % remote.name)
output.info("conanfile_path={}".format(conanfile_path))
output.info("reference={}".format(reference.full_str()))
output.info("remote.name={}".format(remote.name))
def post_upload(output, conanfile_path, reference, remote, **kwargs):
output.info("conanfile_path=%s" % conanfile_path)
output.info("reference=%s" % reference.full_str())
output.info("remote.name=%s" % remote.name)
output.info("conanfile_path={}".format(conanfile_path))
output.info("reference={}".format(reference.full_str()))
output.info("remote.name={}".format(remote.name))
def pre_upload_recipe(output, conanfile_path, reference, remote, **kwargs):
output.info("conanfile_path=%s" % conanfile_path)
output.info("reference=%s" % reference.full_str())
output.info("remote.name=%s" % remote.name)
output.info("conanfile_path={}".format(conanfile_path))
output.info("reference={}".format(reference.full_str()))
output.info("remote.name={}".format(remote.name))
def post_upload_recipe(output, conanfile_path, reference, remote, **kwargs):
output.info("conanfile_path=%s" % conanfile_path)
output.info("reference=%s" % reference.full_str())
output.info("remote.name=%s" % remote.name)
output.info("conanfile_path={}".format(conanfile_path))
output.info("reference={}".format(reference.full_str()))
output.info("remote.name={}".format(remote.name))
def pre_upload_package(output, conanfile_path, reference, package_id, remote, **kwargs):
output.info("conanfile_path=%s" % conanfile_path)
output.info("reference=%s" % reference.full_str())
output.info("package_id=%s" % package_id)
output.info("remote.name=%s" % remote.name)
output.info("conanfile_path={}".format(conanfile_path))
output.info("reference={}".format(reference.full_str()))
output.info("package_id={}".format(package_id))
output.info("remote.name={}".format(remote.name))
def post_upload_package(output, conanfile_path, reference, package_id, remote, **kwargs):
output.info("conanfile_path=%s" % conanfile_path)
output.info("reference=%s" % reference.full_str())
output.info("package_id=%s" % package_id)
output.info("remote.name=%s" % remote.name)
output.info("conanfile_path={}".format(conanfile_path))
output.info("reference={}".format(reference.full_str()))
output.info("package_id={}".format(package_id))
output.info("remote.name={}".format(remote.name))
def pre_download(output, reference, remote, **kwargs):
output.info("reference=%s" % reference.full_str())
output.info("remote.name=%s" % remote.name)
output.info("reference={}".format(reference.full_str()))
output.info("remote.name={}".format(remote.name))
def post_download(output, conanfile_path, reference, remote, **kwargs):
output.info("conanfile_path=%s" % conanfile_path)
output.info("reference=%s" % reference.full_str())
output.info("remote.name=%s" % remote.name)
output.info("conanfile_path={}".format(conanfile_path))
output.info("reference={}".format(reference.full_str()))
output.info("remote.name={}".format(remote.name))
def pre_download_recipe(output, reference, remote, **kwargs):
output.info("reference=%s" % reference.full_str())
output.info("remote.name=%s" % remote.name)
output.info("reference={}".format(reference.full_str()))
output.info("remote.name={}".format(remote.name))
def post_download_recipe(output, conanfile_path, reference, remote, **kwargs):
output.info("conanfile_path=%s" % conanfile_path)
output.info("reference=%s" % reference.full_str())
output.info("remote.name=%s" % remote.name)
def pre_download_package(output, conanfile_path, reference, package_id, remote, **kwargs):
output.info("conanfile_path=%s" % conanfile_path)
output.info("reference=%s" % reference.full_str())
output.info("package_id=%s" % package_id)
output.info("remote.name=%s" % remote.name)
def post_download_package(output, conanfile_path, reference, package_id, remote, **kwargs):
output.info("conanfile_path=%s" % conanfile_path)
output.info("reference=%s" % reference.full_str())
output.info("package_id=%s" % package_id)
output.info("remote.name=%s" % remote.name)
output.info("conanfile_path={}".format(conanfile_path))
output.info("reference={}".format(reference.full_str()))
output.info("remote.name={}".format(remote.name))
def pre_download_package(output, conanfile, conanfile_path, reference, package_id, remote, **kwargs):
output.info("conanfile.name={}".format(conanfile.name))
output.info("conanfile_path={}".format(conanfile_path))
output.info("reference={}".format(reference.full_str()))
output.info("package_id={}".format(package_id))
output.info("remote.name={}".format(remote.name))
def post_download_package(output, conanfile, conanfile_path, reference, package_id, remote, **kwargs):
output.info("conanfile.name={}".format(conanfile.name))
output.info("conanfile_path={}".format(conanfile_path))
output.info("reference={}".format(reference.full_str()))
output.info("package_id={}".format(package_id))
output.info("remote.name={}".format(remote.name))
def pre_package_info(output, conanfile, reference, **kwargs):
output.info("reference=%s" % reference.full_str())
output.info("conanfile.cpp_info.defines=%s" % conanfile.cpp_info.defines)
output.info("reference={}".format(reference.full_str()))
output.info("conanfile.cpp_info.defines={}".format(conanfile.cpp_info.defines))
def post_package_info(output, conanfile, reference, **kwargs):
output.info("reference=%s" % reference.full_str())
output.info("conanfile.cpp_info.defines=%s" % conanfile.cpp_info.defines)
output.info("reference={}".format(reference.full_str()))
output.info("conanfile.cpp_info.defines={}".format(conanfile.cpp_info.defines))
"""

HEADER = "[HOOK - complete_hook] {method_name}():"
Expand Down Expand Up @@ -186,8 +188,7 @@ def test_default_hook(self):
def test_complete_hook(self):
server = TestServer([], users={"danimtb": "pass"})
client = TestClient(servers={"default": server}, users={"default": [("danimtb", "pass")]})
hook_path = os.path.join(client.cache.hooks_path, "complete_hook",
"complete_hook.py")
hook_path = os.path.join(client.cache.hooks_path, "complete_hook", "complete_hook.py")
client.save({hook_path: complete_hook, "conanfile.py": conanfile_basic})
conanfile_path = os.path.join(client.current_folder, "conanfile.py")
conanfile_cache_path = client.cache.package_layout(
Expand Down Expand Up @@ -388,6 +389,8 @@ def _check_download_recipe(self, conanfile_cache_path, out):
"remote.name=default", out)

def _check_download_package(self, conanfile_cache_path, out):
self.assertIn("[HOOK - complete_hook/complete_hook.py] pre_download_package(): "
"conanfile.name=basic", out)
self.assertIn("[HOOK - complete_hook/complete_hook.py] pre_download_package(): "
"conanfile_path=%s" % conanfile_cache_path, out)
self.assertIn("[HOOK - complete_hook/complete_hook.py] pre_download_package(): "
Expand All @@ -396,6 +399,8 @@ def _check_download_package(self, conanfile_cache_path, out):
"package_id=%s" % PACKAGE_ID, out)
self.assertIn("[HOOK - complete_hook/complete_hook.py] pre_download_package(): "
"remote.name=default", out)
self.assertIn("[HOOK - complete_hook/complete_hook.py] post_download_package(): "
"conanfile.name=basic", out)
self.assertIn("[HOOK - complete_hook/complete_hook.py] post_download_package(): "
"conanfile_path=%s" % conanfile_cache_path, out)
self.assertIn("[HOOK - complete_hook/complete_hook.py] post_download_package(): "
Expand All @@ -418,10 +423,8 @@ def _check_package_info(self, out):
def test_import_hook(self):
client = TestClient()
hook_path = os.path.join(client.cache.hooks_path, "my_hook", "my_hook.py")
init_path = os.path.join(client.cache.hooks_path, "my_hook", "custom_module",
"__init__.py")
custom_path = os.path.join(client.cache.hooks_path, "my_hook", "custom_module",
"custom.py")
init_path = os.path.join(client.cache.hooks_path, "my_hook", "custom_module", "__init__.py")
custom_path = os.path.join(client.cache.hooks_path, "my_hook", "custom_module", "custom.py")
client.save({init_path: "",
custom_path: custom_module,
hook_path: my_hook,
Expand Down

0 comments on commit e0a53a1

Please sign in to comment.