Beispiel #1
0
import os
import shutil

from drivers.alr import run_alr, init_local_crate, alr_with, alr_publish
from drivers.helpers import init_git_repo, on_windows, commit_all
# from drivers.asserts import assert_eq, assert_match
from subprocess import run

# We create a repository with two nested crates that will act as the upstream
# remote repository:
start_dir = os.getcwd()
os.mkdir("monoproject.upstream")
os.chdir("monoproject.upstream")
init_local_crate("crate1", enter=False)
os.chdir(start_dir)
commit1 = init_git_repo("monoproject.upstream")

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

# We enter the crate nested inside and publish.
# We are now at monoproject/mycrate.
os.chdir("monoproject")
os.chdir("crate1")
alr_publish("crate1", "0.0.0", index_path=os.path.join(start_dir, "my_index"))

# We create a second crate at another commit
os.chdir(os.path.join(start_dir, "monoproject.upstream"))
init_local_crate("crate2", enter=False)
os.chdir(start_dir)
Beispiel #2
0
from subprocess import run

import os


def verify_manifest():
    target = os.path.join("alire", "releases", "xxx-0.1.0-dev.toml")
    assert os.path.isfile(target), \
        "Index manifest not found at expected location"
    # Clean up for next test
    rmtree(os.path.join("alire", "releases"))


# Prepare our "remote" repo
init_local_crate("xxx", enter=False)
head_commit = init_git_repo("xxx")

# Clone to a "local" repo and set minimal config
assert run(["git", "clone", "xxx", "xxx_local"]).returncode == 0
os.chdir("xxx_local")
assert run(["git", "config", "user.email", "*****@*****.**"]).returncode == 0
assert run(["git", "config", "user.name", "Alire Testsuite"]).returncode == 0

# Tests with different default arguments that must all succeed
run_alr("--force", "publish")
verify_manifest()

run_alr("--force", "publish", ".")
verify_manifest()

run_alr("--force", "publish", ".", "master")
Beispiel #3
0
from drivers.alr import run_alr, alr_pin, init_local_crate
from drivers.asserts import assert_eq, assert_match
from drivers.helpers import init_git_repo, dir_separator

import re
import os

#  We are going to setup xxx --> yyy --> zzz, where xxx and zzz live at the
#  same level, and yyy is at ./nest/yyy. Both yyy and zzz will be git
#  repositories, so we refer to them by their absolute path (as if they were
#  remote URLs)

# zzz crate/repo
init_local_crate(name="zzz", enter=False)
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)
Beispiel #4
0
    run_alr("clean", "--cache")
    assert not os.path.isdir(pin_path)

    # Verify automatic redownload when needed
    run_alr("build")

    # Prepare for next test
    run_alr("with", "--del", "upstream")      # Remove dependency
    p = run_alr("pin")
    assert_eq(f"There are no pins\n", p.out)  # Ensure pin is gone
    shutil.rmtree("alire")                    # Total cleanup outside of alr


# Initialize a git repo that will act as the "online" remote
init_local_crate(name="upstream", binary=False)
head = init_git_repo(".")
os.chdir("..")
os.rename("upstream", "upstream.git")  # so it is recognized as git repo

# Initialize a client crate that will use the remote
init_local_crate()  # This leaves us inside the new crate

# Add using with directly
run_alr("with", "--use", "../upstream.git", "--commit", head)
verify(head)

# Add using with, without head commit
run_alr("with", "--use", "../upstream.git")
verify()

# Pin afterwards, with commit
Beispiel #5
0
from drivers.alr import run_alr, alr_pin, alr_unpin, init_local_crate
from drivers.asserts import assert_eq, assert_match
from drivers.helpers import git_branch, git_head, init_git_repo
from e3.os.fs import touch
from re import escape

import re
import os
import shutil
import subprocess

# "remote" is going to be the remote crate

init_local_crate(name="remote", enter=False)
url = os.path.join(os.getcwd(), "remote")
head1 = init_git_repo("remote")
os.chdir("remote")
default_branch = git_branch()

# Create a second branch and commit for testing
subprocess.run(["git", "checkout", "-b", "devel"]).check_returncode()
touch("telltale")
subprocess.run(["git", "add", "telltale"]).check_returncode()
subprocess.run(["git", "commit", "-m", "branching"]).check_returncode()
os.chdir("..")

# Now pin to the branch, and verify the telltale file exists in the checkout
init_local_crate()
alr_pin("remote", url=url, branch="devel")
p = run_alr("pin")
assert_match("remote file:alire/cache/pins/remote " +
Beispiel #6
0
from drivers.asserts import assert_eq, assert_match
from subprocess import run

crate = "pinner"

# We create a repository with the nested crate that will act as the upstream
# remote repository:
start_dir = os.getcwd()
init_local_crate(crate)

# 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"),
Beispiel #7
0
"""
Tests tarball publishing from a git repository
"""

from drivers.alr import init_local_crate, run_alr
from drivers.helpers import init_git_repo
from shutil import copyfile
from subprocess import run

import os

# Prepare our "remote" repo
init_local_crate("xxx", enter=True)

# Initialize a repo right here
init_git_repo(".")

# Clone it to simulate it's our local copy
os.chdir("..")
os.rename("xxx", "xxx_upstream")
run(["git", "clone", "xxx_upstream", "xxx"]).check_returncode()
os.chdir("xxx")

# Publish it. We need to give input to alr, so we directly call it. We use the
# generated location as the "online" location, and this works because we are
# forcing. ".tgz" is used, as bzip2 is not supported by `git archive`.
p = run(
    ["alr", "-q", "-f", "-n", "publish", "--skip-build", "--tar"],
    input=f"file:{os.getcwd()}/alire/archives/xxx-0.1.0-dev.tgz\n".encode())
p.check_returncode()
Beispiel #8
0
from drivers.asserts import assert_eq, assert_match
from drivers.helpers import git_blast, git_head, init_git_repo
from e3.os.fs import touch
from re import escape

import re
import os
import shutil
import subprocess

#  "remote" is going to be the remote crate. Two other crates will depend on it
#  with different branches/commits etc

init_local_crate(name="zzz", enter=False)
url = os.path.join(os.getcwd(), "zzz")
head1 = init_git_repo("zzz")
os.chdir("zzz")

# Create a second branch and commit for testing
subprocess.run(["git", "checkout", "-b", "devel"]).check_returncode()
touch("x")
subprocess.run(["git", "add", "x"]).check_returncode()
subprocess.run(["git", "commit", "-m", "branching"]).check_returncode()
head2 = git_head()
os.chdir("..")


#  In this function we will test that two crates with the same remote works,
#  for several combinations
def should_work(commit="", branch=""):
    os.mkdir("nest")
Beispiel #9
0

# Local pinnable crate
init_local_crate("yyy", enter=False)
yyy_path = "../yyy"

# Local pinnable raw project
os.mkdir("zzz")
zzz_path = "../zzz"

# Simple pin, no restrictions
check_equivalent("yyy", path=yyy_path)
check_equivalent("zzz", path=zzz_path)

# Prepare repository
head = init_git_repo("yyy")
branch = git_branch("yyy")
os.rename("yyy", "yyy.git")  # to be recognizable as a git url
url = "../yyy.git"

# Simple git remote, explicit crate
check_equivalent(crate="yyy", url=url)

# Explicit commit
check_equivalent(crate="yyy", url=url, commit=head)

# Explicit branch
check_equivalent(crate="yyy", url=url, branch=branch)

print('SUCCESS')