|
7 | 7 | from conan.test.assets.sources import gen_function_h, gen_function_cpp |
8 | 8 |
|
9 | 9 |
|
| 10 | +def docker_from_env(): |
| 11 | + try: |
| 12 | + return docker.from_env() |
| 13 | + except Exception: |
| 14 | + return docker.DockerClient(base_url=f'unix://{os.path.expanduser("~")}/.rd/docker.sock', version='auto') # Rancher |
| 15 | + |
| 16 | + |
10 | 17 | def docker_skip(test_image='ubuntu:22.04'): |
11 | 18 | try: |
12 | | - try: |
13 | | - docker_client = docker.from_env() |
14 | | - except: |
15 | | - docker_client = docker.DockerClient(base_url=f'unix://{os.path.expanduser("~")}/.rd/docker.sock', version='auto') # Rancher |
| 19 | + docker_client = docker_from_env() |
16 | 20 | if test_image: |
17 | 21 | docker_client.images.pull(test_image) |
18 | 22 | except docker.errors.DockerException: |
@@ -459,7 +463,7 @@ def test_create_docker_runner_from_configfile_with_args(): |
459 | 463 | client = TestClient() |
460 | 464 |
|
461 | 465 | # Ensure the network exists |
462 | | - docker_client = docker.from_env() |
| 466 | + docker_client = docker_from_env() |
463 | 467 | docker_client.networks.create("my-network") |
464 | 468 |
|
465 | 469 | configfile = textwrap.dedent(f""" |
@@ -550,6 +554,45 @@ def test_create_docker_runner_default_build_profile(): |
550 | 554 | assert "Restore: pkg/0.2:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe metadata" in client.out |
551 | 555 | assert "Removing container" in client.out |
552 | 556 |
|
| 557 | +@pytest.mark.docker_runner |
| 558 | +@pytest.mark.skipif(docker_skip('ubuntu:22.04'), reason="Only docker running") |
| 559 | +def test_create_docker_runner_profile_composition(): |
| 560 | + """ |
| 561 | + Tests the ``conan create . `` with profile composition |
| 562 | + """ |
| 563 | + client = TestClient() |
| 564 | + |
| 565 | + profile = textwrap.dedent(f"""\ |
| 566 | + [settings] |
| 567 | + arch={{{{ detect_api.detect_arch() }}}} |
| 568 | + build_type=Release |
| 569 | + compiler=gcc |
| 570 | + compiler.cppstd=gnu17 |
| 571 | + compiler.libcxx=libstdc++11 |
| 572 | + compiler.version=11 |
| 573 | + os=Linux |
| 574 | + [runner] |
| 575 | + type=docker |
| 576 | + image=conan-runner-ninja-test |
| 577 | + """) |
| 578 | + |
| 579 | + profile_extension = textwrap.dedent(f"""\ |
| 580 | + [runner] |
| 581 | + type=docker |
| 582 | + dockerfile={dockerfile_path("Dockerfile_ninja")} |
| 583 | + build_context={conan_base_path()} |
| 584 | + cache=copy |
| 585 | + remove=True |
| 586 | + """) |
| 587 | + client.save({"profile": profile, "profile_extension": profile_extension}) |
| 588 | + client.run("new cmake_lib -d name=pkg -d version=2.0") |
| 589 | + client.run("create . -pr:h profile -pr:h profile_extension") |
| 590 | + |
| 591 | + assert "[100%] Built target example" in client.out |
| 592 | + assert "Restore: pkg/2.0 in pkgc6abef0178849" in client.out |
| 593 | + assert "Restore: pkg/2.0:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe" in client.out |
| 594 | + assert "Restore: pkg/2.0:8631cf963dbbb4d7a378a64a6fd1dc57558bc2fe metadata" in client.out |
| 595 | + |
553 | 596 |
|
554 | 597 | @pytest.mark.docker_runner |
555 | 598 | @pytest.mark.skipif(docker_skip(), reason="Only docker running") |
|
0 commit comments