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 revision order #14950

Merged
merged 3 commits into from
Oct 19, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions conan/internal/cache/db/cache_database.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import os
import sqlite3

from conan.api.output import ConanOutput
from conan.internal.cache.db.packages_table import PackagesDBTable
from conan.internal.cache.db.recipes_table import RecipesDBTable
from conans.model.package_ref import PkgReference
from conans.model.recipe_ref import RecipeReference
from conans.model.version import Version


class CacheDatabase:

def __init__(self, filename):
version = sqlite3.sqlite_version
if Version(version) < "3.7.11": # Not an exception, in case some false positives
ConanOutput().error(f"Your sqlite3 '{version} < 3.7.11' version is not supported")
self._recipes = RecipesDBTable(filename)
self._packages = PackagesDBTable(filename)
if not os.path.isfile(filename):
Expand Down
35 changes: 35 additions & 0 deletions conans/test/integration/cache/test_package_revisions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from mock import mock

from conans.test.assets.genconanfile import GenConanfile
from conans.test.utils.tools import TestClient
from conans.util.env import environment_update


def test_package_revision_latest():
# https://github.com/conan-io/conan/issues/14945
c = TestClient()
c.save({"tool/conanfile.py": GenConanfile("tool", "0.1").with_package_file("file.txt",
env_var="MYVAR"),
"pkg/conanfile.py": GenConanfile("pkg", "0.1").with_tool_requires("tool/0.1")})
with environment_update({"MYVAR": "MYVALUE1"}):
# Just in case dates were not correctly processed
with mock.patch("conan.internal.cache.cache.revision_timestamp_now",
return_value="1691760295"):
c.run("create tool")
prev1 = c.created_package_revision("tool/0.1")
with environment_update({"MYVAR": "MYVALUE2"}):
# Just in case dates were not correctly processed
with mock.patch("conan.internal.cache.cache.revision_timestamp_now",
return_value="1697442658"):
c.run("create tool")
prev2 = c.created_package_revision("tool/0.1")

c.run("create pkg")
# The latest is used
assert prev2 in c.out
assert prev1 not in c.out

c.run("install --requires=pkg/0.1 --build=pkg*")
# The latest is used
assert prev2 in c.out
assert prev1 not in c.out