Travis: run tests for Windows (#1403)
parent
7918a790b4
commit
37a0e6ebef
|
@ -33,11 +33,8 @@ script:
|
||||||
fi
|
fi
|
||||||
- |
|
- |
|
||||||
if [[ "${TRAVIS_OS_NAME}" == "windows" ]]; then
|
if [[ "${TRAVIS_OS_NAME}" == "windows" ]]; then
|
||||||
echo "Running make.bat..."
|
echo "Running make_tests.bat..."
|
||||||
./make.bat
|
./make_tests.bat
|
||||||
./v.exe -debug -o v2.exe compiler
|
|
||||||
gcc -Ithirdparty/microsoft_craziness -DUNICODE -D_UNICODE .v2.exe.c thirdparty/microsoft_craziness/microsoft_craziness.c -o v2.exe -lole32 -ladvapi32 -loleaut32
|
|
||||||
./v2.exe -o v3.exe compiler
|
|
||||||
fi
|
fi
|
||||||
- |
|
- |
|
||||||
if [[ "${TRAVIS_OS_NAME}" != "windows" ]]; then
|
if [[ "${TRAVIS_OS_NAME}" != "windows" ]]; then
|
||||||
|
|
|
@ -366,7 +366,7 @@ void init_consts();')
|
||||||
// if v.build_mode in [.default, .embed_vlib] {
|
// if v.build_mode in [.default, .embed_vlib] {
|
||||||
if v.pref.build_mode == .default_mode || v.pref.build_mode == .embed_vlib {
|
if v.pref.build_mode == .default_mode || v.pref.build_mode == .embed_vlib {
|
||||||
// vlib can't have `init_consts()`
|
// vlib can't have `init_consts()`
|
||||||
cgen.genln('void init_consts() { \n#ifdef _WIN32\n _setmode(_fileno(stdout), _O_U8TEXT); \n#endif\n g_str_buf=malloc(1000); ${cgen.consts_init.join_lines()} }')
|
cgen.genln('void init_consts() { \n#ifdef _WIN32\n _setmode(_fileno(stdout), _O_U8TEXT); \nSetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), ENABLE_PROCESSED_OUTPUT | 0x0004); // ENABLE_VIRTUAL_TERMINAL_PROCESSING\n#endif\n g_str_buf=malloc(1000); ${cgen.consts_init.join_lines()} }')
|
||||||
// _STR function can't be defined in vlib
|
// _STR function can't be defined in vlib
|
||||||
cgen.genln('
|
cgen.genln('
|
||||||
string _STR(const char *fmt, ...) {
|
string _STR(const char *fmt, ...) {
|
||||||
|
|
|
@ -3086,10 +3086,10 @@ fn (p mut Parser) assert_statement() {
|
||||||
p.gen('bool $tmp = ')
|
p.gen('bool $tmp = ')
|
||||||
p.check_types(p.bool_expression(), 'bool')
|
p.check_types(p.bool_expression(), 'bool')
|
||||||
// TODO print "expected: got" for failed tests
|
// TODO print "expected: got" for failed tests
|
||||||
filename := p.file_path
|
filename := p.file_path.replace('\\', '\\\\')
|
||||||
p.genln(';\n
|
p.genln(';\n
|
||||||
if (!$tmp) {
|
if (!$tmp) {
|
||||||
puts("\\x1B[31mFAILED: $p.cur_fn.name() in $filename:$p.scanner.line_nr\\x1B[0m");
|
println(tos2("\\x1B[31mFAILED: $p.cur_fn.name() in $filename:$p.scanner.line_nr\\x1B[0m"));
|
||||||
g_test_ok = 0 ;
|
g_test_ok = 0 ;
|
||||||
// TODO
|
// TODO
|
||||||
// Maybe print all vars in a test function if it fails?
|
// Maybe print all vars in a test function if it fails?
|
||||||
|
|
|
@ -6,28 +6,6 @@ module term
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
// Calling this functions enables color terminal output on windows
|
|
||||||
// Maybe implement a way to auto run an init function when a module
|
|
||||||
// is imported on a certain os. for example to run this?
|
|
||||||
pub fn enable_term_color_win() {
|
|
||||||
mode_wanted := os.ENABLE_PROCESSED_OUTPUT | os.ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
|
||||||
mut mode_current := 0
|
|
||||||
h_output := C.GetStdHandle(os.STD_OUTPUT_HANDLE)
|
|
||||||
if h_output == os.INVALID_HANDLE_VALUE {
|
|
||||||
panic('term.enable_term_color_win(): error getting output handle.')
|
|
||||||
}
|
|
||||||
if !C.GetConsoleMode(h_output, &mode_current) {
|
|
||||||
panic('term.enable_term_color_win(): error getting console mode.')
|
|
||||||
}
|
|
||||||
if mode_wanted == mode_current {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !C.SetConsoleMode(h_output, mode_wanted) {
|
|
||||||
panic('term.enable_term_color_win(): error setting console mode.')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn format(msg, open, close string) string {
|
pub fn format(msg, open, close string) string {
|
||||||
enable_term_color_win()
|
|
||||||
return _format(msg, open, close)
|
return _format(msg, open, close)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue