From 194ee2ce13a18e4acd3a3ca39a9c12ee41306867 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Mon, 30 Jan 2017 18:38:16 +0100 Subject: [PATCH] add tests for requires and conflicts Signed-off-by: Igor Gnatenko --- test.py | 229 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 224 insertions(+), 5 deletions(-) diff --git a/test.py b/test.py index b18eca6..61aa9b6 100644 --- a/test.py +++ b/test.py @@ -42,13 +42,19 @@ def run(*params): return out.split("\n")[:-1] -@pytest.mark.parametrize("toml,expected", [ +@pytest.mark.parametrize("toml, provides, requires, conflicts", [ + + # Basic provides (""" [package] name = "hello" version = "0.0.0" """, - ["crate(hello) = 0.0.0"]), + ["crate(hello) = 0.0.0"], + [], + []), + + # Basic provides for feature (""" [package] name = "hello" @@ -58,7 +64,220 @@ def run(*params): color = [] """, ["crate(hello) = 1.2.3", - "crate(hello/color) = 1.2.3"]), + "crate(hello/color) = 1.2.3"], + [], + []), + + # Caret requirements + (""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = "^0" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) >= 0.0.0"], + ["crate(libc) >= 1.0.0"]), + (""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = "^0.0" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) >= 0.0.0"], + ["crate(libc) >= 0.1.0"]), + (""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = "^0.0.3" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) >= 0.0.3"], + ["crate(libc) >= 0.0.4"]), + (""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = "^0.2.3" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) >= 0.2.3"], + ["crate(libc) >= 0.3.0"]), + (""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = "^1" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) >= 1.0.0"], + ["crate(libc) >= 2.0.0"]), + (""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = "^1.2" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) >= 1.2.0"], + ["crate(libc) >= 2.0.0"]), + (""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = "^1.2.3" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) >= 1.2.3"], + ["crate(libc) >= 2.0.0"]), + + # Tilde requirements + (""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = "~1" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) >= 1.0.0"], + ["crate(libc) >= 2.0.0"]), + (""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = "~1.2" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) >= 1.2.0"], + ["crate(libc) >= 1.3.0"]), + (""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = "~1.2.3" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) >= 1.2.3"], + ["crate(libc) >= 1.3.0"]), + + # Wildcard requirements + pytest.mark.xfail((""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = "*" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) >= 0.0.0"], + [])), + pytest.mark.xfail((""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = "1.*" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) >= 1.0.0"], + ["crate(libc) >= 2.0.0"])), + pytest.mark.xfail((""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = "1.2.*" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) >= 1.2.0"], + ["crate(libc) >= 1.3.0"])), + + # Inequality requirements + (""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = ">= 1.2.0" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) >= 1.2.0"], + []), + (""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = "> 1" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) > 1"], + []), + (""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = "< 2" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) < 2"], + []), + (""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = "= 1.2.3" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) = 1.2.3"], + []), + + # Multiple requirements + (""" + [package] + name = "hello" + version = "0.0.0" + + [dependencies] + libc = ">= 1.2, < 1.5" + """, + ["crate(hello) = 0.0.0"], + ["crate(libc) >= 1.2"], + ["crate(libc) >= 1.5"]), + ]) -def test_provides(toml, expected, cargo_toml): - assert run("--provides", cargo_toml(toml)) == expected +def test_depgen(toml, provides, requires, conflicts, cargo_toml): + assert run("--provides", cargo_toml(toml)) == provides + assert run("--requires", cargo_toml(toml)) == requires + assert run("--conflicts", cargo_toml(toml)) == conflicts