from drivers.helpers import dir_separator, path_separator # Initialize test crate run_alr("init", "--bin", "xxx") os.chdir("xxx") # Link a folder which also contains crate metadata run_alr("with", "--use=../my_index/crates/crate_1234") expected_gpr_path = [] expected_gpr_path += [['.*', 'my_index', 'crates', 'crate_1234']] expected_gpr_path += [['.*', 'my_index', 'crates', 'crate_1234', 'nested']] expected_gpr_path += [['.*', 'xxx']] for i, path in enumerate(expected_gpr_path): if platform.system() == 'Windows': expected_gpr_path[i] = "\\\\".join(path) else: expected_gpr_path[i] = "/".join(path) expected_gpr_path = os.pathsep.join(expected_gpr_path) # Check paths are proper (base and one extra nested) p = run_alr("setenv") assert_match(('export GPR_PROJECT_PATH="' + expected_gpr_path + '"\n' + 'export ALIRE="True"\n').replace('/', re.escape(dir_separator())), p.out) print('SUCCESS')
import os import re from drivers.alr import run_alr from drivers.asserts import assert_match from drivers.helpers import dir_separator from glob import glob # Retrieve a crate run_alr('get', 'hello=1') target = glob('hello*')[0] # Initialize a workspace run_alr('init', '--bin', 'xxx') os.chdir('xxx') # Pin the hello crate as local dir dependency run_alr('with', 'hello', '--use', '..' + dir_separator() + target) # Verify that hello dependencies are detected and used p = run_alr('with', '--solve') assert_match( '''.*Dependencies \(solution\): hello=1\.0\.0 .* libhello=1\.1\.0 .*''', # we skip non-relevant details p.out, flags=re.S) print('SUCCESS')
# Initialize test crate run_alr("init", "--bin", "xxx") os.chdir("xxx") # Link a folder which also contains crate metadata for a project file inside a # 'nested'-named folder run_alr("with", "--use=../my_index/crates/crate_1234") expected_gpr_path = [] expected_gpr_path += [['.*', 'my_index', 'crates', 'crate_1234', 'nested']] expected_gpr_path += [['.*', 'xxx']] for i, path in enumerate(expected_gpr_path): if platform.system() == 'Windows': expected_gpr_path[i] = "\\\\".join(path) else: expected_gpr_path[i] = "/".join(path) expected_gpr_path = os.pathsep.join(expected_gpr_path) # Check paths are proper (base and one extra nested) p = run_alr("printenv") assert_match(('.*' 'export ALIRE="True"\n' '.*' 'export GPR_PROJECT_PATH="' + expected_gpr_path + '"\n' '.*').replace('/', re.escape(dir_separator())), p.out) print('SUCCESS')
# Prepare a cycle init_local_crate("xxx", enter=False) init_local_crate("yyy", enter=False) init_local_crate("zzz") alr_pin("xxx", path="../xxx", update=False) os.chdir("..") os.chdir("yyy") alr_pin("zzz", path="../zzz", update=False) os.chdir("..") os.chdir("xxx") alr_pin("yyy", path="../yyy", update=False) # At this point, xxx --> yyy --> zzz --> xxx p = run_alr("pin", complain_on_error=False) s = re.escape(dir_separator()) assert_match( ".*" "ERROR: Pin circularity detected when adding pin zzz --> xxx:\n" f"ERROR: Last manifest in the cycle is .*{s}zzz{s}alire.toml\n", p.out) # Verify that the buggy case that was reported does not happen again # In this case, we have # dep1 -> dep2 -> dep3 -> dep4; dep1 -> dep3; dep1 -> dep4; dep2 -> dep4 init_local_crate("dep4", enter=False) init_local_crate("dep3") alr_with("dep4", path="../dep4")
with_project('xxx.gpr', 'libhello') # Verify it doesn't build without it p = run_alr('build', complain_on_error=False) assert p.status != 0, "Build should fail" # Add normally and then pin, check that it builds run_alr('with', 'libhello') run_alr('pin', 'libhello', '--use', '../crates/libhello_1.0.0') run_alr('build') # Check the pin shows in the solution p = run_alr('with', '--solve') # For this match we don't know where the test is temporarily put, so we skip # over some parts of the output s = re.escape(dir_separator()) # platform-dependent assert_match('.*Dependencies \(external\):.*' 'libhello\* \(direct,linked' ',pin=.*' + s + 'pin__pin-dir' + s + 'crates' + s + 'libhello_1.0.0\).*', p.out, flags=re.S) # Check that unpinning the dependency works and now the dependency is show # as a regular one from the index run_alr('pin', '--unpin', 'libhello') p = run_alr('show', '--solve') assert_match('.*Dependencies \(solution\):' '.*libhello=1.0.0.*', p.out, flags=re.S)
# Retrieve a crate run_alr('get', 'hello=1') target = glob('hello*')[0] # Initialize a workspace run_alr('init', '--bin', 'xxx') os.chdir('xxx') # Add a dependency as pinned dir without metadata; this should succeed run_alr('with', 'nothello', '--use', '..') # Detect a repin is rejected unless forced p = run_alr('with', 'nothello', '--use', '..' + dir_separator() + target, complain_on_error=False) assert_match(".*nothello is already pinned with pin .*", p.out) # Try to repin to a dir with valid crate metadata p = run_alr('with', 'nothello', '--use', '..' + dir_separator() + target, complain_on_error=False, force=True) # Expected error assert_match('.*expected nothello but found hello.*', p.out) # skip test-specific path
path_zzz = os.path.join(os.getcwd(), "zzz") init_git_repo(path_zzz) # yyy crate/repo os.mkdir("nest") os.chdir("nest") init_local_crate(name="yyy") alr_pin("zzz", url=path_zzz) os.chdir("..") path_yyy = os.path.join(os.getcwd(), "yyy") init_git_repo(path_yyy) # xxx crate os.chdir("..") init_local_crate() alr_pin("yyy", url=path_yyy) # Should work properly p = run_alr("pin") # Absolute path to simulate a remote URL is platform dependent: s = dir_separator() assert_match( re.escape('yyy file:alire/cache/pins/yyy ') + # local rel path '.*' + re.escape(f'{s}nest{s}yyy\n') + # remote abs url re.escape('zzz file:alire/cache/pins/zzz ') + # local rel path '.*' + re.escape(f'{s}zzz \n'), # remote abs url p.out) print('SUCCESS')