mirror of
https://github.com/vlang/v.git
synced 2025-09-15 15:32:27 +03:00
This commit is contained in:
parent
cb976c7e17
commit
269462425a
2 changed files with 23 additions and 11 deletions
|
@ -133,10 +133,11 @@ fn init_project() {
|
||||||
c.write_vmod(false)
|
c.write_vmod(false)
|
||||||
println('Change the description of your project in `v.mod`')
|
println('Change the description of your project in `v.mod`')
|
||||||
}
|
}
|
||||||
|
if !os.exists('src/main.v') {
|
||||||
c.files << ProjectFiles{
|
c.files << ProjectFiles{
|
||||||
path: 'src/main.v'
|
path: 'src/main.v'
|
||||||
content: hello_world_content()
|
content: hello_world_content()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c.create_files_and_directories()
|
c.create_files_and_directories()
|
||||||
c.write_gitattributes(false)
|
c.write_gitattributes(false)
|
||||||
|
|
|
@ -7,19 +7,30 @@ const test_path = os.join_path(os.vtmp_dir(), 'v', 'test_vcreate')
|
||||||
|
|
||||||
fn init_and_check() ! {
|
fn init_and_check() ! {
|
||||||
os.chdir(test_path)!
|
os.chdir(test_path)!
|
||||||
|
|
||||||
|
// if main file already exist we should not tamper it
|
||||||
|
mut main_last_modified_time := i64(0)
|
||||||
|
is_main_file_preexisting := os.exists('src/main.v')
|
||||||
|
if is_main_file_preexisting == true {
|
||||||
|
main_last_modified_time = os.file_last_mod_unix('src/main.v')
|
||||||
|
}
|
||||||
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
|
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
|
||||||
|
|
||||||
x := os.execute_or_exit('${os.quoted_path(@VEXE)} run .')
|
x := os.execute_or_exit('${os.quoted_path(@VEXE)} run .')
|
||||||
assert x.exit_code == 0
|
assert x.exit_code == 0
|
||||||
assert x.output.trim_space() == 'Hello World!'
|
assert x.output.trim_space() == 'Hello World!'
|
||||||
|
|
||||||
assert os.read_file('src/main.v')! == [
|
if is_main_file_preexisting == true {
|
||||||
'module main\n',
|
assert main_last_modified_time == os.file_last_mod_unix('src/main.v')
|
||||||
'fn main() {',
|
} else {
|
||||||
" println('Hello World!')",
|
assert os.read_file('src/main.v')! == [
|
||||||
'}',
|
'module main\n',
|
||||||
'',
|
'fn main() {',
|
||||||
].join_lines()
|
" println('Hello World!')",
|
||||||
|
'}',
|
||||||
|
'',
|
||||||
|
].join_lines()
|
||||||
|
}
|
||||||
|
|
||||||
assert os.read_file('v.mod')! == [
|
assert os.read_file('v.mod')! == [
|
||||||
'Module {',
|
'Module {',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue