Debian Codegraph @

testsuite/tests/publish/tarball-repo/test.py

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