| 1 |
""" |
| 2 |
Tests tarball publishing from a git repository with custom manifest location |
| 3 |
""" |
| 4 |
|
| 5 |
from drivers.alr import init_local_crate, run_alr |
| 6 |
from drivers.helpers import init_git_repo |
| 7 |
from shutil import copyfile |
| 8 |
from subprocess import run |
| 9 |
|
| 10 |
import os |
| 11 |
|
| 12 |
# Prepare our "remote" repo |
| 13 |
init_local_crate("xxx", enter=True) |
| 14 |
os.rename("alire.toml", "xxx.toml") |
| 15 |
|
| 16 |
# Initialize a repo right here |
| 17 |
init_git_repo(".") |
| 18 |
|
| 19 |
# Clone it to simulate it's our local copy |
| 20 |
os.chdir("..") |
| 21 |
os.rename("xxx", "xxx_upstream") |
| 22 |
run(["git", "clone", "xxx_upstream", "xxx"]).check_returncode() |
| 23 |
os.chdir("xxx") |
| 24 |
|
| 25 |
# Publish it. We need to give input to alr, so we directly call it. We use the |
| 26 |
# generated location as the "online" location, and this works because we are |
| 27 |
# forcing. ".tgz" is used, as bzip2 is not supported by `git archive`. |
| 28 |
p = run(["alr", "-q", "-f", "-n", "publish", "--skip-build", "--tar", |
| 29 |
"--manifest", "xxx.toml"], |
| 30 |
input=f"file:{os.getcwd()}/alire/archives/xxx-0.1.0-dev.tgz\n".encode()) |
| 31 |
p.check_returncode() |
| 32 |
|
| 33 |
# Verify the index manifest has been generated |
| 34 |
assert os.path.isfile("./alire/releases/xxx-0.1.0-dev.toml") |
| 35 |
|
| 36 |
os.chdir("..") |
| 37 |
|
| 38 |
# Add this manifest to our local index, and retrieve + build the crate |
| 39 |
os.makedirs("my_index/index/xx/xxx") |
| 40 |
copyfile("xxx/alire/releases/xxx-0.1.0-dev.toml", |
| 41 |
"my_index/index/xx/xxx/xxx-0.1.0-dev.toml") |
| 42 |
|
| 43 |
run_alr("get", "--build", "xxx") # Should not err |
| 44 |
|
| 45 |
print('SUCCESS') |