Skip to content

Commit

Permalink
simplified test_package
Browse files Browse the repository at this point in the history
No need to actually compile something with this tool
we simply need to know if it runs.

The win_bash for the run needs to be set explicitly
due to the conf not working properly in the test_package
see conan-io/conan#11975
  • Loading branch information
j.spijker@ultimaker.com authored and jellespijker committed Sep 5, 2022
1 parent 6aeafa2 commit d9ee4de
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 118 deletions.
14 changes: 0 additions & 14 deletions recipes/autoconf/all/test_package/Makefile.in

This file was deleted.

44 changes: 13 additions & 31 deletions recipes/autoconf/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,29 @@
from conans import AutoToolsBuildEnvironment, ConanFile, tools
from conan.tools.microsoft import is_msvc
import contextlib
import os
import shutil
from os import environ

required_conan_version = ">=1.45.0"
from conan import ConanFile
from conan.tools.build import can_run

required_conan_version = ">=1.50.0"


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
exports_sources = "configure.ac", "config.h.in", "Makefile.in", "test_package_c.c", "test_package_cpp.cpp",
generators = "VirtualBuildEnv"
test_type = "explicit"
win_bash = True

@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)

def build_requirements(self):
self.build_requires(self.tested_reference_str)
if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"):
self.build_requires("msys2/cci.latest")

@contextlib.contextmanager
def _build_context(self):
if is_msvc(self):
with tools.vcvars(self):
with tools.environment_append({"CC": "cl -nologo", "CXX": "cl -nologo",}):
yield
else:
yield
self.tool_requires(self.tested_reference_str)
if self._settings_build.os == "Windows" and not environ.get("CONAN_BASH_PATH"):
self.tool_requires("msys2/cci.latest")

def build(self):
for src in self.exports_sources:
shutil.copy(os.path.join(self.source_folder, src), self.build_folder)
self.run("{} --verbose".format(os.environ["AUTOCONF"]),
win_bash=tools.os_info.is_windows, run_environment=True)
self.run("{} --help".format(os.path.join(self.build_folder, "configure").replace("\\", "/")),
win_bash=tools.os_info.is_windows, run_environment=True)
autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
with self._build_context():
autotools.configure()
autotools.make()
pass

def test(self):
if not tools.cross_building(self):
self.run(os.path.join(".", "test_package"), run_environment=True)
if can_run(self):
self.run("autoconf --version", run_environment=True, env="conanbuild", win_bash=self.settings.os == "Windows")
23 changes: 0 additions & 23 deletions recipes/autoconf/all/test_package/config.h.in

This file was deleted.

25 changes: 0 additions & 25 deletions recipes/autoconf/all/test_package/configure.ac

This file was deleted.

8 changes: 0 additions & 8 deletions recipes/autoconf/all/test_package/test_package_c.c

This file was deleted.

17 changes: 0 additions & 17 deletions recipes/autoconf/all/test_package/test_package_cpp.cpp

This file was deleted.

0 comments on commit d9ee4de

Please sign in to comment.