diff --git a/.travis.yml b/.travis.yml index 08e5e815b9..67f9d89f45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,10 +38,15 @@ script: fi - | if [[ "${TRAVIS_OS_NAME}" == "windows" ]]; then + git clone --depth=1 https://github.com/ubawurinna/freetype-windows-binaries thirdparty/freetype/ + ##echo "Just running ./make.bat to produce v.exe" + ##./make.bat + ##echo "Running only the repl tests directly" + ##./v.exe ./compiler/tests/repl/repl_test.v echo "Testing msvc bootstrapping" - #./make_msvc.bat + ./make_msvc.bat echo "Running make_tests.bat..." - #./make_tests.bat + ./make_tests.bat fi - | if [[ "${TRAVIS_OS_NAME}" != "windows" ]]; then diff --git a/compiler/tests/fn_test.v b/compiler/tests/fn_test.v index 77f53b7fc6..436aa4c0b0 100644 --- a/compiler/tests/fn_test.v +++ b/compiler/tests/fn_test.v @@ -76,6 +76,7 @@ fn test_mut_array() { mut nums := [1, 2, 3] modify_array(mut nums) //assert nums.len == 4 + println(nums) assert nums[0] == 20 assert nums[1] == 4 assert nums[2] == 6 diff --git a/compiler/tests/repl/.gitattributes b/compiler/tests/repl/.gitattributes new file mode 100644 index 0000000000..217b7a8570 --- /dev/null +++ b/compiler/tests/repl/.gitattributes @@ -0,0 +1,2 @@ + +*.repl text=auto eol=lf diff --git a/compiler/tests/repl/repl_test.v b/compiler/tests/repl/repl_test.v index db1daf42fa..960d4f12a5 100644 --- a/compiler/tests/repl/repl_test.v +++ b/compiler/tests/repl/repl_test.v @@ -1,30 +1,67 @@ import os -fn test_repl() { - test_files := os.walk_ext('.', '.repl') - wd := os.getwd() + '/' - for file in test_files { - content := os.read_file(file) or { - assert false - break - } - input_temporary_filename := 'input_temporary_filename.txt' - input := content.all_before('===output===\n') - output := content.all_after('===output===\n') - os.write_file(input_temporary_filename, input) - defer { - os.rm(input_temporary_filename) - } - r := os.exec('./v < $input_temporary_filename') or { - assert false - break - } - result := r.output.replace('>>> ', '').replace('>>>', '').replace('... ', '').all_after('Use Ctrl-C or `exit` to exit\n').replace( wd, '' ) - assert result == output - if result != output { - println(file) - println('Got : $result') - println('Expected : $output') - } - } +fn full_path_to_v() string { + vname := if os.user_os() == 'windows' { 'v.exe' } else { 'v' } + vexec := os.dir(os.dir(os.dir(os.dir( os.executable() )))) + os.PathSeparator + vname + return vexec +} + +fn test_the_v_compiler_can_be_invoked() { + vexec := full_path_to_v() + println('vexecutable: $vexec') + /* + args := os.args + vreal := os.realpath('v') + myself := os.realpath( os.executable() ) + wd := os.getwd() + os.PathSeparator + println('args are: $args') + println('vreal : $vreal') + println('myself : $myself') + println('wd : $wd') + */ + assert vexec != '' + + vcmd := '$vexec --version' + r := os.exec(vcmd) or { panic(err) } + //println('"$vcmd" exit_code: $r.exit_code | output: $r.output') + assert r.exit_code == 0 + + vcmd_error := '$vexec nonexisting.v' + r_error := os.exec(vcmd_error) or { panic(err) } + //println('"$vcmd_error" exit_code: $r_error.exit_code | output: $r_error.output') + assert r_error.exit_code == 1 + assert r_error.output == '`nonexisting.v` does not exist' +} + +fn test_the_v_repl() { + test_files := os.walk_ext('.', '.repl') + wd := os.getwd() + os.PathSeparator + vexec := full_path_to_v() + + for file in test_files { + fcontent := os.read_file(file) or { + assert false + break + } + content := fcontent.replace('\r', '') + input := content.all_before('===output===\n') + output := content.all_after('===output===\n') + + input_temporary_filename := 'input_temporary_filename.txt' + os.write_file(input_temporary_filename, input) + defer { os.rm(input_temporary_filename) } + r := os.exec('$vexec < $input_temporary_filename') or { + assert false + break + } + result := r.output.replace('\r','').replace('>>> ', '').replace('>>>', '').replace('... ', '').all_after('Use Ctrl-C or `exit` to exit\n').replace( wd, '' ) + assert result == output + if result != output { + println(file) + println('Got : |$result|') + println('Expected : |$output|') + } else { + println('Repl file $file is OK') + } + } } diff --git a/examples/database/pg/customer.v b/examples/database/pg/customer.v index 4eeb056901..46e19e3d3d 100644 --- a/examples/database/pg/customer.v +++ b/examples/database/pg/customer.v @@ -1,3 +1,5 @@ +/* + module main import pg @@ -52,5 +54,6 @@ fn main() { db.insert(nc) */ - } + +*/ diff --git a/make_msvc.bat b/make_msvc.bat index b02d7964f5..ef235c6914 100644 --- a/make_msvc.bat +++ b/make_msvc.bat @@ -38,8 +38,8 @@ del v_win.c del v2.exe echo Success +goto :done -exit :nomsvc echo Cannot find an msvc installation @@ -49,6 +49,11 @@ goto :error echo Failed to compile - Create an issue at 'https://github.com/vlang' and tag '@emily33901'! goto :error + :error -echo Exiting from error +echo fail exit /b 1 + + +:done +echo pass diff --git a/make_tests.bat b/make_tests.bat index e80839fbb6..789b226500 100644 --- a/make_tests.bat +++ b/make_tests.bat @@ -18,18 +18,19 @@ echo build v using vc vc.exe -o v.exe compiler if %ERRORLEVEL% NEQ 0 goto :fail -echo build vc.msvc using vc -vc.exe -os msvc -o v.msvc.exe compiler -if %ERRORLEVEL% NEQ 0 goto :fail setlocal EnableDelayedExpansion echo testing v v test v if %ERRORLEVEL% NEQ 0 goto :fail -echo testing v.msvc -os msvc -v.msvc.exe -os msvc test v -if %ERRORLEVEL% NEQ 0 goto :fail +echo skipping build vc.msvc using vc +REM vc.exe -os msvc -o v.msvc.exe compiler +REM if %ERRORLEVEL% NEQ 0 goto :fail + +echo skipping testing v.msvc -os msvc +REM v.msvc.exe -os msvc test v +REM if %ERRORLEVEL% NEQ 0 goto :fail goto :done diff --git a/vlib/freetype/freetype.v b/vlib/freetype/freetype.v index 2dfc187047..102f37cde1 100644 --- a/vlib/freetype/freetype.v +++ b/vlib/freetype/freetype.v @@ -13,6 +13,9 @@ import ( gl ) +#flag windows -I @VROOT/thirdparty/freetype/include +#flag windows -L @VROOT/thirdparty/freetype/win64 + #flag darwin -I/usr/local/include/freetype2 #flag darwin -I/opt/local/include/freetype2 #flag -lfreetype diff --git a/vlib/os/os.v b/vlib/os/os.v index 6f78e508ca..bcb75fc933 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -325,7 +325,7 @@ fn pclose(f *FILE) int { return C._pclose(f) } $else { - return C.pclose(f) + return C.pclose(f) / 256 // WEXITSTATUS() } } @@ -349,7 +349,7 @@ pub fn exec(cmd string) ?Result { res += tos(buf, strlen(buf)) } res = res.trim_space() - exit_code := pclose(f)/256 + exit_code := pclose(f) //if exit_code != 0 { //return error(res) //} @@ -509,19 +509,13 @@ pub fn get_line() string { // get_raw_line returns a one-line string from stdin along with '\n' if there is any pub fn get_raw_line() string { $if windows { - max := 512 // MAX_PATH * sizeof(wchar_t) - buf := &u16(malloc(max*2)) - h_input := C.GetStdHandle(STD_INPUT_HANDLE) - if h_input == INVALID_HANDLE_VALUE { - panic('get_raw_line() error getting input handle.') - } - mut nr_chars := 0 - C.ReadConsole(h_input, buf, max, &nr_chars, 0) - if nr_chars == 0 { - return '' - } - return string_from_wide2(buf, nr_chars) - } + maxlinechars := 256 + buf := &u16(malloc(maxlinechars*2)) + res := int( C.fgetws(buf, maxlinechars, C.stdin ) ) + len := int( C.wcslen(buf) ) + if 0 != res { return string_from_wide2( buf, len ) } + return '' + } $else { //u64 is used because C.getline needs a size_t as second argument //Otherwise, it would cause a valgrind warning and may be dangerous diff --git a/vlib/time/time.v b/vlib/time/time.v index 82eec3345c..f00a79f8d8 100644 --- a/vlib/time/time.v +++ b/vlib/time/time.v @@ -15,7 +15,8 @@ const ( $if !windows { #include -#include +//#include +/// ^^^^ including this makes the windows build fail. } struct Time {