Debian Codegraph @

testsuite/tests/publish/pin-removal/test.py

raw
1 """
2 Publish a crate that contains pins, and verify pins are removed in the process
3 """
4
5 import os
6 import shutil
7
8 from drivers.alr import run_alr, init_local_crate, alr_pin, alr_publish, \
9 alr_manifest
10 from drivers.helpers import content_of, init_git_repo
11 from drivers.asserts import assert_eq, assert_match
12 from subprocess import run
13
14 crate = "pinner"
15
16 # We create a repository with the nested crate that will act as the upstream
17 # remote repository:
18 start_dir = os.getcwd()
19 init_local_crate(crate)
20
21 # And add the pin directly in the remote
22 alr_pin("unobtanium", path="/")
23
24 # We can now create the upstream repo
25 os.chdir("..")
26 commit = init_git_repo(crate)
27 os.rename(crate, f"{crate}.upstream")
28
29 # We clone the project to obtain our local copy
30 assert run(["git", "clone", f"{crate}.upstream", crate]).returncode == 0
31
32 # We enter the clone
33 os.chdir(crate)
34
35 # Verify the pin is there
36 assert_match(".*\[\[pins\]\].*", content_of(alr_manifest()))
37
38 # We publish with the pin in the manifest
39 p = alr_publish(crate, "0.1.0-dev",
40 index_path=os.path.join(start_dir, "my_index"),
41 submit=False,
42 quiet=False)
43
44 # Verify warning during publishing
45 assert_match(".*contains pins that will be removed.*", p.out)
46
47 # Verify no pins in the generated file
48 assert "[[pins]]" not in \
49 content_of(os.path.join("alire", "releases", f"{crate}-0.1.0-dev.toml")), \
50 "Unexpected contents in published file"
51
52 print('SUCCESS')