예제 #1
0
파일: test.py 프로젝트: pyjarrett/alire
def check(pin, error):
    """
    Insert a pin at the end of the manifest, verify that it is rejected, and
    remove it from the manifest. Check the error produced against the one given
    """
    with open(alr_manifest(), "a") as manifest:
        manifest.write("\n[[pins]]\n" + pin + "\n")

    # Remove lockfile to ensure reload
    if os.path.exists(alr_lockfile()):
        os.remove(alr_lockfile())

    p = run_alr("pin", complain_on_error=False)
    assert p.status != 0, "Unexpected success for pin: " + pin
    assert_match(".*Cannot continue with invalid session.*" + error + ".*\n",
                 p.out)

    # Restore the manifest
    lines = lines_of(alr_manifest())
    lines.pop()
    with open(alr_manifest(), "w") as manifest:
        manifest.write("".join(lines))

    # Verify the manifest is OK again
    run_alr("pin")
예제 #2
0
def try_path(path: str):
    """
    Pin the parent crate using the given path, that must be equivalent to ".."
    """

    if os.path.isdir("child"):
        rmtree("child")

    init_local_crate("child")
    alr_pin("parent", path=path, manual=False)
    # This should result in the pin being simplified to ".."

    assert "parent = { path='..' }\n" in lines_of(alr_manifest()), \
        "Unexpected manifest contents: " + content_of(alr_manifest())

    os.chdir("..")  # We entered during init_local_crate()
예제 #3
0
"""
Test that an empty nested table in dependencies does not cause an error.
Bugfix #906: https://github.com/alire-project/alire/pull/906
"""

from drivers.alr import run_alr, init_local_crate, alr_manifest
from drivers.asserts import assert_match

init_local_crate()

# Create the problematic table
with open(alr_manifest(), "at") as manifest:
    manifest.write("[[depends-on]]\n")
    manifest.write("[depends-on.'case(os)'.linux."
                   "'case(distribution)'.ubuntu]\n")

# The following command failed pre-bugfix, all is OK if it does not complain
p = run_alr("update")

print('SUCCESS')
예제 #4
0
# And add the pin directly in the remote
alr_pin("unobtanium", path="/")

# We can now create the upstream repo
os.chdir("..")
commit = init_git_repo(crate)
os.rename(crate, f"{crate}.upstream")

# We clone the project to obtain our local copy
assert run(["git", "clone", f"{crate}.upstream", crate]).returncode == 0

# We enter the clone
os.chdir(crate)

# Verify the pin is there
assert_match(".*\[\[pins\]\].*", content_of(alr_manifest()))

# We publish with the pin in the manifest
p = alr_publish(crate,
                "0.0.0",
                index_path=os.path.join(start_dir, "my_index"),
                submit=False,
                quiet=False)

# Verify warning during publishing
assert_match(".*contains pins that will be removed.*", p.out)

# Verify no pins in the generated file
assert "[[pins]]" not in \
    content_of(os.path.join("alire", "releases", f"{crate}-0.0.0.toml")), \
    "Unexpected contents in published file"
예제 #5
0
def check_config(path, profile, expected_switches=[]):
    conf = content_of(path)
    assert_match('.*Build_Profile : Build_Profile_Kind := "%s"' % profile,
                 conf)

    for sw in expected_switches:
        assert_match('.*"%s"' % sw, conf)


lib1_config = "../lib_1/config/lib_1_config.gpr"
lib2_config = "../lib_2/config/lib_2_config.gpr"
bin_config = "config/bin_1_config.gpr"

# Check if we can change the profile of a dependency
manifests = [alr_manifest(), '../lib_1/alire.toml', '../lib_2/alire.toml']

for path in manifests:
    with open(path, "a") as manifest:
        manifest.write('[build-switches]\n')
        manifest.write('"*".optimization = ["-opt-switch", "-opt-switch2"]\n')
        manifest.write('"*".debug_info = ["-debug-info-switch"]\n')
        manifest.write('"*".runtime_checks = ["-runtime-checks-switch"]\n')
        manifest.write('"*".compile_checks = ["-compile-checks-switch"]\n')
        manifest.write('"*".contracts = ["-contracts-switch"]\n')
        manifest.write(
            '"*".style_checks = ["-style-switch", "-style-switch2"]\n')

run_alr('update')

expected_switches = [