1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ci: set up pg database to test ORM

This commit is contained in:
Alexander Medvednikov 2019-12-06 02:11:39 +03:00
parent 71c0c4803f
commit be323e2fb6
5 changed files with 48 additions and 37 deletions

View File

@ -29,7 +29,7 @@ jobs:
node-version: 12.x
- name: Install dependencies
run: |
brew install freetype glfw openssl
brew install freetype glfw openssl postgres
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
- name: Build V
run: make && ./v -o v v.v
@ -37,6 +37,10 @@ jobs:
run: ./v -o v2 v.v && ./v2 -o v3 v.v
- name: Test symlink
run: sudo ./v symlink
- name: Set up pg database
run: |
psql -U postgres -c 'create database customerdb;'
psql -d customerdb -f examples/database/pg/mydb.sql
- name: Test v->c
run: ./v test-compiler
- name: Test v binaries

View File

@ -19,7 +19,7 @@ pub mut:
fail string
}
pub fn new_test_sesion(vargs string) TestSession {
pub fn new_test_session(vargs string) TestSession {
return TestSession{
vexe: vexe_path()
vargs: vargs
@ -50,6 +50,9 @@ pub fn (ts mut TestSession) test() {
$if windows {
if file.contains('sqlite') { continue }
}
$if !macos {
if file.contains('customer') { continue }
}
$if msvc {
if file.contains('asm') { continue }
}
@ -108,11 +111,11 @@ pub fn v_build_failing(zargs string, folder string) bool {
parent_dir := os.dir(vexe)
vlib_should_be_present( parent_dir )
vargs := zargs.replace(vexe, '')
eprintln(main_label)
eprintln(' v compiler args: "$vargs"')
mut session := new_test_sesion( vargs )
mut session := new_test_session( vargs )
files := os.walk_ext(filepath.join(parent_dir, folder),'.v')
mains := files.filter(!it.contains('modules'))
mut rebuildable_mains := mains
@ -148,8 +151,8 @@ pub fn building_any_v_binaries_failed() bool {
parent_dir := os.dir(vexe)
testing.vlib_should_be_present( parent_dir )
os.chdir( parent_dir )
mut failed := false
mut failed := false
v_build_commands := [
// '$vexe -o v_g -g v.v',
@ -160,11 +163,11 @@ pub fn building_any_v_binaries_failed() bool {
'$vexe -o v_prod -prod v.v',
]
mut bmark := benchmark.new_benchmark()
bok := term.ok_message('OK')
bfail := term.fail_message('FAIL')
for cmd in v_build_commands {
for cmd in v_build_commands {
bmark.step()
if build_v_cmd_failed(cmd) {
bmark.fail()
@ -174,10 +177,10 @@ pub fn building_any_v_binaries_failed() bool {
continue
}
bmark.ok()
eprintln(bmark.step_message('$cmd => ${bok}'))
eprintln(bmark.step_message('$cmd => ${bok}'))
}
bmark.stop()
eprintln( bmark.total_message( 'building v binaries' ) )
return failed
}

View File

@ -5,7 +5,7 @@ import (
testing
benchmark
filepath
)
)
pub const (
v_modules_path = os.home_dir() + '.vmodules'
@ -21,18 +21,18 @@ fn v_test_compiler(vargs string){
vexe := testing.vexe_path()
parent_dir := os.dir(vexe)
testing.vlib_should_be_present( parent_dir )
// Changing the current directory is needed for some of the compiler tests,
// compiler/tests/local_test.v and compiler/tests/repl/repl_test.v
os.chdir( parent_dir )
/*
if !os.exists(parent_dir + '/v.v') {
eprintln('v.v is missing, it must be next to the V executable')
exit(1)
}
*/
// Make sure v.c can be compiled without warnings
$if macos {
if os.exists('/v.v') {
@ -44,11 +44,11 @@ fn v_test_compiler(vargs string){
eprintln('v.c can be compiled without warnings. This is good :)')
}
}
building_tools_failed := testing.v_build_failing(vargs, 'tools')
eprintln('\nTesting all _test.v files...')
mut compiler_test_session := testing.new_test_sesion( vargs )
mut compiler_test_session := testing.new_test_session( vargs )
compiler_test_session.files << os.walk_ext(parent_dir, '_test.v')
compiler_test_session.test()
eprintln( compiler_test_session.benchmark.total_message('running V tests') )
@ -57,7 +57,7 @@ fn v_test_compiler(vargs string){
building_examples_failed := testing.v_build_failing(vargs, 'examples')
eprintln('')
building_live_failed := testing.v_build_failing(vargs + '-live',
building_live_failed := testing.v_build_failing(vargs + '-live',
filepath.join( 'examples', 'hot_reload'))
eprintln('')
@ -73,12 +73,12 @@ fn v_test_compiler(vargs string){
}
vmark.stop()
eprintln( 'Installing a v module took: ' + vmark.total_duration().str() + 'ms')
if building_tools_failed ||
compiler_test_session.failed ||
building_examples_failed ||
if building_tools_failed ||
compiler_test_session.failed ||
building_examples_failed ||
building_live_failed {
exit(1)
}
}

View File

@ -2,7 +2,7 @@ module main
import (
os
testing
testing
)
pub fn main() {
@ -29,8 +29,8 @@ pub fn main() {
eprintln('Use `v test-compiler` instead.')
exit(1)
}
mut ts := testing.new_test_sesion(args_before)
mut ts := testing.new_test_session(args_before)
for targ in args_after.split(' ') {
if os.exists(targ) && targ.ends_with('_test.v') {
ts.files << targ

View File

@ -223,7 +223,7 @@ fn test_right_with_n_bigger_than_array_size() {
// mut b := a[10..]
mut b := a.right(10)
assert b.len == 0
// also check that the result of a.right
// is an array of the same type/element size as a:
b << 5
@ -285,6 +285,10 @@ const (
N = 5
)
struct Foooj {
a [N]int
}
fn test_fixed() {
mut nums := [4]int
assert nums[0] == 0
@ -368,7 +372,7 @@ fn test_single_element() {
assert a[0] == 1
assert a[1] == 2
println(a)
}
}
fn test_find_index() {
// string
@ -452,7 +456,7 @@ fn test_filter() {
d := c.filter(it.len > 1)
assert d[0] == 'is'
assert d[1] == 'awesome'
}
}
fn test_map() {
a := [1, 2, 3, 4, 5, 6]
@ -471,8 +475,8 @@ fn test_map() {
assert bools[0] == true
assert bools[1] == false
assert bools[2] == false
}
}
fn test_array_str() {
numbers := [1, 2, 3]
@ -502,7 +506,7 @@ fn test_sort() {
assert nums[2] == 42
assert nums[3] == 67
assert nums[4] == 108
}
}
@ -514,10 +518,10 @@ fn test_for_last() {
s += '$num'
if !last {
s += ', '
}
}
}
}
s += ']'
assert s == '[1, 2, 3, 4]'
}
}
*/