tests: build vweb example

pull/5265/head
Alexander Medvednikov 2020-06-07 15:44:33 +02:00
parent 8277c976a8
commit 931cf86cc3
3 changed files with 65 additions and 55 deletions

View File

@ -231,7 +231,14 @@ pub fn v_build_failing_skipped(zargs string, folder string, skipped []string) bo
mut mains := []string{}
for f in files {
if !f.contains('modules') && !f.contains('preludes') {
if f.contains('life_gg') || f.contains('/graph.v') || f.contains('/vweb/') || f.contains('/pg/') || f.contains('rune.v') {
//$if !linux {
// run pg example only on linux
if f.contains('/pg/') {
continue
}
//}
if f.contains('life_gg') || f.contains('/graph.v') || f.contains('rune.v') {
continue
}

View File

@ -1,4 +1,4 @@
//import pg
import pg
struct Modules {
id int
@ -9,8 +9,11 @@ struct Modules {
}
fn test_orm() {
db := pg.connect(
dbname:'vpm'
user:'alex'
)
/*
db := pg.connect('vpm', 'alex')
//nr_modules := db.select count from modules
//nr_modules := db.select count from Modules where id == 1
nr_modules := db.select count from Modules where

View File

@ -87,8 +87,19 @@ fn (mut p Parser) vweb() ast.ComptimeCall {
// Compile vweb html template to V code, parse that V code and embed the resulting V function
// that returns an html string.
mut path := p.cur_fn_name + '.html'
// if p.pref.is_debug {
// if p.pref.is_verbose {
println('>>> compiling vweb HTML template "$path"')
// }
if !os.exists(path) {
// Can't find the template file in current directory,
// try looking next to the vweb program, in case it's run with
// v path/to/vweb_app.v
path = os.dir(p.scanner.file_path) + '/' + path
if !os.exists(path) {
p.error('vweb HTML template "$path" not found')
}
// println('path is now "$path"')
}
v_code := tmpl.compile_file(path)
mut scope := &ast.Scope{
start_pos: 0
@ -102,17 +113,6 @@ fn (mut p Parser) vweb() ast.ComptimeCall {
println('>>> end of vweb template END')
println('\n\n')
}
/*
if !os.exists(path) {
// Can't find the template file in current directory,
// try looking next to the vweb program, in case it's run with
// v path/to/vweb_app.v
path = os.dir(p.scanner.file_path) + '/' + path
if !os.exists(path) {
p.error('vweb HTML template "$path" not found')
}
}
*/
// copy vars from current fn scope into vweb_tmpl scope
for stmt in file.stmts {
if stmt is ast.FnDecl {