Debian Codegraph @

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

raw
1 """
2 Tests tarball publishing from non-vcs directory
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
16 canary = "canary.txt"
17
18 # Create a canary file to double-check that it does not make into the tarball
19 with open(os.path.join("alire", canary), "wt") as file:
20 print(file, "...\n")
21
22 # Publish it. We need to give input to alr, so we directly call it. We use the
23 # generated location as the "online" location, and this works because we are
24 # forcing.
25 p = run(["alr", "-q", "-f", "-n", "publish", "--skip-build", "--tar"],
26 input=f"file:{os.getcwd()}/alire/archives/xxx-0.1.0-dev.tbz2\n".encode())
27 p.check_returncode()
28
29 # Verify the generated file does not contain the alire folder
30 p = run(["tar", "tf", "alire/archives/xxx-0.1.0-dev.tbz2"],
31 capture_output=True)
32 p.check_returncode()
33 assert "xxx-0.0.0/alire/" not in p.stdout.decode(), \
34 "Unexpected contents in tarball: " + p.stdout.decode()
35
36 # Verify the index manifest has been generated
37 assert os.path.isfile("./alire/releases/xxx-0.1.0-dev.toml")
38
39 os.chdir("..")
40
41 # Add this manifest to our local index, and retrieve + build the crate
42 os.makedirs("my_index/index/xx/xxx")
43 copyfile("xxx/alire/releases/xxx-0.1.0-dev.toml",
44 "my_index/index/xx/xxx/xxx-0.1.0-dev.toml")
45
46 run_alr("get", "--build", "xxx") # Should not err
47
48 # Verify the canary didn't made through
49 os.chdir(glob("xxx_*")[0])
50 assert not os.path.isfile(os.path.join("alire", canary)), \
51 "Found canary file that should not be there"
52
53 print('SUCCESS')