Exemplo n.º 1
0
def verify_manifest():
    target = os.path.join("alire", "releases", "xxx-0.0.0.toml")
    assert os.path.isfile(target), \
        "Index manifest not found at expected location"
    # Minimally check the expected contents are in the file
    assert "[origin]" in content_of(target)
    assert "url" in content_of(target)
Exemplo n.º 2
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)
Exemplo n.º 3
0
def verify():
    """
    Check that the lockfile is only in the new location, with proper contents
    """
    assert isfile(alr_lockfile()) and not isfile(old_lockfile), \
        "Unexpected lockfile placement"
    assert content_of(alr_lockfile()) == proper_content, "bad contents"
Exemplo n.º 4
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()
Exemplo n.º 5
0
Arquivo: test.py Projeto: onox/alr
def make_manifest(var_def):
    """ Make an hello_world manifest that include the variable definitions
    passed as argument.
    """
    dst = os.path.join("my_index", "index", "he", "hello_world",
                       "hello_world-0.1.0.toml")

    src = "manifest.toml"

    # Remove existing manifest, if any
    if os.path.exists(dst):
        os.remove(dst)

    with open(dst, 'w') as f:
        f.write(content_of(src))
        f.write(var_def)
Exemplo n.º 6
0
def check_config(path, profile):
    conf = content_of(path)
    assert_match('.*Build_Profile : Build_Profile_Kind := "%s"' % profile,
                 conf)
Exemplo n.º 7
0
run_alr('init', '--bin', 'xxx')
os.chdir('xxx')

# Manually add a regular and a dynamic dependency
with open(manifest, 'a') as file:
    file.write('[[depends-on]]\n'
               'libhello = "*"\n\n'
               '[[depends-on]]\n'
               '[depends-on."case(os)"."..."]\n'
               'superhello = "*"')

# Check adding a dependency
run_alr('with', 'hello^1')
assert 'hello = "^1"  # This line was added by `alr with`' \
       in content_of(manifest)

# Check removal
run_alr('with', '--del', 'hello')
assert 'hello = "^1"  # This line was added by `alr with`' \
       not in content_of(manifest)

# Check that the dependency that precedes the dynamic expression is removable
run_alr('with', '--del', 'libhello')
assert 'libhello = "*"' not in content_of(manifest)

# Check that empty array entries have been cleaned up
assert content_of(manifest).count('[[depends-on]]') == 1

# Check that removing the dynamic dependency isn't allowed
p = run_alr('with', '--del', 'superhello',
Exemplo n.º 8
0
from drivers.alr import run_alr
from drivers.asserts import assert_eq, assert_match
from drivers.helpers import content_of

manifest = "alire.toml"

run_alr('init', '--bin', 'xxx')
os.chdir('xxx')

# Manually add two dependencies to the same array entry
with open(manifest, 'a') as file:
    file.write('[[depends-on]]\n' 'libhello = "*"\n' 'hello = "*"')

# Check removal in 1st-2nd order
run_alr('with', '--del', 'libhello')
assert 'libhello = "*"' not in content_of(manifest)  # Dep gone
assert 'hello = "*"' in content_of(manifest)  # Dep stays

run_alr('with', '--del', 'hello')
assert 'hello = "*"' not in content_of(manifest)  # No trace of deps anymore
assert '[[depends-on]]' not in content_of(manifest)  # No trace of deps anymore

# Same tests in reverse order of dependency

with open(manifest, 'a') as file:
    file.write('[[depends-on]]\n' 'hello = "*"\n' 'libhello = "*"')

# Check removal in 2nd-1st order
run_alr('with', '--del', 'libhello')
assert 'libhello = "*"' not in content_of(manifest)  # Dep gone
assert 'hello = "*"' in content_of(manifest)  # Dep stays
Exemplo n.º 9
0
Verify that lockfiles are properly [re]moved from $crate/ to $crate/alire/
"""

import os

from drivers.alr import run_alr, init_local_crate, alr_lockfile, alr_with
# from drivers.asserts import assert_eq, assert_match
from drivers.helpers import content_of
from os.path import isfile


old_lockfile = "alire.lock"

init_local_crate()
# Add a dependency so the lockfile is not the same as the default one
default_content = content_of(alr_lockfile())
alr_with("libhello")
proper_content = content_of(alr_lockfile())
assert default_content != proper_content, \
    "error setting up the test (contents should differ)"


def verify():
    """
    Check that the lockfile is only in the new location, with proper contents
    """
    assert isfile(alr_lockfile()) and not isfile(old_lockfile), \
        "Unexpected lockfile placement"
    assert content_of(alr_lockfile()) == proper_content, "bad contents"

Exemplo n.º 10
0
Arquivo: test.py Projeto: onox/alr
def assert_no_origin(crate):
    assert "origin" not in content_of("alire.toml"), \
        "found unexpected contents in manifest of crate " + crate
Exemplo n.º 11
0
Arquivo: test.py Projeto: onox/alr
"""
Test "executable" only appears in --bin initializations
"""

import os.path

from drivers.alr import run_alr
from drivers.asserts import assert_match
from drivers.helpers import content_of

test_dir = os.getcwd()

# Binary crate
run_alr("init", "--bin", "xxx")
assert_match(".*executables = \[", content_of("xxx/alire.toml"))

# Check that it builds and runs
os.chdir("xxx")
run_alr("run")

# Library crate must not provide an executable
os.chdir("..")
run_alr("init", "--lib", "yyy")
assert ".*executables = [" not in content_of("xxx/alire.toml"), \
    "Unexpected contents in manifest"

# Check the default executable is not built/runnable
os.chdir("yyy")
p = run_alr("run", complain_on_error=False)
assert_match(".*Executable .* not found.*", p.out)
Exemplo n.º 12
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"
Exemplo n.º 13
0
"""
Check that an upstream manifest is backed up and not used upon `alr get`
"""

from drivers.alr import run_alr
from drivers.helpers import content_of
from os import chdir, path

# Retrieve a crate that bundles a manifest file
run_alr('get', 'crate')
chdir('crate_1.0.0_filesystem')

upstream = path.join('alire', 'alire.toml.upstream')

# Verify that the manifest has been properly renamed
assert path.isfile(upstream), "Expected backup file missing"

# Verify that contents are as expected in the generated and backed up manifests
assert "badproperty" not in content_of("alire.toml"), \
        "Unexpected contents present in manifest file"
assert "badproperty" in content_of(upstream), \
        "Unexpected contents missing in upstream manifest file"

print('SUCCESS')