mirror of
https://github.com/vlang/v.git
synced 2025-09-13 01:16:02 -04:00
tools.vpm: add support for env variable VPM_FAIL_ON_PROMPT
, to prevent getting stuck in test scenarios with conflicting module dir names (#19960)
This commit is contained in:
parent
e3d306d1d2
commit
b60ef550bd
@ -233,6 +233,10 @@ fn (m Module) confirm_install() bool {
|
||||
} else {
|
||||
install_version := at_version(if m.version == '' { 'latest' } else { m.version })
|
||||
println('Module `${m.name}${at_version(m.installed_version)}` is already installed at `${m.install_path_fmted}`.')
|
||||
if settings.fail_on_prompt {
|
||||
vpm_error('VPM should not have entered a confirmation prompt.')
|
||||
exit(1)
|
||||
}
|
||||
input := os.input('Replace it with `${m.name}${install_version}`? [Y/n]: ')
|
||||
match input.to_lower() {
|
||||
'', 'y' {
|
||||
|
@ -16,6 +16,7 @@ fn testsuite_begin() {
|
||||
os.setenv('VMODULES', test_path, true)
|
||||
os.setenv('VPM_DEBUG', '', true)
|
||||
os.setenv('VPM_NO_INCREMENT', '1', true)
|
||||
os.setenv('VPM_FAIL_ON_PROMPT', '1', true)
|
||||
}
|
||||
|
||||
fn testsuite_end() {
|
||||
|
@ -14,6 +14,7 @@ fn testsuite_begin() {
|
||||
os.setenv('VMODULES', test_path, true)
|
||||
os.setenv('VPM_DEBUG', '', true)
|
||||
os.setenv('VPM_NO_INCREMENT', '1', true)
|
||||
os.setenv('VPM_FAIL_ON_PROMPT', '1', true)
|
||||
}
|
||||
|
||||
fn testsuite_end() {
|
||||
|
@ -13,6 +13,9 @@ mut:
|
||||
server_urls []string
|
||||
vmodules_path string
|
||||
no_dl_count_increment bool
|
||||
// To ensure that some test scenarios with conflicting module directory names do not get stuck in prompts.
|
||||
// It is intended that VPM does not display a prompt when `VPM_FAIL_ON_PROMPT` is set.
|
||||
fail_on_prompt bool
|
||||
// git is used by default. URL installations can specify `--hg`. For already installed modules
|
||||
// and VPM modules that specify a different VCS in their `v.mod`, the VCS is validated separately.
|
||||
vcs VCS
|
||||
@ -35,5 +38,6 @@ fn init_settings() VpmSettings {
|
||||
vcs: supported_vcs[if '--hg' in opts { 'hg' } else { 'git' }]
|
||||
vmodules_path: os.vmodules_dir()
|
||||
no_dl_count_increment: os.getenv('CI') != '' || (no_inc_env != '' && no_inc_env != '0')
|
||||
fail_on_prompt: os.getenv('VPM_FAIL_ON_PROMPT') != ''
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user