Debian Codegraph @

testsuite/tests/publish/tarball-plaindir-nonstd/test.py

raw
1 """
2 Tests tarball publishing from non-vcs directory with custom manifest location
3 """
4
5 from drivers.alr import init_local_crate, run_alr
6 from glob import glob
7 from shutil import copyfile
8 from subprocess import run
9
10 import drivers.helpers
11 import os
12
13 # Prepare our "remote" repo
14 init_local_crate("xxx", enter=True)
15 # with custom manifest location
16 os.rename("alire.toml", "xxx.toml")
17
18 canary = "canary.txt"
19
20 # Create a canary file to double-check that it does not make into the tarball
21 with open(os.path.join("alire", canary), "wt") as file:
22 print(file, "...\n")
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.
27 p = run(["alr", "-q", "-f", "-n", "publish", "--skip-build", "--tar",
28 "--manifest", "xxx.toml"],
29 input=f"file:{os.getcwd()}/alire/archives/xxx-0.1.0-dev.tbz2\n".encode())
30 p.check_returncode()
31
32 # Verify the generated file does not contain the alire folder
33 p = run(["tar", "tf", "alire/archives/xxx-0.1.0-dev.tbz2"],
34 capture_output=True)
35 p.check_returncode()
36 assert "xxx-0.0.0/alire/" not in p.stdout.decode(), \
37 "Unexpected contents in tarball: " + p.stdout.decode()
38
39 # Verify the index manifest has been generated
40 assert os.path.isfile("./alire/releases/xxx-0.1.0-dev.toml")
41
42 os.chdir("..")
43
44 # Add this manifest to our local index, and retrieve + build the crate
45 os.makedirs("my_index/index/xx/xxx")
46 copyfile("xxx/alire/releases/xxx-0.1.0-dev.toml",
47 "my_index/index/xx/xxx/xxx-0.1.0-dev.toml")
48
49 run_alr("get", "--build", "xxx") # Should not err
50
51 # Verify the canary didn't made through
52 os.chdir(glob("xxx_*")[0])
53 assert not os.path.isfile(os.path.join("alire", canary)), \
54 "Found canary file that should not be there"
55
56 print('SUCCESS')