v / cmd / tools / vpm / update_test.v
52 lines · 47 sloc · 2.02 KB · 9317f4b5078c90aee517b362099900f8f34c21ef
Raw
1// vtest build: !musl? && !sanitized_job?
2// vtest retry: 3
3import os
4import rand
5import test_utils { cmd_fail, cmd_ok }
6
7const v = os.quoted_path(@VEXE)
8const test_path = os.join_path(os.vtmp_dir(), 'vpm_update_test_${rand.ulid()}')
9
10fn testsuite_begin() {
11 $if !network ? {
12 eprintln('> skipping ${@FILE}, when `-d network` is missing')
13 exit(0)
14 }
15 dump(test_path)
16 test_utils.set_test_env(test_path)
17}
18
19fn testsuite_end() {
20 os.rmdir_all(test_path) or {}
21}
22
23// Tests if `v update` detects installed modules and runs successfully.
24fn test_update() {
25 os.execute_or_exit('${v} install pcre')
26 os.execute_or_exit('${v} install nedpals.args')
27 os.execute_or_exit('${v} install https://github.com/spytheman/vtray')
28 res := cmd_ok(@LOCATION, '${v} update')
29 assert res.output.contains('Updating module `pcre`'), res.output
30 assert res.output.contains('Updating module `nedpals.args`'), res.output
31 assert res.output.contains('Updating module `spytheman.vtray`'), res.output
32 assert res.output.contains('Skipping download count increment for `nedpals.args`.'), res.output
33 assert res.output.contains('Skipping download count increment for `pcre`.'), res.output
34}
35
36fn test_update_idents() {
37 mut res := cmd_ok(@LOCATION, '${v} update pcre')
38 assert res.output.contains('Updating module `pcre`'), res.output
39 res = cmd_ok(@LOCATION, '${v} update nedpals.args spytheman.vtray')
40 assert res.output.contains('Updating module `spytheman.vtray`'), res.output
41 assert res.output.contains('Updating module `nedpals.args`'), res.output
42 // Update installed module using its url.
43 res = cmd_ok(@LOCATION, '${v} update https://github.com/spytheman/vtray')
44 assert res.output.contains('Updating module `spytheman.vtray`'), res.output
45 // Try update not installed.
46 res = cmd_fail(@LOCATION, '${v} update vsl')
47 assert res.output.contains('failed to find `vsl`'), res.output
48 // Try update mixed.
49 res = cmd_fail(@LOCATION, '${v} update pcre vsl')
50 assert res.output.contains('Updating module `pcre`'), res.output
51 assert res.output.contains('failed to find `vsl`'), res.output
52}
53