Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/tag tools #7975

Merged
merged 19 commits into from Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions conans/requirements_dev.txt
@@ -1,6 +1,7 @@
nose>=1.3.7, <1.4.0
pytest>=6.1.1, <7.0.0; python_version > '3.0'
pytest>=4.6.11; python_version < '3.0'
pytest-xdist # To launch in N cores with pytest -n
jgsogo marked this conversation as resolved.
Show resolved Hide resolved
parameterized>=0.6.3
mock>=1.3.0, <1.4.0
WebTest>=2.0.18, <2.1.0
Expand Down
3 changes: 3 additions & 0 deletions conans/test/conan_v2/test_default_config.py
@@ -1,6 +1,8 @@
import platform
import unittest

import pytest

from conans.test.utils.conan_v2_tests import ConanV2ModeTestCase


Expand All @@ -27,6 +29,7 @@ def test_package_id_mode(self):
# self.assertEqual(str(t.out).strip(), "semver_direct_mode")

@unittest.skipUnless(platform.system() == "Linux", "OLD ABI is only detected for Linux/gcc")
@pytest.mark.tool_gcc()
def test_default_libcxx(self):
t = self.get_client()
t.run('profile new --detect autodetected')
Expand Down
57 changes: 57 additions & 0 deletions conans/test/conftest.py
@@ -0,0 +1,57 @@
import pytest
from conans.errors import ConanException

from conans.client.tools import vswhere, which

tools_available = [
'cmake',
'gcc', 'clang', 'visual_studio',
'autotools', 'pkg_config', 'premake',
'file',
'git', 'svn',
'compiler'
]

if not which("cmake"):
tools_available.remove("cmake")

if not which("gcc"):
tools_available.remove("gcc")
if not which("clang"):
tools_available.remove("clang")
try:
vswhere()
except ConanException:
tools_available.remove("visual_studio")

if not any([x for x in ("gcc", "clang", "visual_sudio") if x in tools_available]):
tools_available.remove("compiler")


if not which("file"):
tools_available.remove("file")

if not which("git"):
tools_available.remove("git")
if not which("svn"):
tools_available.remove("svn")

if not which("autoconf") or not which("automake"):
tools_available.remove("autotools")
if not which("pkg-config"):
tools_available.remove("pkg_config")
if not which("premake"):
tools_available.remove("premake")
jgsogo marked this conversation as resolved.
Show resolved Hide resolved


def tool_check(mark):
tool_name = mark.name[5:]
if tool_name not in tools_available:
pytest.skip("required {} not satisfied".format(tool_name))
jgsogo marked this conversation as resolved.
Show resolved Hide resolved


def pytest_runtest_setup(item):
# Every mark is a required tool, some specify a version
for mark in item.iter_markers():
if mark.name.startswith("tool_"):
return tool_check(mark)
Expand Up @@ -2,6 +2,8 @@
import platform
import unittest

import pytest

from conans.client import tools
from conans.model.ref import ConanFileReference, PackageReference
from conans.paths import CONANFILE
Expand Down Expand Up @@ -51,7 +53,8 @@ def _set_deps_info(self, conanfile):
conanfile.deps_cpp_info.exelinkflags.append("exe_link_flag")
conanfile.deps_cpp_info.sysroot = "/path/to/folder"

@unittest.skipUnless(platform.system() == "Linux", "Requires make")
@unittest.skipUnless(platform.system() == "Linux", "Requires Autotools")
@pytest.mark.tool_autotools()
def test_autotools_real_install_dirs(self):
body = gen_function_cpp(name="hello", msg="Hola Mundo!")
header = gen_function_h(name="hello")
Expand Down
1 change: 1 addition & 0 deletions conans/test/functional/build_helpers/cmake_configs_test.py
Expand Up @@ -10,6 +10,7 @@

@attr("slow")
@pytest.mark.slow
@pytest.mark.tool_cmake
class CMakeConfigsTest(unittest.TestCase):

def test_test_package_configs(self):
Expand Down
1 change: 1 addition & 0 deletions conans/test/functional/build_helpers/cmake_flags_test.py
Expand Up @@ -63,6 +63,7 @@ def package_info(self):

@attr("slow")
@pytest.mark.slow
@pytest.mark.tool_cmake
class CMakeFlagsTest(unittest.TestCase):

def _get_line(self, text, begin):
Expand Down
4 changes: 3 additions & 1 deletion conans/test/functional/build_helpers/cmake_folders_test.py
@@ -1,12 +1,14 @@
import os
import unittest

import pytest
from parameterized import parameterized

