mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
ci: fix v test-self
failures related to cmd/tools/vcreate_test.v
This commit is contained in:
parent
68501677e3
commit
46ced75184
@ -2,11 +2,20 @@
|
||||
// Use of this source code is governed by an MIT license that can be found in the LICENSE file.
|
||||
module main
|
||||
|
||||
// This module follows a similar convention to Rust: `init` makes the
|
||||
import os
|
||||
|
||||
// Note: this program follows a similar convention to Rust: `init` makes the
|
||||
// structure of the program in the _current_ directory, while `new`
|
||||
// makes the program structure in a _sub_ directory. Besides that, the
|
||||
// functionality is essentially the same.
|
||||
import os
|
||||
|
||||
// Note: here are the currently supported invokations so far:
|
||||
// 1) `v init` -> create a new project in the current folder
|
||||
// 2) `v new abc` -> create a new project in the new folder `abc`, by default a "hello world" project.
|
||||
// 3) `v new abcd web` -> create a new project in the new folder `abcd`, using the vweb template.
|
||||
// 4) `v new abcde gg` -> create a new project in the new folder `abcde`, using the gg template.
|
||||
|
||||
// Note: run `v cmd/tools/vcreate_test.v` after changes to this program, to avoid regressions.
|
||||
|
||||
struct Create {
|
||||
mut:
|
||||
@ -53,9 +62,13 @@ fn vmod_content(c Create) string {
|
||||
}
|
||||
|
||||
fn new_project_content() string {
|
||||
if os.args.len == 2 && os.args[1] == 'init' {
|
||||
return main_content()
|
||||
}
|
||||
if os.args.len == 3 {
|
||||
return main_content()
|
||||
} else if os.args.len == 4 {
|
||||
}
|
||||
if os.args.len == 4 {
|
||||
kind := os.args.last()
|
||||
return match kind {
|
||||
'web' {
|
||||
|
@ -1,11 +1,19 @@
|
||||
import os
|
||||
|
||||
const test_path = os.join_path(os.vtmp_dir(), 'v', 'vcreate_test')
|
||||
// Note: the following uses `test_vcreate` and NOT `vcreate_test` deliberately,
|
||||
// to both avoid confusions with the name of the current test itself, and to
|
||||
// avoid clashes with the postfix `_test.v`, that V uses for its own test files.
|
||||
const test_path = os.join_path(os.vtmp_dir(), 'v', 'test_vcreate')
|
||||
|
||||
fn init_and_check() ! {
|
||||
os.chdir(test_path)!
|
||||
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
|
||||
|
||||
assert os.read_file('vcreate_test.v')! == [
|
||||
x := os.execute_or_exit('${os.quoted_path(@VEXE)} run .')
|
||||
assert x.exit_code == 0
|
||||
assert x.output.trim_space() == 'Hello World!'
|
||||
|
||||
assert os.read_file('test_vcreate.v')! == [
|
||||
'module main\n',
|
||||
'fn main() {',
|
||||
" println('Hello World!')",
|
||||
@ -15,7 +23,7 @@ fn init_and_check() ! {
|
||||
|
||||
assert os.read_file('v.mod')! == [
|
||||
'Module {',
|
||||
" name: 'vcreate_test'",
|
||||
" name: 'test_vcreate'",
|
||||
" description: ''",
|
||||
" version: ''",
|
||||
" license: ''",
|
||||
@ -27,7 +35,7 @@ fn init_and_check() ! {
|
||||
assert os.read_file('.gitignore')! == [
|
||||
'# Binaries for programs and plugins',
|
||||
'main',
|
||||
'vcreate_test',
|
||||
'test_vcreate',
|
||||
'*.exe',
|
||||
'*.exe~',
|
||||
'*.so',
|
||||
|
Loading…
Reference in New Issue
Block a user