Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
270 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
conans/test/unittests/tools/cmake/test_cmake_cmd_line_args.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import textwrap | ||
|
||
import pytest | ||
|
||
from conan.tools.cmake.cmake import _cmake_cmd_line_args | ||
from conans.model.conf import ConfDefinition | ||
from conans.test.utils.mocks import ConanFileMock | ||
|
||
|
||
@pytest.fixture | ||
def conanfile(): | ||
c = ConfDefinition() | ||
c.loads(textwrap.dedent("""\ | ||
tools.gnu.make:jobs=40 | ||
tools.ninja:jobs=30 | ||
tools.microsoft.msbuild:max_cpu_count=20 | ||
tools.build:processes=10 | ||
""")) | ||
|
||
conanfile = ConanFileMock() | ||
conanfile.conf = c.get_conanfile_conf(None) | ||
return conanfile | ||
|
||
|
||
def test_no_generator(conanfile): | ||
args = _cmake_cmd_line_args(conanfile, None, parallel=True) | ||
assert not len(args) | ||
|
||
|
||
def test_makefiles(conanfile): | ||
args = _cmake_cmd_line_args(conanfile, 'Unix Makefiles', parallel=True) | ||
assert args == ['-j40'] | ||
|
||
args = _cmake_cmd_line_args(conanfile, 'Unix Makefiles', parallel=False) | ||
assert not len(args) | ||
|
||
args = _cmake_cmd_line_args(conanfile, 'NMake Makefiles', parallel=True) | ||
assert not len(args) | ||
|
||
|
||
def test_ninja(conanfile): | ||
args = _cmake_cmd_line_args(conanfile, 'Ninja', parallel=True) | ||
assert ['-j30'] == args | ||
|
||
args = _cmake_cmd_line_args(conanfile, 'Ninja', parallel=False) | ||
assert not len(args) | ||
|
||
|
||
def test_visual_studio(conanfile): | ||
args = _cmake_cmd_line_args(conanfile, 'Visual Studio 16 2019', parallel=True) | ||
assert ['/m:20'] == args | ||
|
||
args = _cmake_cmd_line_args(conanfile, 'Ninja', parallel=False) | ||
assert not len(args) |
Empty file.
53 changes: 53 additions & 0 deletions
53
conans/test/unittests/tools/gnu/test_make_jobs_cmd_line_arg.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import textwrap | ||
|
||
from conan.tools.gnu.make import make_jobs_cmd_line_arg | ||
from conans.model.conf import ConfDefinition | ||
from conans.test.utils.mocks import ConanFileMock | ||
|
||
|
||
def test_tools_build(): | ||
c = ConfDefinition() | ||
c.loads(textwrap.dedent("""\ | ||
tools.build:processes=10 | ||
""")) | ||
|
||
conanfile = ConanFileMock() | ||
conanfile.conf = c.get_conanfile_conf(None) | ||
njobs = make_jobs_cmd_line_arg(conanfile) | ||
assert njobs == "-j10" | ||
|
||
|
||
def test_tools_gnu_make(): | ||
c = ConfDefinition() | ||
c.loads(textwrap.dedent("""\ | ||
tools.gnu.make:jobs=23 | ||
""")) | ||
|
||
conanfile = ConanFileMock() | ||
conanfile.conf = c.get_conanfile_conf(None) | ||
njobs = make_jobs_cmd_line_arg(conanfile) | ||
assert njobs == "-j23" | ||
|
||
|
||
def test_both_values(): | ||
c = ConfDefinition() | ||
c.loads(textwrap.dedent("""\ | ||
tools.gnu.make:jobs=23 | ||
tools.build:processes=10 | ||
""")) | ||
|
||
conanfile = ConanFileMock() | ||
conanfile.conf = c.get_conanfile_conf(None) | ||
njobs = make_jobs_cmd_line_arg(conanfile) | ||
assert njobs == "-j23" | ||
|
||
|
||
def test_none(): | ||
c = ConfDefinition() | ||
c.loads(textwrap.dedent("""\ | ||
""")) | ||
|
||
conanfile = ConanFileMock() | ||
conanfile.conf = c.get_conanfile_conf(None) | ||
njobs = make_jobs_cmd_line_arg(conanfile) | ||
assert njobs is None |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import textwrap | ||
|
||
from conan.tools.meson import Meson | ||
from conans.model.conf import ConfDefinition | ||
from conans.test.utils.mocks import ConanFileMock, MockSettings | ||
|
||
|
||
def test_meson_build(): | ||
c = ConfDefinition() | ||
c.loads(textwrap.dedent("""\ | ||
tools.ninja:jobs=23 | ||
tools.build:processes=10 | ||
""")) | ||
|
||
settings = MockSettings({"build_type": "Release", | ||
"compiler": "gcc", | ||
"compiler.version": "7", | ||
"os": "Linux", | ||
"arch": "x86_64"}) | ||
conanfile = ConanFileMock() | ||
conanfile.settings = settings | ||
conanfile.display_name = 'test' | ||
conanfile.conf = c.get_conanfile_conf(None) | ||
|
||
meson = Meson(conanfile) | ||
meson.build() | ||
|
||
assert '-j23' in str(conanfile.command) |
53 changes: 53 additions & 0 deletions
53
conans/test/unittests/tools/meson/test_ninja_jobs_cmd_line_arg.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import textwrap | ||
|
||
from conan.tools.meson.meson import ninja_jobs_cmd_line_arg | ||
from conans.model.conf import ConfDefinition | ||
from conans.test.utils.mocks import ConanFileMock | ||
|
||
|
||
def test_tools_build(): | ||
c = ConfDefinition() | ||
c.loads(textwrap.dedent("""\ | ||
tools.build:processes=10 | ||
""")) | ||
|
||
conanfile = ConanFileMock() | ||
conanfile.conf = c.get_conanfile_conf(None) | ||
njobs = ninja_jobs_cmd_line_arg(conanfile) | ||
assert njobs == "-j10" | ||
|
||
|
||
def test_tools_ning(): | ||
c = ConfDefinition() | ||
c.loads(textwrap.dedent("""\ | ||
tools.ninja:jobs=23 | ||
""")) | ||
|
||
conanfile = ConanFileMock() | ||
conanfile.conf = c.get_conanfile_conf(None) | ||
njobs = ninja_jobs_cmd_line_arg(conanfile) | ||
assert njobs == "-j23" | ||
|
||
|
||
def test_both_values(): | ||
c = ConfDefinition() | ||
c.loads(textwrap.dedent("""\ | ||
tools.ninja:jobs=23 | ||
tools.build:processes=10 | ||
""")) | ||
|
||
conanfile = ConanFileMock() | ||
conanfile.conf = c.get_conanfile_conf(None) | ||
njobs = ninja_jobs_cmd_line_arg(conanfile) | ||
assert njobs == "-j23" | ||
|
||
|
||
def test_none(): | ||
c = ConfDefinition() | ||
c.loads(textwrap.dedent("""\ | ||
""")) | ||
|
||
conanfile = ConanFileMock() | ||
conanfile.conf = c.get_conanfile_conf(None) | ||
njobs = ninja_jobs_cmd_line_arg(conanfile) | ||
assert njobs is None |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import textwrap | ||
|
||
from conans.model.conf import ConfDefinition | ||
from conans.test.utils.mocks import ConanFileMock, MockSettings | ||
from tools.microsoft import MSBuild | ||
|
||
|
||
def test_meson_build(): | ||
c = ConfDefinition() | ||
c.loads(textwrap.dedent("""\ | ||
tools.microsoft.msbuild:max_cpu_count=23 | ||
tools.build:processes=10 | ||
""")) | ||
|
||
settings = MockSettings({"build_type": "Release", | ||
"compiler": "gcc", | ||
"compiler.version": "7", | ||
"os": "Linux", | ||
"arch": "x86_64"}) | ||
conanfile = ConanFileMock() | ||
conanfile.settings = settings | ||
conanfile.conf = c.get_conanfile_conf(None) | ||
|
||
msbuild = MSBuild(conanfile) | ||
cmd = msbuild.command('project.sln') | ||
|
||
assert '/m:23' in cmd |
53 changes: 53 additions & 0 deletions
53
conans/test/unittests/tools/microsoft/test_msbuild_max_cpu_count_cmd_line_arg.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import textwrap | ||
|
||
from conan.tools.microsoft.msbuild import msbuild_max_cpu_count_cmd_line_arg | ||
from conans.model.conf import ConfDefinition | ||
from conans.test.utils.mocks import ConanFileMock | ||
|
||
|
||
def test_tools_build(): | ||
c = ConfDefinition() | ||
c.loads(textwrap.dedent("""\ | ||
tools.build:processes=10 | ||
""")) | ||
|
||
conanfile = ConanFileMock() | ||
conanfile.conf = c.get_conanfile_conf(None) | ||
max_cpu_count = msbuild_max_cpu_count_cmd_line_arg(conanfile) | ||
assert max_cpu_count == "/m:10" | ||
|
||
|
||
def test_tools_ning(): | ||
c = ConfDefinition() | ||
c.loads(textwrap.dedent("""\ | ||
tools.microsoft.msbuild:max_cpu_count=23 | ||
""")) | ||
|
||
conanfile = ConanFileMock() | ||
conanfile.conf = c.get_conanfile_conf(None) | ||
max_cpu_count = msbuild_max_cpu_count_cmd_line_arg(conanfile) | ||
assert max_cpu_count == "/m:23" | ||
|
||
|
||
def test_both_values(): | ||
c = ConfDefinition() | ||
c.loads(textwrap.dedent("""\ | ||
tools.microsoft.msbuild:max_cpu_count=23 | ||
tools.build:processes=10 | ||
""")) | ||
|
||
conanfile = ConanFileMock() | ||
conanfile.conf = c.get_conanfile_conf(None) | ||
max_cpu_count = msbuild_max_cpu_count_cmd_line_arg(conanfile) | ||
assert max_cpu_count == "/m:23" | ||
|
||
|
||
def test_none(): | ||
c = ConfDefinition() | ||
c.loads(textwrap.dedent("""\ | ||
""")) | ||
|
||
conanfile = ConanFileMock() | ||
conanfile.conf = c.get_conanfile_conf(None) | ||
max_cpu_count = msbuild_max_cpu_count_cmd_line_arg(conanfile) | ||
assert max_cpu_count is None |