Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cmd/v/v.v
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,17 @@ fn main() {
if prefs.is_help {
invoke_help_and_exit(args)
}
$if windows {
// An invalid `-cc` setting should take precedence over an unknown command,
// but must not affect commands that do not compile code.
if builder.should_find_windows_host_c_compiler(prefs) && prefs.ccompiler_set_by_flag
&& prefs.ccompiler != 'msvc' {
mut probe := builder.Builder{
pref: unsafe { prefs }
Comment thread
GGRei marked this conversation as resolved.
}
probe.find_win_cc() or { builder.verror(err.msg()) }
}
}

other_commands := ['run', 'crun', 'build', 'build-module', 'help', 'version', 'new', 'init',
'install', 'link', 'list', 'outdated', 'remove', 'search', 'show', 'unlink', 'update',
Expand Down
24 changes: 24 additions & 0 deletions cmd/v/v_windows_test.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module main

import os

fn test_invalid_c_compiler_is_reported_before_command_dispatch() {
$if !windows {
return
}
missing_compiler := 'missing_compiler_27868'
expected_error := 'builder error: C compiler `${missing_compiler}` was requested with `-cc`, but was not found.'
for command in ['', 'not-a-command'] {
result := os.execute('${os.quoted_path(@VEXE)} -cc ${missing_compiler} ${command}')
assert result.exit_code == 1
assert result.output.contains(expected_error), result.output
}
help_result := os.execute('${os.quoted_path(@VEXE)} -cc ${missing_compiler} help')
assert help_result.exit_code == 1
assert help_result.output.contains('provide only one help topic.'), help_result.output
assert !help_result.output.contains(expected_error), help_result.output

version_result := os.execute('${os.quoted_path(@VEXE)} -cc ${missing_compiler} version')
assert version_result.exit_code == 0, version_result.output
assert !version_result.output.contains(expected_error), version_result.output
}
Loading