Skip to content

Commit

Permalink
tools: fix already installed detection when running v install --once …
Browse files Browse the repository at this point in the history
…without args (#19838)
  • Loading branch information
ttytm committed Nov 12, 2023
1 parent e1312d0 commit 744b92a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cmd/tools/vpm/dependency_test.v
Expand Up @@ -49,14 +49,17 @@ fn test_install_dependencies_in_module_dir() {
}
assert v_mod.dependencies == ['markdown', 'pcre', 'https://github.com/spytheman/vtray']
// Run `v install`
res := os.execute_or_exit('${v} install')
mut res := os.execute_or_exit('${v} install --once')
assert res.output.contains('Detected v.mod file inside the project directory. Using it...'), res.output
assert res.output.contains('Installing `markdown`'), res.output
assert res.output.contains('Installing `pcre`'), res.output
assert res.output.contains('Installing `vtray`'), res.output

assert get_mod_name(os.join_path(test_path, 'markdown', 'v.mod')) == 'markdown'
assert get_mod_name(os.join_path(test_path, 'pcre', 'v.mod')) == 'pcre'
assert get_mod_name(os.join_path(test_path, 'vtray', 'v.mod')) == 'vtray'
res = os.execute_or_exit('${v} install --once')
assert res.output.contains('All modules are already installed.'), res.output
}

fn test_resolve_external_dependencies_during_module_install() {
Expand Down
3 changes: 2 additions & 1 deletion cmd/tools/vpm/install.v
Expand Up @@ -43,6 +43,7 @@ fn vpm_install(query []string) {
vpm_log(@FILE_LINE, @FN, 'Installed modules: ${installed_modules}')

if installed_modules.len > 0 && settings.is_once {
num_to_install := vpm_modules.len + external_modules.len
mut already_installed := []string{}
if external_modules.len > 0 {
mut i_deleted := []int{}
Expand Down Expand Up @@ -70,7 +71,7 @@ fn vpm_install(query []string) {
}
if already_installed.len > 0 {
verbose_println('Already installed modules: ${already_installed}')
if already_installed.len == query.len {
if already_installed.len == num_to_install {
println('All modules are already installed.')
exit(0)
}
Expand Down

0 comments on commit 744b92a

Please sign in to comment.