Esempio n. 1
0
os.chdir("..")

init_local_crate("dep_targeted")
alr_with("gnat_native")  # This step also installs the native compiler
os.chdir("..")

# First we check that a root generic dependency mixes well with either of the
# two dependencies

init_local_crate("xxx_generic_generic")
run_alr("with", "--use=../dep_generic")
alr_with("gnat")

# gnat x gnat results in the external available compiler being used, preferred
# over the native also available compiler (but not selected)
match_solution(f"gnat={version} (gnat_external) (installed)", escape=True)

# If we add a precise dependency on e.g. the installed native compiler, this
# should override the external compiler
alr_with("gnat_native")
match_solution("gnat=8888.0.0 (gnat_native) (installed)", escape=True)
match_solution("gnat_native=8888.0.0 (installed)", escape=True)

# Let us swap the generic dependency with a targeted dependency, starting from
# scratch

os.chdir("..")
init_local_crate("xxx_generic_targeted")
run_alr("with", "--use=../dep_targeted")
alr_with("gnat")
Esempio n. 2
0
        print(f"erroneous path was: {paths[0]}")
        raise


# First we test manual installation
run_alr("toolchain", "--install", "gnat_native")
check_content("gnat_native")

# Uninstall the compiler and verify absence
run_alr("toolchain", "--uninstall", "gnat_native", quiet=False)
paths = contents(cache_dir, "gnat_native")
assert len(paths) == 0, "Unexpected contents: " + str(paths)

# Require the external compiler and verify no trace appears in install folder
# nor in local folder
init_local_crate("xxx")
alr_with("gnat_external")
match_solution("gnat_external=.* \(installed\)")
paths = contents(cache_dir, "gnat_external")
assert len(paths) == 0, "Unexpected contents: " + str(paths)
paths = contents(".", "gnat_external")
assert len(paths) == 0, "Unexpected contents: " + str(paths)

# Require a cross compiler and verify it is automatically installed
alr_with("gnat_external", delete=True, manual=False)
alr_with("gnat_cross_1")
match_solution("gnat_cross_1=.* \(installed\)")
check_content("gnat_cross_1")

print('SUCCESS')
Esempio n. 3
0
import subprocess
import os

from drivers.alr import run_alr, init_local_crate, alr_with
from drivers.asserts import assert_eq, assert_match, match_solution
from re import escape as e

# This test relies on two crates in the index: crate_lone=1.0 is unavailable.
# crate_equiv=2.0 also provides crate_lone=1.0 and crate_virtual=1.0.
# Finally there is crate_lone=2.0 that is available and nobody else provides.

init_local_crate("xxx")
alr_with("crate_lone^1")

# Since crate_lone is unavailable, in the solution we should find crate_equiv:
match_solution("crate_lone=2.0.0 (crate_equiv)", escape=True)

# Likewise, a dependency on crate_virtual will be fulfilled by the same crate
alr_with("crate_virtual")
match_solution("crate_virtual=2.0.0 (crate_equiv)", escape=True)

# Whereas a dependency on crate_equiv will show plainly without equivalence
alr_with("crate_equiv")
match_solution(
    "Dependencies (solution):\n"
    "   crate_equiv=2.0.0 (origin: filesystem)\n"
    "   crate_lone=2.0.0 (crate_equiv) (origin: filesystem)\n"
    "   crate_virtual=2.0.0 (crate_equiv) (origin: filesystem)\n",
    escape=True)

# Finally check that a dependency on crate_lone^2 is only fulfilled by itself
Esempio n. 4
0
import subprocess
import os

from drivers.alr import run_alr, init_local_crate, alr_with
from drivers.asserts import assert_eq, assert_match, match_solution
from re import escape as e

# This test relies on three crates in the toolchain_index:
# crate_conflict=1.2.3 conflicts with crate_lone* and crate_virtual*
# crate_lone is a regular crate
# crate_virtual has no releases, but is provided by crate_conflict_1
# Crate conflict cannot appear with any of the others in a solution, because of
# its [forbids] table.

init_local_crate("conflict_lone")
alr_with("crate_conflict")
alr_with("crate_lone")
match_solution("crate_(conflict|lone)=.* \(origin:.*\)")  # has origin: solved
match_solution("crate_(conflict|lone)\* \(direct,missed\)")
# Because of load/solving details, we do not know which of the two crates is
# going to be missed/accepted in the solution, so we check there is one of each

init_local_crate("conflict_virtual")
alr_with("crate_conflict")
alr_with("crate_virtual")
match_solution("crate_(conflict|virtual)=.* \(origin:.*\)")
match_solution("crate_(conflict|virtual)\* \(direct,missed\)")

print('SUCCESS')
Esempio n. 5
0
    "gnat_external.*Available.*Detected.*\n",
    p.out)

# Capture version
version = re.search("gnat_external ([0-9.]+)", p.out, re.MULTILINE).group(1)

print(version)
# When no compiler is selected, since the external one is available, it should
# be used before offering to download a new compiler.

# Create a crate for our experiments
init_local_crate("xxx")

