예제 #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 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"
예제 #3
0
파일: test.py 프로젝트: pyjarrett/alire
def check_child(version, output, pinned):
    # Verify output
    assert_match('.*\n'
                 'Dependencies \(solution\):\n'
                 '   libchild=' + version + (' \(pinned\)' if pinned else "") +
                 '\n'
                 '   libparent=1\.0\.0\n'
                 '.*\n',
                 output,
                 flags=re.S)

    # Verify lockfile
    check_line_in(alr_lockfile(), 'name = "libchild"')
    check_line_in(alr_lockfile(), f'version = "{version}"')
예제 #4
0
파일: test.py 프로젝트: pyjarrett/alire
def check_child(version, output, pinned):
    # Verify output
    assert_match('.*\n'
                 'Dependencies \(solution\):\n'
                 '   libchild=' + version + (" \(pinned\)" if pinned else "") +
                 '.*\n',
                 output,
                 flags=re.S)

    # Verify lockfile
    check_line_in(alr_lockfile(), 'name = "libchild"')
    check_line_in(alr_lockfile(), f'version = "{version}"')

    # Verify dependency folders
    assert os.path.exists('alire/cache/dependencies/libchild_' + version +
                          '_filesystem')
예제 #5
0
파일: test.py 프로젝트: pyjarrett/alire
"""
Verify that pins when there is no lockfile are correctly applied on first run
"""

from drivers.alr import run_alr, alr_pin, init_local_crate, alr_lockfile
from drivers.asserts import assert_eq

import os

fake_dep = "unobtainium"

# Create a crate
init_local_crate()

# Add a dependency
run_alr("with", fake_dep, force=True)

# Pin to a local folder
os.mkdir(fake_dep)
alr_pin(fake_dep, path=fake_dep)

# Remove the lockfile
os.remove(alr_lockfile())

# Check that the pin is applied on next command run
p = run_alr("pin")
assert_eq(f"{fake_dep} file:{fake_dep} \n", p.out)

print('SUCCESS')
예제 #6
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"

예제 #7
0
"""
A test that a bad lockfile is recovered from (losing pins)
"""

from drivers.alr import run_alr, alr_lockfile, init_local_crate

import os
import re

# Create a new crate
init_local_crate(name='xxx')

# And muck its lockfile
BADLINE = "SHOULND'T BE HERE"

with open(alr_lockfile(), "a") as myfile:
    myfile.write(BADLINE)

# Run a command that requires the lockfile
p = run_alr('show')

# Now the lockfile should be recreated and proper, so check no bad line:
with open(alr_lockfile(), 'r') as myfile:
    for line in myfile:
        assert line != BADLINE, "Unexpected line found in file"

print('SUCCESS')