Skip to content

Commit

Permalink
[Micromamba] Add mamba tests (#2877)
Browse files Browse the repository at this point in the history
* Add mamba `test_api` tests to umamba

* Add more tests
  • Loading branch information
Hind-M authored Oct 3, 2023
1 parent e0d4f6d commit b1c4950
Show file tree
Hide file tree
Showing 16 changed files with 699 additions and 9 deletions.
53 changes: 53 additions & 0 deletions micromamba/tests/channel_a/linux-64/repodata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"info": {
"subdir": "linux-64"
},
"packages": {
"A_0.1.0.tar.bz2": {
"build": "abc",
"build_number": 0,
"depends": [],
"license": "BSD",
"license_family": "BSD",
"md5": "85107fc10154734ef34a5a75685be684",
"name": "a",
"sha256": "398831eff682d2c975b360d64656d8f475cbc1f1b6d0ee33d86285190e7ee4d1",
"size": 222503,
"subdir": "linux-64",
"timestamp": 1578950023135,
"version": "0.1.0"
},
"A_0.2.0.tar.bz2": {
"build": "abc",
"build_number": 0,
"depends": [],
"license": "BSD",
"license_family": "BSD",
"md5": "85107fc10154734ef34a5a75685be684",
"name": "a",
"sha256": "398831eff682d2c975b360d64656d8f475cbc1f1b6d0ee33d86285190e7ee4d1",
"size": 222503,
"subdir": "linux-64",
"timestamp": 1578950023135,
"version": "0.2.0"
},
"B_0.1.0.tar.bz2": {
"build": "abc",
"build_number": 0,
"depends": [
"a"
],
"license": "BSD",
"license_family": "BSD",
"md5": "85107fc10154734ef34a5a75685be684",
"name": "b",
"sha256": "398831eff682d2c975b360d64656d8f475cbc1f1b6d0ee33d86285190e7ee4d1",
"size": 222503,
"subdir": "linux-64",
"timestamp": 1578950023135,
"version": "0.1.0"
}
},
"removed": [],
"repodata_version": 1
}
Binary file added micromamba/tests/channel_a/linux-64/repodata.tar.bz2
Binary file not shown.
55 changes: 55 additions & 0 deletions micromamba/tests/channel_a/linux-64/repodata.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"info": {
"subdir": "linux-64"
},
"packages": {
"A_0.1.0.tar.bz2": {
"build": "abc",
"build_number": 0,
"depends": [
],
"license": "BSD",
"license_family": "BSD",
"md5": "85107fc10154734ef34a5a75685be684",
"name": "a",
"sha256": "398831eff682d2c975b360d64656d8f475cbc1f1b6d0ee33d86285190e7ee4d1",
"size": 222503,
"subdir": "linux-64",
"timestamp": 1578950023135,
"version": "0.1.0"
},
"A_0.2.0.tar.bz2": {
"build": "abc",
"build_number": 0,
"depends": [
],
"license": "BSD",
"license_family": "BSD",
"md5": "85107fc10154734ef34a5a75685be684",
"name": "a",
"sha256": "398831eff682d2c975b360d64656d8f475cbc1f1b6d0ee33d86285190e7ee4d1",
"size": 222503,
"subdir": "linux-64",
"timestamp": 1578950023135,
"version": "0.2.0"
},
"B_0.1.0.tar.bz2": {
"build": "abc",
"build_number": 0,
"depends": [
"a"GLIBC_PLACEHOLDER
],
"license": "BSD",
"license_family": "BSD",
"md5": "85107fc10154734ef34a5a75685be684",
"name": "b",
"sha256": "398831eff682d2c975b360d64656d8f475cbc1f1b6d0ee33d86285190e7ee4d1",
"size": 222503,
"subdir": "linux-64",
"timestamp": 1578950023135,
"version": "0.1.0"
}
},
"removed": [],
"repodata_version": 1
}
Binary file not shown.
40 changes: 40 additions & 0 deletions micromamba/tests/channel_a/noarch/repodata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"info": {
"subdir": "noarch"
},
"packages": {
"_r-mutex-1.0.1-anacondar_1.tar.bz2": {
"build": "anacondar_1",
"build_number": 1,
"constrains": [],
"depends": [],
"license": "BSD",
"md5": "19f9db5f4f1b7f5ef5f6d67207f25f38",
"name": "_r-mutex",
"noarch": "generic",
"platform": null,
"sha256": "e58f9eeb416b92b550e824bcb1b9fb1958dee69abfe3089dfd1a9173e3a0528a",
"size": 3566,
"subdir": "noarch",
"timestamp": 1562343890778,
"track_features": "",
"version": "1.0.1"
},
"testpkg_0.1.0.tar.bz2": {
"build": "abc",
"build_number": 0,
"depends": [],
"license": "BSD",
"license_family": "BSD",
"md5": "85107fc10154734ef34a5a75685be684",
"name": "testpkg",
"sha256": "398831eff682d2c975b360d64656d8f475cbc1f1b6d0ee33d86285190e7ee4d1",
"size": 222503,
"subdir": "noarch",
"timestamp": 1578950023135,
"version": "0.1.0"
}
},
"removed": [],
"repodata_version": 1
}
53 changes: 53 additions & 0 deletions micromamba/tests/channel_a/win-64/repodata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"info": {
"subdir": "win-64"
},
"packages": {
"A_0.1.0.tar.bz2": {
"build": "abc",
"build_number": 0,
"depends": [],
"license": "BSD",
"license_family": "BSD",
"md5": "85107fc10154734ef34a5a75685be684",
"name": "a",
"sha256": "398831eff682d2c975b360d64656d8f475cbc1f1b6d0ee33d86285190e7ee4d1",
"size": 222503,
"subdir": "win-64",
"timestamp": 1578950023135,
"version": "0.1.0"
},
"A_0.2.0.tar.bz2": {
"build": "abc",
"build_number": 0,
"depends": [],
"license": "BSD",
"license_family": "BSD",
"md5": "85107fc10154734ef34a5a75685be684",
"name": "a",
"sha256": "398831eff682d2c975b360d64656d8f475cbc1f1b6d0ee33d86285190e7ee4d1",
"size": 222503,
"subdir": "win-64",
"timestamp": 1578950023135,
"version": "0.2.0"
},
"B_0.1.0.tar.bz2": {
"build": "abc",
"build_number": 0,
"depends": [
"a"
],
"license": "BSD",
"license_family": "BSD",
"md5": "85107fc10154734ef34a5a75685be684",
"name": "b",
"sha256": "398831eff682d2c975b360d64656d8f475cbc1f1b6d0ee33d86285190e7ee4d1",
"size": 222503,
"subdir": "win-64",
"timestamp": 1578950023135,
"version": "0.1.0"
}
},
"removed": [],
"repodata_version": 1
}
Binary file added micromamba/tests/channel_a/win-64/repodata.tar.bz2
Binary file not shown.
55 changes: 55 additions & 0 deletions micromamba/tests/channel_a/win-64/repodata.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"info": {
"subdir": "win-64"
},
"packages": {
"A_0.1.0.tar.bz2": {
"build": "abc",
"build_number": 0,
"depends": [
],
"license": "BSD",
"license_family": "BSD",
"md5": "85107fc10154734ef34a5a75685be684",
"name": "a",
"sha256": "398831eff682d2c975b360d64656d8f475cbc1f1b6d0ee33d86285190e7ee4d1",
"size": 222503,
"subdir": "win-64",
"timestamp": 1578950023135,
"version": "0.1.0"
},
"A_0.2.0.tar.bz2": {
"build": "abc",
"build_number": 0,
"depends": [
],
"license": "BSD",
"license_family": "BSD",
"md5": "85107fc10154734ef34a5a75685be684",
"name": "a",
"sha256": "398831eff682d2c975b360d64656d8f475cbc1f1b6d0ee33d86285190e7ee4d1",
"size": 222503,
"subdir": "win-64",
"timestamp": 1578950023135,
"version": "0.2.0"
},
"B_0.1.0.tar.bz2": {
"build": "abc",
"build_number": 0,
"depends": [
"a"GLIBC_PLACEHOLDER
],
"license": "BSD",
"license_family": "BSD",
"md5": "85107fc10154734ef34a5a75685be684",
"name": "b",
"sha256": "398831eff682d2c975b360d64656d8f475cbc1f1b6d0ee33d86285190e7ee4d1",
"size": 222503,
"subdir": "win-64",
"timestamp": 1578950023135,
"version": "0.1.0"
}
},
"removed": [],
"repodata_version": 1
}
23 changes: 23 additions & 0 deletions micromamba/tests/channel_b/linux-64/repodata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"info": {
"subdir": "linux-64"
},
"packages": {
"A_0.1.0.tar.bz2": {
"build": "abc",
"build_number": 0,
"depends": [],
"license": "BSD",
"license_family": "BSD",
"md5": "85107fc10154734ef34a5a75685be684",
"name": "a",
"sha256": "398831eff682d2c975b360d64656d8f475cbc1f1b6d0ee33d86285190e7ee4d1",
"size": 222503,
"subdir": "linux-64",
"timestamp": 1578950023135,
"version": "0.1.0"
}
},
"removed": [],
"repodata_version": 1
}
1 change: 1 addition & 0 deletions micromamba/tests/channel_b/noarch/repodata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
23 changes: 23 additions & 0 deletions micromamba/tests/channel_b/win-64/repodata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"info": {
"subdir": "win-64"
},
"packages": {
"A_0.1.0.tar.bz2": {
"build": "abc",
"build_number": 0,
"depends": [],
"license": "BSD",
"license_family": "BSD",
"md5": "85107fc10154734ef34a5a75685be684",
"name": "a",
"sha256": "398831eff682d2c975b360d64656d8f475cbc1f1b6d0ee33d86285190e7ee4d1",
"size": 222503,
"subdir": "win-64",
"timestamp": 1578950023135,
"version": "0.1.0"
}
},
"removed": [],
"repodata_version": 1
}
47 changes: 47 additions & 0 deletions micromamba/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,50 @@ def user_cache_dir(tmp_home: pathlib.Path) -> Generator[pathlib.Path, None, None
yield pathlib.Path(os.environ["LOCALAPPDATA"]) / "mamba"
else:
raise RuntimeError(f"Unsupported system {system}")


def get_glibc_version():
try:
output = subprocess.check_output(["ldd", "--version"])
except:
return
output.splitlines()
version = output.splitlines()[0].split()[-1]
return version.decode("ascii")


@pytest.fixture
def add_glibc_virtual_package():
version = get_glibc_version()
here = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(here, "channel_a/linux-64/repodata.tpl")) as f:
repodata = f.read()
with open(os.path.join(here, "channel_a/linux-64/repodata.json"), "w") as f:
if version is not None:
glibc_placeholder = ', "__glibc=' + version + '"'
else:
glibc_placeholder = ""
repodata = repodata.replace("GLIBC_PLACEHOLDER", glibc_placeholder)
f.write(repodata)


