Skip to content

Commit

Permalink
tools: use VPM_NO_INCREMENT env var to skip dl count increment when…
Browse files Browse the repository at this point in the history
… testing vpm (#19756)
  • Loading branch information
ttytm authored Nov 4, 2023
1 parent c2a3eef commit 244411a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/tools/vpm/common.v
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ fn ensure_vcs_is_installed(vcs &VCS) ! {
}

fn increment_module_download_count(name string) ! {
if no_dl_count_increment {
println('Skipping download count increment for "${name}".')
return
}
mut errors := []string{}

for server_url in vpm_server_urls {
Expand Down
2 changes: 2 additions & 0 deletions cmd/tools/vpm/install_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const (

fn testsuite_begin() {
os.setenv('VMODULES', test_path, true)
os.setenv('VPM_NO_INCREMENT', '1', true)
}

fn testsuite_end() {
Expand All @@ -19,6 +20,7 @@ fn testsuite_end() {
fn test_install_from_vpm_ident() {
res := os.execute('${v} install nedpals.args')
assert res.exit_code == 0, res.output
assert res.output.contains('Skipping download count increment for "nedpals.args".')
mod := vmod.from_file(os.join_path(test_path, 'nedpals', 'args', 'v.mod')) or {
assert false, err.str()
return
Expand Down
1 change: 1 addition & 0 deletions cmd/tools/vpm/vpm.v
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct VCS {

const (
settings = &VpmSettings{}
no_dl_count_increment = os.getenv('VPM_NO_INCREMENT') == '1'
default_vpm_server_urls = ['https://vpm.vlang.io', 'https://vpm.url4e.com']
vpm_server_urls = rand.shuffle_clone(default_vpm_server_urls) or { [] } // ensure that all queries are distributed fairly
valid_vpm_commands = ['help', 'search', 'install', 'update', 'upgrade', 'outdated', 'list',
Expand Down

0 comments on commit 244411a

Please sign in to comment.