# Check that a generic dependency results in the external being used
alr_with("gnat")
match_solution(f"gnat={version} (gnat_external) (installed)", escape=True)

# Check that requesting a version different to the one externally available
# results in missing compiler, as Alire won't try to install one.
alr_with("gnat", delete=True, manual=False)
alr_with(f"gnat/={version}")
match_solution(f"gnat/={version} (direct,hinted)", escape=True)
# Hinted because we know the crate exists as external

# Now, if the user installs a cross compiler, it will be used

run_alr("toolchain", "--install", "gnat_cross_2")
run_alr("update")
match_solution("gnat=1.0.0 (gnat_cross_2) (installed)", escape=True)

# Likewise, if we install a native compiler, it will be preferred to a
Esempio n. 6
0
"""
Test that two crates providing the same third crate are compatible
"""

import subprocess
import os

from drivers.alr import run_alr, init_local_crate, alr_with
from drivers.asserts import assert_eq, assert_match, match_solution
from re import escape as e

# This test relies on two crates in the index:
# crate_virt_1=2.0 also provides crate_virtual=1.0
# crate_virt_2=1.0 also provides crate_virtual=1.0

# Verify that these crates provide the same virtual release
p = run_alr("show", "crate_virt_1")
assert_match(".*Provides: crate_virtual=1.0.0.*", p.out)
p = run_alr("show", "crate_virt_2")
assert_match(".*Provides: crate_virtual=1.0.0.*", p.out)

init_local_crate("xxx")
alr_with("crate_virt_1")
alr_with("crate_virt_2")

# Both crates must appear in the solution
match_solution("crate_virt_1=2.0.0 (origin: filesystem)", escape=True)
match_solution("crate_virt_2=1.0.0 (origin: filesystem)", escape=True)

print('SUCCESS')
Esempio n. 7
0
import os

from drivers.alr import run_alr, init_local_crate, alr_with
from drivers.asserts import assert_eq, assert_match, match_solution
from re import escape as e

# Select the default preferred compiler, which is the native packaged one
run_alr("toolchain", "--select")

# Init a crate depending on gnat

init_local_crate("xxx")
alr_with("gnat*")

# Will appear in the solution as generic fulfilled by the preferred compiler
match_solution("gnat=8888.0.0 (gnat_native) (installed)", escape=True)

# Selecting another default will cause a corresponding change in the solution
run_alr("config", "--set", "toolchain.use.gnat", "gnat_cross_2=1")
run_alr("update")
match_solution("gnat=1.0.0 (gnat_cross_2) (installed)", escape=True)

# Adding another incompatible compiler dependency should result in overriding
# the configured one
alr_with("gnat_cross_1")

# Both dependencies will appear in the solution, matching the same crate
match_solution("gnat=9999.0.0 \(gnat_cross_1\) \(installed\).*"
               "gnat_cross_1=9999.0.0 \(installed\)")

print('SUCCESS')
Esempio n. 8
0
"""

import subprocess
import os

from drivers.alr import run_alr, init_local_crate, alr_with
from drivers.asserts import assert_eq, assert_match, match_solution
from re import escape as e

# This test relies on two crates in the toolchain_index:
# crate_subst both provides and forbids crate_real
# crate_real is a regular crate only provided by itself and crate_subst

# The following has only one possible solution, which is for crate_subst
# providing both dependencies.
init_local_crate("test")
alr_with("crate_real")

# Check that this is initially solved with the regular crate. This is currently
# guaranteed by the solver attempting crates in alphabetical order. We will
# need eventually a way to disable equivalences (via pins, or solver config).
match_solution("crate_real=1.0.0 (origin: filesystem)", escape=True)

# Let's add the drop-in equivalent crate that provides+forbids crate_lone
alr_with("crate_subst")
match_solution("crate_real=1.0.0 (crate_subst) (origin: filesystem)",
               escape=True)  # This is the substituted release
match_solution("crate_subst=1.0.0 (origin: filesystem)", escape=True)

print('SUCCESS')
Esempio n. 9
0
    ".*\n"  # Headers
    "gnat_external.*Available.*Detected.*\n",
    p.out)

# Capture version
version = re.search("gnat_external ([0-9.]+)", p.out, re.MULTILINE).group(1)

# When no compiler is selected, only the gnat_external one should be used
# unless a targeted compiler dependency is used

# Create a crate for our experiments
init_local_crate("xxx")

# Check that a generic dependency results in the external being used
alr_with("gnat")
match_solution(f"gnat={version} (gnat_external) (installed)", escape=True)

# Check that adding a second dependency on native packaged compiler is honored.
# Both dependencies should appear in the solution.
alr_with("gnat_native")
match_solution("gnat=8888.0.0 (gnat_native) (installed)", escape=True)
match_solution("gnat_native=8888.0.0 (installed)", escape=True)

# The previous dependency also should have caused the installation of the
# native compiler as an available compiler, which we will check:
p = run_alr("toolchain")
assert_match(".*gnat_native.*8888.0.0.*Available.*", p.out)

# Move to a new crate
init_local_crate("yyy")