@pytest.fixture
def copy_channels_osx():
import shutil

here = os.path.dirname(os.path.abspath(__file__))
for channel in ["a", "b"]:
if not os.path.exists(os.path.join(here, f"channel_{channel}/osx-64")):
shutil.copytree(
os.path.join(here, f"channel_{channel}/linux-64"),
os.path.join(here, f"channel_{channel}/osx-64"),
)
with open(
os.path.join(here, f"channel_{channel}/osx-64/repodata.json")
) as f:
repodata = f.read()
with open(
os.path.join(here, f"channel_{channel}/osx-64/repodata.json"), "w"
) as f:
repodata = repodata.replace("linux", "osx")
f.write(repodata)
16 changes: 16 additions & 0 deletions micromamba/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,3 +505,19 @@ def get_fake_activate(prefix):
env["PATH"] = os.pathsep.join([str(x) for x in addpath + curpath])
env["CONDA_PREFIX"] = str(prefix)
return env


def create_with_chan_pkg(env_name, channels, package):
cmd = [
"-n",
env_name,
"--override-channels",
"--strict-channel-priority",
"--dry-run",
"--json",
]
for channel in channels:
cmd += ["-c", os.path.abspath(os.path.join(*channel))]
cmd.append(package)

return create(*cmd, default_channel=False, no_rc=False)
Loading

0 comments on commit b1c4950

Please sign in to comment.