from conans.test.utils.tools import TestClient
from conans.util.files import load, mkdir


@pytest.mark.slow
@pytest.mark.tool_cmake
class CMakeFoldersTest(unittest.TestCase):

@parameterized.expand([(True, True), (False, True), (True, False), (False, False)])
Expand Down
@@ -1,10 +1,13 @@
import unittest

import pytest

from conans.test.utils.tools import TestClient


class CMakeInstallPackageTest(unittest.TestCase):

@pytest.mark.tool_compiler
def test_patch_config(self):
client = TestClient()
conanfile = """from conans import ConanFile, CMake
Expand Down Expand Up @@ -43,6 +46,7 @@ def package(self):
self.assertIn("ConanException: cmake.patch_config_paths() can't work without package name",
client.out)

@pytest.mark.tool_cmake
def test_install_package(self):
client = TestClient()
conanfile = """from conans import ConanFile, CMake
Expand Down
1 change: 1 addition & 0 deletions conans/test/functional/build_helpers/cmake_targets_test.py
Expand Up @@ -77,6 +77,7 @@ class Alpha(ConanFile):
self.assertIn('set(CONAN_SHARED_LINKER_FLAGS '
'"CharlieFlag BetaFlag ${CONAN_SHARED_LINKER_FLAGS}")', cmake)

