ci: set up pg database to test ORM
parent
71c0c4803f
commit
be323e2fb6
|
@ -29,7 +29,7 @@ jobs:
|
||||||
node-version: 12.x
|
node-version: 12.x
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
brew install freetype glfw openssl
|
brew install freetype glfw openssl postgres
|
||||||
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
|
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
|
||||||
- name: Build V
|
- name: Build V
|
||||||
run: make && ./v -o v v.v
|
run: make && ./v -o v v.v
|
||||||
|
@ -37,6 +37,10 @@ jobs:
|
||||||
run: ./v -o v2 v.v && ./v2 -o v3 v.v
|
run: ./v -o v2 v.v && ./v2 -o v3 v.v
|
||||||
- name: Test symlink
|
- name: Test symlink
|
||||||
run: sudo ./v 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
|
- name: Test v->c
|
||||||
run: ./v test-compiler
|
run: ./v test-compiler
|
||||||
- name: Test v binaries
|
- name: Test v binaries
|
||||||
|
|
|
@ -19,7 +19,7 @@ pub mut:
|
||||||
fail string
|
fail string
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_test_sesion(vargs string) TestSession {
|
pub fn new_test_session(vargs string) TestSession {
|
||||||
return TestSession{
|
return TestSession{
|
||||||
vexe: vexe_path()
|
vexe: vexe_path()
|
||||||
vargs: vargs
|
vargs: vargs
|
||||||
|
@ -50,6 +50,9 @@ pub fn (ts mut TestSession) test() {
|
||||||
$if windows {
|
$if windows {
|
||||||
if file.contains('sqlite') { continue }
|
if file.contains('sqlite') { continue }
|
||||||
}
|
}
|
||||||
|
$if !macos {
|
||||||
|
if file.contains('customer') { continue }
|
||||||
|
}
|
||||||
$if msvc {
|
$if msvc {
|
||||||
if file.contains('asm') { continue }
|
if file.contains('asm') { continue }
|
||||||
}
|
}
|
||||||
|
@ -108,11 +111,11 @@ pub fn v_build_failing(zargs string, folder string) bool {
|
||||||
parent_dir := os.dir(vexe)
|
parent_dir := os.dir(vexe)
|
||||||
vlib_should_be_present( parent_dir )
|
vlib_should_be_present( parent_dir )
|
||||||
vargs := zargs.replace(vexe, '')
|
vargs := zargs.replace(vexe, '')
|
||||||
|
|
||||||
eprintln(main_label)
|
eprintln(main_label)
|
||||||
eprintln(' v compiler args: "$vargs"')
|
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')
|
files := os.walk_ext(filepath.join(parent_dir, folder),'.v')
|
||||||
mains := files.filter(!it.contains('modules'))
|
mains := files.filter(!it.contains('modules'))
|
||||||
mut rebuildable_mains := mains
|
mut rebuildable_mains := mains
|
||||||
|
@ -148,8 +151,8 @@ pub fn building_any_v_binaries_failed() bool {
|
||||||
parent_dir := os.dir(vexe)
|
parent_dir := os.dir(vexe)
|
||||||
testing.vlib_should_be_present( parent_dir )
|
testing.vlib_should_be_present( parent_dir )
|
||||||
os.chdir( parent_dir )
|
os.chdir( parent_dir )
|
||||||
|
|
||||||
mut failed := false
|
mut failed := false
|
||||||
v_build_commands := [
|
v_build_commands := [
|
||||||
|
|
||||||
// '$vexe -o v_g -g v.v',
|
// '$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',
|
'$vexe -o v_prod -prod v.v',
|
||||||
]
|
]
|
||||||
|
|
||||||
mut bmark := benchmark.new_benchmark()
|
mut bmark := benchmark.new_benchmark()
|
||||||
bok := term.ok_message('OK')
|
bok := term.ok_message('OK')
|
||||||
bfail := term.fail_message('FAIL')
|
bfail := term.fail_message('FAIL')
|
||||||
for cmd in v_build_commands {
|
for cmd in v_build_commands {
|
||||||
bmark.step()
|
bmark.step()
|
||||||
if build_v_cmd_failed(cmd) {
|
if build_v_cmd_failed(cmd) {
|
||||||
bmark.fail()
|
bmark.fail()
|
||||||
|
@ -174,10 +177,10 @@ pub fn building_any_v_binaries_failed() bool {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
bmark.ok()
|
bmark.ok()
|
||||||
eprintln(bmark.step_message('$cmd => ${bok}'))
|
eprintln(bmark.step_message('$cmd => ${bok}'))
|
||||||
}
|
}
|
||||||
bmark.stop()
|
bmark.stop()
|
||||||
eprintln( bmark.total_message( 'building v binaries' ) )
|
eprintln( bmark.total_message( 'building v binaries' ) )
|
||||||
|
|
||||||
return failed
|
return failed
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
testing
|
testing
|
||||||
benchmark
|
benchmark
|
||||||
filepath
|
filepath
|
||||||
)
|
)
|
||||||
|
|
||||||
pub const (
|
pub const (
|
||||||
v_modules_path = os.home_dir() + '.vmodules'
|
v_modules_path = os.home_dir() + '.vmodules'
|
||||||
|
@ -21,18 +21,18 @@ fn v_test_compiler(vargs string){
|
||||||
vexe := testing.vexe_path()
|
vexe := testing.vexe_path()
|
||||||
parent_dir := os.dir(vexe)
|
parent_dir := os.dir(vexe)
|
||||||
testing.vlib_should_be_present( parent_dir )
|
testing.vlib_should_be_present( parent_dir )
|
||||||
|
|
||||||
// Changing the current directory is needed for some of the compiler tests,
|
// Changing the current directory is needed for some of the compiler tests,
|
||||||
// compiler/tests/local_test.v and compiler/tests/repl/repl_test.v
|
// compiler/tests/local_test.v and compiler/tests/repl/repl_test.v
|
||||||
os.chdir( parent_dir )
|
os.chdir( parent_dir )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if !os.exists(parent_dir + '/v.v') {
|
if !os.exists(parent_dir + '/v.v') {
|
||||||
eprintln('v.v is missing, it must be next to the V executable')
|
eprintln('v.v is missing, it must be next to the V executable')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Make sure v.c can be compiled without warnings
|
// Make sure v.c can be compiled without warnings
|
||||||
$if macos {
|
$if macos {
|
||||||
if os.exists('/v.v') {
|
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 :)')
|
eprintln('v.c can be compiled without warnings. This is good :)')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
building_tools_failed := testing.v_build_failing(vargs, 'tools')
|
building_tools_failed := testing.v_build_failing(vargs, 'tools')
|
||||||
|
|
||||||
eprintln('\nTesting all _test.v files...')
|
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.files << os.walk_ext(parent_dir, '_test.v')
|
||||||
compiler_test_session.test()
|
compiler_test_session.test()
|
||||||
eprintln( compiler_test_session.benchmark.total_message('running V tests') )
|
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')
|
building_examples_failed := testing.v_build_failing(vargs, 'examples')
|
||||||
|
|
||||||
eprintln('')
|
eprintln('')
|
||||||
building_live_failed := testing.v_build_failing(vargs + '-live',
|
building_live_failed := testing.v_build_failing(vargs + '-live',
|
||||||
filepath.join( 'examples', 'hot_reload'))
|
filepath.join( 'examples', 'hot_reload'))
|
||||||
|
|
||||||
eprintln('')
|
eprintln('')
|
||||||
|
@ -73,12 +73,12 @@ fn v_test_compiler(vargs string){
|
||||||
}
|
}
|
||||||
vmark.stop()
|
vmark.stop()
|
||||||
eprintln( 'Installing a v module took: ' + vmark.total_duration().str() + 'ms')
|
eprintln( 'Installing a v module took: ' + vmark.total_duration().str() + 'ms')
|
||||||
|
|
||||||
if building_tools_failed ||
|
if building_tools_failed ||
|
||||||
compiler_test_session.failed ||
|
compiler_test_session.failed ||
|
||||||
building_examples_failed ||
|
building_examples_failed ||
|
||||||
building_live_failed {
|
building_live_failed {
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ module main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
os
|
os
|
||||||
testing
|
testing
|
||||||
)
|
)
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
|
@ -29,8 +29,8 @@ pub fn main() {
|
||||||
eprintln('Use `v test-compiler` instead.')
|
eprintln('Use `v test-compiler` instead.')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
mut ts := testing.new_test_sesion(args_before)
|
mut ts := testing.new_test_session(args_before)
|
||||||
for targ in args_after.split(' ') {
|
for targ in args_after.split(' ') {
|
||||||
if os.exists(targ) && targ.ends_with('_test.v') {
|
if os.exists(targ) && targ.ends_with('_test.v') {
|
||||||
ts.files << targ
|
ts.files << targ
|
||||||
|
|
|
@ -223,7 +223,7 @@ fn test_right_with_n_bigger_than_array_size() {
|
||||||
// mut b := a[10..]
|
// mut b := a[10..]
|
||||||
mut b := a.right(10)
|
mut b := a.right(10)
|
||||||
assert b.len == 0
|
assert b.len == 0
|
||||||
|
|
||||||
// also check that the result of a.right
|
// also check that the result of a.right
|
||||||
// is an array of the same type/element size as a:
|
// is an array of the same type/element size as a:
|
||||||
b << 5
|
b << 5
|
||||||
|
@ -285,6 +285,10 @@ const (
|
||||||
N = 5
|
N = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
|
struct Foooj {
|
||||||
|
a [N]int
|
||||||
|
}
|
||||||
|
|
||||||
fn test_fixed() {
|
fn test_fixed() {
|
||||||
mut nums := [4]int
|
mut nums := [4]int
|
||||||
assert nums[0] == 0
|
assert nums[0] == 0
|
||||||
|
@ -368,7 +372,7 @@ fn test_single_element() {
|
||||||
assert a[0] == 1
|
assert a[0] == 1
|
||||||
assert a[1] == 2
|
assert a[1] == 2
|
||||||
println(a)
|
println(a)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_find_index() {
|
fn test_find_index() {
|
||||||
// string
|
// string
|
||||||
|
@ -452,7 +456,7 @@ fn test_filter() {
|
||||||
d := c.filter(it.len > 1)
|
d := c.filter(it.len > 1)
|
||||||
assert d[0] == 'is'
|
assert d[0] == 'is'
|
||||||
assert d[1] == 'awesome'
|
assert d[1] == 'awesome'
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_map() {
|
fn test_map() {
|
||||||
a := [1, 2, 3, 4, 5, 6]
|
a := [1, 2, 3, 4, 5, 6]
|
||||||
|
@ -471,8 +475,8 @@ fn test_map() {
|
||||||
assert bools[0] == true
|
assert bools[0] == true
|
||||||
assert bools[1] == false
|
assert bools[1] == false
|
||||||
assert bools[2] == false
|
assert bools[2] == false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_array_str() {
|
fn test_array_str() {
|
||||||
numbers := [1, 2, 3]
|
numbers := [1, 2, 3]
|
||||||
|
@ -502,7 +506,7 @@ fn test_sort() {
|
||||||
assert nums[2] == 42
|
assert nums[2] == 42
|
||||||
assert nums[3] == 67
|
assert nums[3] == 67
|
||||||
assert nums[4] == 108
|
assert nums[4] == 108
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -514,10 +518,10 @@ fn test_for_last() {
|
||||||
s += '$num'
|
s += '$num'
|
||||||
if !last {
|
if !last {
|
||||||
s += ', '
|
s += ', '
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s += ']'
|
s += ']'
|
||||||
assert s == '[1, 2, 3, 4]'
|
assert s == '[1, 2, 3, 4]'
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue