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

test_package only if build missing #15999

Merged
merged 4 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 8 additions & 1 deletion conan/cli/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from conan.cli.printers import print_profiles
from conan.cli.printers.graph import print_graph_packages, print_graph_basic
from conan.errors import ConanException
from conans.client.graph.graph import BINARY_BUILD
from conans.util.files import mkdir


Expand All @@ -33,7 +34,6 @@ def create(conan_api, parser, *args):

cwd = os.getcwd()
path = conan_api.local.get_conanfile_path(args.path, cwd, py=True)
test_conanfile_path = _get_test_conanfile_path(args.test_folder, path)
overrides = eval(args.lockfile_overrides) if args.lockfile_overrides else None
lockfile = conan_api.lockfile.get_lockfile(lockfile=args.lockfile,
conanfile_path=path,
Expand Down Expand Up @@ -91,6 +91,13 @@ def create(conan_api, parser, *args):
lockfile = conan_api.lockfile.update_lockfile(lockfile, deps_graph, args.lockfile_packages,
clean=args.lockfile_clean)

test_folder = args.test_folder
if test_folder and test_folder.startswith("missing"):
if deps_graph.root.dependencies[0].dst.binary == BINARY_BUILD:
test_folder = test_folder.split(":", 1)[1] if ":" in test_folder else "test_package"
else:
test_folder = "" # disable it
test_conanfile_path = _get_test_conanfile_path(test_folder, path)
if test_conanfile_path:
# TODO: We need arguments for:
# - decide update policy "--test_package_update"
Expand Down
23 changes: 23 additions & 0 deletions conans/test/integration/command/create_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,3 +811,26 @@ def test(self):
c.run("create .")
# Ensure that creating a deps graph does not break the testing
assert "pyreq/1.0 (test package): 42!!!" in c.out


def test_create_test_package_only_build():
c = TestClient()
c.save({"conanfile.py": GenConanfile("pkg", "0.1"),
"test_package/conanfile.py": GenConanfile().with_test("self.output.info('TEST1!!!')"),
"test_package2/conanfile.py": GenConanfile().with_test("self.output.info('TEST2!!!')")})
# As it doesn't exist, it builds and test it
c.run("create . -tf=missing")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conan create . --build=missing --test-missing -tf=other_folder

assert "Testing the package" in c.out
assert "TEST1!!!" in c.out
# this will not create the binary, so it won't test it
c.run("create . --build=missing -tf=missing")
assert "Testing the package" not in c.out
assert "TEST" not in c.out
c.run("create . -tf=missing:test_package2")
assert "Testing the package" in c.out
assert "TEST2!!!" in c.out
assert "TEST1!!!" not in c.out
c.run("create . -tf=missing:test_package2 --build=missing")
assert "Testing the package" not in c.out
assert "TEST2!!!" not in c.out
assert "TEST1!!!" not in c.out