| 1 | // vtest build: !musl? && !sanitized_job? |
| 2 | // vtest retry: 3 |
| 3 | import os |
| 4 | import rand |
| 5 | import test_utils { cmd_fail, cmd_ok } |
| 6 | |
| 7 | const v = os.quoted_path(@VEXE) |
| 8 | const test_path = os.join_path(os.vtmp_dir(), 'vpm_update_test_${rand.ulid()}') |
| 9 | |
| 10 | fn 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 | |
| 19 | fn testsuite_end() { |
| 20 | os.rmdir_all(test_path) or {} |
| 21 | } |
| 22 | |
| 23 | // Tests if `v update` detects installed modules and runs successfully. |
| 24 | fn 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 `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 | |
| 36 | fn 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 vtray') |
| 40 | assert res.output.contains('Updating module `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 `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 | |