mirror of https://github.com/mamba-org/mamba.git
Fix test on windows (#3555)
This commit is contained in:
parent
bd8c1d2e4d
commit
47e962968d
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "mamba/specs/match_spec.hpp"
|
||||
#include "mamba/specs/package_info.hpp"
|
||||
#include "mamba/util/build.hpp"
|
||||
#include "mamba/util/string.hpp"
|
||||
|
||||
using namespace mamba;
|
||||
|
@ -623,6 +624,54 @@ TEST_SUITE("specs::match_spec")
|
|||
}
|
||||
}
|
||||
|
||||
TEST_CASE("parse_url")
|
||||
{
|
||||
SUBCASE("https://conda.com/pkg-2-bld.conda")
|
||||
{
|
||||
auto ms = MatchSpec::parse_url("https://conda.com/pkg-2-bld.conda").value();
|
||||
CHECK(ms.is_file());
|
||||
CHECK_EQ(ms.name().str(), "pkg");
|
||||
CHECK_EQ(ms.version().str(), "==2");
|
||||
CHECK_EQ(ms.str(), "https://conda.com/pkg-2-bld.conda");
|
||||
CHECK_EQ(ms.build_string().str(), "bld");
|
||||
CHECK_EQ(ms.filename(), "pkg-2-bld.conda");
|
||||
}
|
||||
|
||||
SUBCASE("/home/usr/mamba/micromamba/tests/data/cph_test_data-0.0.1-0.tar.bz2")
|
||||
{
|
||||
auto ms = MatchSpec::parse_url(
|
||||
"/home/usr/mamba/micromamba/tests/data/cph_test_data-0.0.1-0.tar.bz2"
|
||||
)
|
||||
.value();
|
||||
CHECK(ms.is_file());
|
||||
CHECK_EQ(ms.name().str(), "cph_test_data");
|
||||
CHECK_EQ(ms.version().str(), "==0.0.1");
|
||||
CHECK_EQ(ms.str(), "/home/usr/mamba/micromamba/tests/data/cph_test_data-0.0.1-0.tar.bz2");
|
||||
CHECK_EQ(ms.build_string().str(), "0");
|
||||
CHECK_EQ(ms.filename(), "cph_test_data-0.0.1-0.tar.bz2");
|
||||
}
|
||||
|
||||
SUBCASE(R"(D:\a\mamba\mamba\micromamba\tests\data\cph_test_data-0.0.1-0.tar.bz2)")
|
||||
{
|
||||
if (util::on_win)
|
||||
{
|
||||
auto ms = MatchSpec::parse_url(
|
||||
R"(D:\a\mamba\mamba\micromamba\tests\data\cph_test_data-0.0.1-0.tar.bz2)"
|
||||
)
|
||||
.value();
|
||||
CHECK(ms.is_file());
|
||||
CHECK_EQ(ms.name().str(), "cph_test_data");
|
||||
CHECK_EQ(ms.version().str(), "==0.0.1");
|
||||
CHECK_EQ(
|
||||
ms.str(),
|
||||
"D:/a/mamba/mamba/micromamba/tests/data/cph_test_data-0.0.1-0.tar.bz2"
|
||||
);
|
||||
CHECK_EQ(ms.build_string().str(), "0");
|
||||
CHECK_EQ(ms.filename(), "cph_test_data-0.0.1-0.tar.bz2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Conda discrepancies")
|
||||
{
|
||||
SUBCASE("python=3.7=bld")
|
||||
|
|
|
@ -614,17 +614,6 @@ class TestInstall:
|
|||
reinstall_res = helpers.install("xtensor", "--json")
|
||||
assert "actions" not in reinstall_res
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.platform == "win32",
|
||||
reason="Set info (e.g 'name') is wrong (to be fixed)",
|
||||
)
|
||||
def test_install_local_package(self):
|
||||
"""Attempts to install a .tar.bz2 package from a local directory."""
|
||||
file_path = Path(__file__).parent / "data" / "cph_test_data-0.0.1-0.tar.bz2"
|
||||
|
||||
res = helpers.install(f"file://{file_path}", "--json", default_channel=False)
|
||||
assert "cph_test_data" in {pkg["name"] for pkg in res["actions"]["LINK"]}
|
||||
|
||||
def test_install_local_package_relative_path(self):
|
||||
"""Attempts to install a locally built package from a relative local path."""
|
||||
spec = "./micromamba/tests/test-server/repo::test-package"
|
||||
|
@ -676,6 +665,28 @@ def test_install_check_dirs(tmp_home, tmp_root_prefix):
|
|||
assert os.path.isdir(env_prefix / "lib" / "python3.8" / "site-packages")
|
||||
|
||||
|
||||
def test_install_local_package(tmp_home, tmp_root_prefix):
|
||||
env_name = "myenv"
|
||||
tmp_root_prefix / "envs" / env_name
|
||||
|
||||
helpers.create("-n", env_name, default_channel=False)
|
||||
|
||||
"""Attempts to install a .tar.bz2 package from a local directory."""
|
||||
file_path = Path(__file__).parent / "data" / "cph_test_data-0.0.1-0.tar.bz2"
|
||||
res = helpers.install("-n", env_name, file_path, "--json", default_channel=False)
|
||||
|
||||
assert len(res["actions"]["LINK"]) == 1
|
||||
pkg = res["actions"]["LINK"][0]
|
||||
|
||||
assert pkg["name"] == "cph_test_data"
|
||||
assert pkg["version"] == "0.0.1"
|
||||
assert pkg["fn"] == "cph_test_data-0.0.1-0.tar.bz2"
|
||||
assert pkg["channel"].startswith("file:///")
|
||||
assert pkg["channel"].endswith("data")
|
||||
assert pkg["url"].startswith("file:///")
|
||||
assert pkg["url"].endswith("cph_test_data-0.0.1-0.tar.bz2")
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.platform == "darwin" and platform.machine() == "arm64",
|
||||
reason="Python 3.7.9 not available",
|
||||
|
|
Loading…
Reference in New Issue