@pytest.mark.tool_cmake
def test_header_only(self):
client = TestClient()
client.save({"conanfile.py": conanfile_py,
Expand Down
3 changes: 3 additions & 0 deletions conans/test/functional/build_helpers/cmake_test.py
@@ -1,9 +1,12 @@
import textwrap
import unittest

import pytest

from conans.test.utils.tools import TestClient


@pytest.mark.tool_cmake
class CMakeBuildHelper(unittest.TestCase):
def test_get_version_no_toolchain(self):
client = TestClient()
Expand Down
3 changes: 3 additions & 0 deletions conans/test/functional/build_helpers/pkg_config_test.py
Expand Up @@ -2,6 +2,8 @@
import textwrap
import unittest

import pytest

from conans.test.utils.tools import TestClient

hello_cpp = """
Expand Down Expand Up @@ -66,6 +68,7 @@ def package_info(self):


@unittest.skipIf(platform.system() == "Windows", ".pc files not in Win")
@pytest.mark.tool_pkg_config
class PkgConfigTest(unittest.TestCase):
"""
Test WITHOUT a build helper nor a generator, explicitly defining pkg-config in the
Expand Down
Expand Up @@ -60,6 +60,7 @@ def build(self):

@attr("slow")
@pytest.mark.slow
@pytest.mark.tool_cmake
class BuildRequiresTest(unittest.TestCase):

def test_test_framework(self):
Expand Down
3 changes: 3 additions & 0 deletions conans/test/functional/case_sensitive_test.py
Expand Up @@ -2,6 +2,8 @@
import textwrap
import unittest

import pytest

from conans.paths import CONANFILE
from conans.test.assets.cpp_test_files import cpp_hello_conan_files
from conans.test.utils.tools import TestClient, TestServer
Expand All @@ -21,6 +23,7 @@ def source(self):
@unittest.skipIf(platform.system() == 'Linux', "Only for case insensitive OS")
class CaseSensitiveTest(unittest.TestCase):

@pytest.mark.tool_compiler
def test_install(self):
test_server = TestServer()
servers = {"default": test_server}
Expand Down
3 changes: 3 additions & 0 deletions conans/test/functional/command/build_test.py
Expand Up @@ -2,6 +2,8 @@
import textwrap
import unittest

import pytest

from conans.model.ref import PackageReference
from conans.paths import BUILD_INFO, CONANFILE
from conans.test.utils.tools import NO_SETTINGS_PACKAGE_ID, TestClient
Expand Down Expand Up @@ -242,6 +244,7 @@ def build(self):
self.assertIn("Hello.Pkg/0.1/lasote/testing", client.out)
self.assertIn("Hello-Tools/0.1/lasote/testing", client.out)

@pytest.mark.tool_cmake
def test_build_cmake_install(self):
client = TestClient()
conanfile = """
Expand Down
7 changes: 7 additions & 0 deletions conans/test/functional/command/config_install_test.py
Expand Up @@ -6,6 +6,7 @@
import unittest
import zipfile

import pytest
import six
from mock import patch

Expand Down Expand Up @@ -386,6 +387,7 @@ def test_failed_install_http(self):
self.assertIn("ERROR: Failed conan config install: "
"Error while installing config from httpnonexisting", self.client.out)

@pytest.mark.tool_git
def test_install_repo(self):
""" should install from a git repo
"""
Expand All @@ -402,6 +404,7 @@ def test_install_repo(self):
check_path = os.path.join(folder, ".git")
self._check("git, %s, True, None" % check_path)

@pytest.mark.tool_git
def test_install_repo_relative(self):
relative_folder = "./config"
absolute_folder = os.path.join(self.client.current_folder, "config")
Expand All @@ -417,6 +420,7 @@ def test_install_repo_relative(self):
self.client.run('config install "%s/.git"' % relative_folder)
self._check("git, %s, True, None" % os.path.join("%s" % folder, ".git"))

@pytest.mark.tool_git
def test_install_custom_args(self):
""" should install from a git repo
"""
Expand Down Expand Up @@ -529,6 +533,7 @@ def download_verify_true(obj, url, filename, **kwargs): # @UnusedVariable
with patch.object(FileDownloader, 'download', new=download_verify_true):
self.client.run("config install %s --verify-ssl=True" % fake_url)

@pytest.mark.tool_git
def test_git_checkout_is_possible(self):
folder = self._create_profile_folder()
with self.client.chdir(folder):
Expand Down Expand Up @@ -701,6 +706,7 @@ def test_invalid_time_interval(self):
self.assertIn("ERROR: Incorrect definition of general.config_install_interval: 1s",
self.client.out)

@pytest.mark.tool_git
def test_config_install_remove_git_repo(self):
""" config_install_interval must break when remote git has been removed
"""
Expand All @@ -726,6 +732,7 @@ def test_config_install_remove_git_repo(self):
self.client.run("config --help")
self.assertIn("Repo cloned!", self.client.out)

@pytest.mark.tool_git
def test_config_install_remove_config_repo(self):
""" config_install_interval should not run when config list is empty
"""
Expand Down
3 changes: 3 additions & 0 deletions conans/test/functional/command/devflow_test.py
@@ -1,6 +1,8 @@
import os
import unittest

import pytest

from conans.client import tools
from conans.model.ref import ConanFileReference
from conans.test.utils.tools import TestClient
Expand Down Expand Up @@ -232,6 +234,7 @@ def test_child_build(self):
os.listdir(cache_package_folder)[0])
self._assert_pkg(cache_package_folder)

@pytest.mark.tool_compiler
def test_build_local_different_folders(self):
# Real build, needed to ensure that the generator is put in the correct place and
# cmake finds it, using an install_folder different from build_folder
Expand Down
@@ -1,13 +1,15 @@
import os
import unittest

import pytest

from conans.model.ref import ConanFileReference, PackageReference
from conans.paths import CONANFILE
from conans.test.assets.cpp_test_files import cpp_hello_conan_files
from conans.test.utils.tools import TestClient, TestServer
from conans.util.files import load


@pytest.mark.tool_compiler # Needed only because it assume that a settings.compiler is detected
class DownloadSelectedPackagesTest(unittest.TestCase):

def setUp(self):
Expand Down
2 changes: 2 additions & 0 deletions conans/test/functional/command/export/export_test.py
Expand Up @@ -3,6 +3,7 @@
import textwrap
import unittest

import pytest
from parameterized import parameterized

from conans.model.manifest import FileTreeManifest
Expand Down Expand Up @@ -403,6 +404,7 @@ def test_revision_mode_hash(self):
meta = t.cache.package_layout(ref, short_paths=False).load_metadata()
self.assertEqual(meta.recipe.revision, self.summary_hash)

@pytest.mark.tool_git
def test_revision_mode_scm(self):
t = TestClient()
commit = t.init_git_repo({'conanfile.py': self.conanfile.format(revision_mode="scm")})
Expand Down
4 changes: 3 additions & 1 deletion conans/test/functional/command/info/info_command_test.py
@@ -1,13 +1,15 @@
import os
import unittest

import pytest

from conans.paths import CONANFILE
from conans.test.assets.cpp_test_files import cpp_hello_conan_files
from conans.test.utils.test_files import temp_folder
from conans.test.utils.tools import TestClient, TestServer
from conans.util.files import load, save


@pytest.mark.tool_compiler # Needed only because it assume that a settings.compiler is detected
class InfoTest(unittest.TestCase):

def setUp(self):
Expand Down
3 changes: 3 additions & 0 deletions conans/test/functional/command/info/info_options_test.py
@@ -1,8 +1,11 @@
import unittest

import pytest

from conans.test.utils.tools import TestClient


@pytest.mark.tool_compiler
class InfoOptionsTest(unittest.TestCase):

def test_info_options(self):
Expand Down