Skip to content

- DO NOT MERGE! add developer2 #400

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ pipeline {
sh '.ci/generate_env_macos.sh'
}
}
stage('Macos - py36 - conandev2') {
environment {
PYVER = 'py36'
TOXENV = 'py36-conandev2'
}
steps {
sh '.ci/run_tox.sh'
}
}
stage('Macos - py36 - conandev') {
environment {
PYVER = 'py36'
Expand Down Expand Up @@ -50,6 +59,15 @@ pipeline {
sh '.ci/generate_env_macos.sh'
}
}
stage('Macos - py39 - conande2') {
environment {
PYVER = 'py39'
TOXENV = 'py39-conandev2'
}
steps {
sh '.ci/run_tox.sh'
}
}
stage('Macos - py39 - conandev') {
environment {
PYVER = 'py39'
Expand Down
18 changes: 15 additions & 3 deletions hooks/non_ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@

import os
import unicodedata
from conans import tools


def load(conanfile, filename):
try:
from conans.tools import load
v2 = False
except ImportError:
from conan.tools.files import load
v2 = True
if v2:
return load(conanfile, filename)
else:
return load(filename)


def check_non_ascii(filename, content, output):
Expand All @@ -23,10 +35,10 @@ def check_non_ascii(filename, content, output):


def pre_export(output, conanfile, conanfile_path, reference, **kwargs):
conanfile_content = tools.load(conanfile_path)
conanfile_content = load(conanfile, conanfile_path)
check_non_ascii("conanfile.py", conanfile_content, output)
test_package_dir = os.path.join(os.path.dirname(conanfile_path), "test_package")
test_package_path = os.path.join(test_package_dir, "conanfile.py")
if os.path.exists(test_package_path):
test_package_content = tools.load(test_package_path)
test_package_content = load(conanfile, test_package_path)
check_non_ascii("test_package/conanfile.py", test_package_content)
33 changes: 17 additions & 16 deletions tests/test_hooks/conan-center/test_build_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from conans import tools

from tests.utils.test_cases.conan_client import ConanClientTestCase
from tests.utils.compat import save


class TestBuildInfo(ConanClientTestCase):
Expand All @@ -15,7 +16,7 @@ def _get_environ(self, **kwargs):
return kwargs

def test_trivial_ok(self):
tools.save("conanfile.py", content=textwrap.dedent("""\
save("conanfile.py", content=textwrap.dedent("""\
from conans import ConanFile

class AConan(ConanFile):
Expand All @@ -25,7 +26,7 @@ class AConan(ConanFile):
self.assertIn("[NO BUILD SYSTEM FUNCTIONS (KB-H061)] OK", output)

def test_build_toolsosinfo_ok(self):
tools.save("conanfile.py", content=textwrap.dedent("""\
save("conanfile.py", content=textwrap.dedent("""\
from conans import ConanFile, tools

class AConan(ConanFile):
Expand All @@ -37,7 +38,7 @@ def build(self):
self.assertIn("[NO BUILD SYSTEM FUNCTIONS (KB-H061)] OK", output)

def test_build_platform_ok(self):
tools.save("conanfile.py", content=textwrap.dedent("""\
save("conanfile.py", content=textwrap.dedent("""\
from conans import ConanFile
import platform

Expand All @@ -50,7 +51,7 @@ def build(self):
self.assertIn("[NO BUILD SYSTEM FUNCTIONS (KB-H061)] OK", output)

def test_buildreq_toolsosinfo(self):
tools.save("conanfile.py", textwrap.dedent("""\
save("conanfile.py", textwrap.dedent("""\
from conans import ConanFile, tools

class AConan(ConanFile):
Expand All @@ -64,7 +65,7 @@ def build_requirements(self):
self.assertIn("conanfile.py:5 Build system dependent", output)

def test_buildreq_platform(self):
tools.save("conanfile.py", textwrap.dedent("""\
save("conanfile.py", textwrap.dedent("""\
from conans import ConanFile, tools
import platform

Expand All @@ -79,7 +80,7 @@ def build_requirements(self):
self.assertIn("conanfile.py:6 Build system dependent", output)

def test_req_toolsosinfo(self):
tools.save("conanfile.py", textwrap.dedent("""\
save("conanfile.py", textwrap.dedent("""\
from conans import ConanFile, tools

class AConan(ConanFile):
Expand All @@ -93,7 +94,7 @@ def requirements(self):
self.assertIn("conanfile.py:5 Build system dependent", output)

def test_req_platform(self):
tools.save("conanfile.py", textwrap.dedent("""\
save("conanfile.py", textwrap.dedent("""\
from conans import ConanFile, tools
import platform

Expand All @@ -108,7 +109,7 @@ def requirements(self):
self.assertIn("conanfile.py:6 Build system dependent", output)

def test_configopts_toolsosinfo(self):
tools.save("conanfile.py", textwrap.dedent("""\
save("conanfile.py", textwrap.dedent("""\
from conans import ConanFile, tools

class AConan(ConanFile):
Expand All @@ -122,7 +123,7 @@ def config_options(self):
self.assertIn("conanfile.py:5 Build system dependent", output)

def test_configopts_platform(self):
tools.save("conanfile.py", textwrap.dedent("""\
save("conanfile.py", textwrap.dedent("""\
from conans import ConanFile, tools
import platform

Expand All @@ -137,7 +138,7 @@ def config_options(self):
self.assertIn("conanfile.py:6 Build system dependent", output)

def test_config_toolsosinfo(self):
tools.save("conanfile.py", textwrap.dedent("""\
save("conanfile.py", textwrap.dedent("""\
from conans import ConanFile, tools

class AConan(ConanFile):
Expand All @@ -151,7 +152,7 @@ def configure(self):
self.assertIn("conanfile.py:5 Build system dependent", output)

def test_config_platform(self):
tools.save("conanfile.py", textwrap.dedent("""\
save("conanfile.py", textwrap.dedent("""\
from conans import ConanFile, tools
import platform

Expand All @@ -166,7 +167,7 @@ def configure(self):
self.assertIn("conanfile.py:6 Build system dependent", output)

def test_validate_toolsosinfo(self):
tools.save("conanfile.py", textwrap.dedent("""\
save("conanfile.py", textwrap.dedent("""\
from conans import ConanFile, tools
from conans.errors import ConanInvalidConfiguration

Expand All @@ -181,7 +182,7 @@ def validate(self):
self.assertIn("conanfile.py:6 Build system dependent", output)

def test_validate_platform(self):
tools.save("conanfile.py", textwrap.dedent("""\
save("conanfile.py", textwrap.dedent("""\
from conans import ConanFile, tools
from conans.errors import ConanInvalidConfiguration
import platform
Expand All @@ -204,7 +205,7 @@ def config_options(self):
if tools.os_info.is_windows:
pass
""")
tools.save('conanfile.py', content=conanfile)
save('conanfile.py', content=conanfile)
output = self.conan(['export', '.', 'name/version@user/channel'])
self.assertIn("ERROR: [NO BUILD SYSTEM FUNCTIONS (KB-H061)]", output)

Expand All @@ -216,7 +217,7 @@ def configure(self):
if tools.os_info.is_linux:
pass
""")
tools.save('conanfile.py', content=conanfile)
save('conanfile.py', content=conanfile)
output = self.conan(['export', '.', 'name/version@user/channel'])
self.assertIn("ERROR: [NO BUILD SYSTEM FUNCTIONS (KB-H061)]", output)

Expand All @@ -229,6 +230,6 @@ def configure(self):
if os_info.is_macos:
pass
""")
tools.save('conanfile.py', content=conanfile)
save('conanfile.py', content=conanfile)
output = self.conan(['export', '.', 'name/version@user/channel'])
self.assertIn("ERROR: [NO BUILD SYSTEM FUNCTIONS (KB-H061)]", output)
21 changes: 11 additions & 10 deletions tests/test_hooks/conan-center/test_cmake_bad_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from conans import __version__ as conan_version
from conans import tools
from tests.utils.test_cases.conan_client import ConanClientTestCase
from tests.utils.compat import save


@unittest.skipUnless(conan_version >= "1.16.0", "Conan > 1.16.0 needed")
Expand Down Expand Up @@ -41,13 +42,13 @@ def _get_environ(self, **kwargs):

def test_find_and_config_files(self):

tools.save('conanfile.py', content=self.conan_file.format("", "WhateverConfig.cmake"))
save('conanfile.py', content=self.conan_file.format("", "WhateverConfig.cmake"))
output = self.conan(['create', '.', 'name/version@user/channel'])
self.assertIn("ERROR: [CMAKE-MODULES-CONFIG-FILES (KB-H016)] Found files: ./WhateverConfig.cmake",
output)

def test_find_and_find_files(self):
tools.save('conanfile.py', content=self.conan_file.format("", "FindXXX.cmake"))
save('conanfile.py', content=self.conan_file.format("", "FindXXX.cmake"))
output = self.conan(['create', '.', 'name/version@user/channel'])
self.assertIn("ERROR: [CMAKE-MODULES-CONFIG-FILES (KB-H016)] Found files: ./FindXXX.cmake",
output)
Expand All @@ -63,19 +64,19 @@ def package(self):
tools.save(os.path.join(self.package_folder, "FindXXX.cmake"), "foo")
tools.save(os.path.join(self.package_folder, "XXXConfig.cmake"), "foo")
""")
tools.save('conanfile.py', content=conanfile)
save('conanfile.py', content=conanfile)
output = self.conan(['create', '.', 'name/version@user/channel'])
self.assertIn("ERROR: [CMAKE-MODULES-CONFIG-FILES (KB-H016)] Found files: ./FindXXX.cmake; ./XXXConfig.cmake",
output)

def test_find_files_outside_dir(self):

tools.save('conanfile.py', content=self.conan_file.format("folder", "file.cmake"))
save('conanfile.py', content=self.conan_file.format("folder", "file.cmake"))
output = self.conan(['create', '.', 'name/version@user/channel'])
self.assertIn("WARN: [CMAKE FILE NOT IN BUILD FOLDERS (KB-H019)] Found files: "
"./folder/file.cmake", output.replace("\\", "/"))

tools.save('conanfile.py', content=self.conan_file.format("", "file.cmake"))
save('conanfile.py', content=self.conan_file.format("", "file.cmake"))
output = self.conan(['create', '.', 'name/version@user/channel'])
self.assertNotIn("WARN: [CMAKE FILE NOT IN BUILD FOLDERS (KB-H019)]", output)

Expand All @@ -92,20 +93,20 @@ def package_info(self):
self.cpp_info.builddirs = ["some_build_dir"]
""")

tools.save('conanfile.py', content=conanfile2.format("some_build_dir"))
save('conanfile.py', content=conanfile2.format("some_build_dir"))
output = self.conan(['create', '.', 'name/version@user/channel'])
self.assertNotIn("WARN: [CMAKE FILE NOT IN BUILD FOLDERS (KB-H019)]", output)

tools.save('conanfile.py', content=conanfile2.format("some_build_dir/subdir"))
save('conanfile.py', content=conanfile2.format("some_build_dir/subdir"))
output = self.conan(['create', '.', 'name/version@user/channel'])
self.assertNotIn("WARN: [CMAKE FILE NOT IN BUILD FOLDERS (KB-H019)]", output)

def test_good_files(self):
tools.save('conanfile.py', content=self.conan_file_info.format('os.path.join("lib", "cmake", "script.cmake")', ["lib/cmake"]))
save('conanfile.py', content=self.conan_file_info.format('os.path.join("lib", "cmake", "script.cmake")', ["lib/cmake"]))
output = self.conan(['create', '.', 'name/version@user/channel'])
self.assertNotIn("ERROR: [CMAKE FILE NOT IN BUILD FOLDERS (KB-H019)]", output)

tools.save('conanfile.py', content=self.conan_file_info.format('os.path.join("lib", "cmake", "script.cmake")', ["lib\\cmake"]))
save('conanfile.py', content=self.conan_file_info.format('os.path.join("lib", "cmake", "script.cmake")', ["lib\\cmake"]))
output = self.conan(['create', '.', 'name/version@user/channel'])
self.assertNotIn("ERROR: [CMAKE FILE NOT IN BUILD FOLDERS (KB-H019)]", output)

Expand All @@ -123,6 +124,6 @@ def package_info(self):
self.cpp_info.components["baz"].names["cmake_find_package_multi"] = "baz"
self.cpp_info.components["baz"].builddirs = [os.path.join("lib", "cmake")]
""")
tools.save('conanfile.py', content=conanfile)
save('conanfile.py', content=conanfile)
output = self.conan(['create', '.', 'name/version@user/channel'])
self.assertNotIn("ERROR: [CMAKE FILE NOT IN BUILD FOLDERS (KB-H019)]", output)
Loading