mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: change optional to result of io (#16075)
This commit is contained in:
@ -2,10 +2,10 @@ import os
|
||||
|
||||
const test_path = os.join_path(os.temp_dir(), 'v', 'vcreate_test')
|
||||
|
||||
fn init_and_check() ? {
|
||||
fn init_and_check() ! {
|
||||
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
|
||||
|
||||
assert os.read_file('vcreate_test.v')? == [
|
||||
assert os.read_file('vcreate_test.v')! == [
|
||||
'module main\n',
|
||||
'fn main() {',
|
||||
" println('Hello World!')",
|
||||
@ -13,7 +13,7 @@ fn init_and_check() ? {
|
||||
'',
|
||||
].join_lines()
|
||||
|
||||
assert os.read_file('v.mod')? == [
|
||||
assert os.read_file('v.mod')! == [
|
||||
'Module {',
|
||||
" name: 'vcreate_test'",
|
||||
" description: ''",
|
||||
@ -24,7 +24,7 @@ fn init_and_check() ? {
|
||||
'',
|
||||
].join_lines()
|
||||
|
||||
assert os.read_file('.gitignore')? == [
|
||||
assert os.read_file('.gitignore')! == [
|
||||
'# Binaries for programs and plugins',
|
||||
'main',
|
||||
'vcreate_test',
|
||||
@ -37,7 +37,7 @@ fn init_and_check() ? {
|
||||
'',
|
||||
].join_lines()
|
||||
|
||||
assert os.read_file('.gitattributes')? == [
|
||||
assert os.read_file('.gitattributes')! == [
|
||||
'*.v linguist-language=V text=auto eol=lf',
|
||||
'*.vv linguist-language=V text=auto eol=lf',
|
||||
'*.vsh linguist-language=V text=auto eol=lf',
|
||||
@ -45,7 +45,7 @@ fn init_and_check() ? {
|
||||
'',
|
||||
].join_lines()
|
||||
|
||||
assert os.read_file('.editorconfig')? == [
|
||||
assert os.read_file('.editorconfig')! == [
|
||||
'[*]',
|
||||
'charset = utf-8',
|
||||
'end_of_line = lf',
|
||||
@ -59,28 +59,28 @@ fn init_and_check() ? {
|
||||
].join_lines()
|
||||
}
|
||||
|
||||
fn prepare_test_path() ? {
|
||||
fn prepare_test_path() ! {
|
||||
os.rmdir_all(test_path) or {}
|
||||
os.mkdir_all(test_path) or {}
|
||||
os.chdir(test_path)?
|
||||
os.chdir(test_path)!
|
||||
}
|
||||
|
||||
fn test_v_init() {
|
||||
prepare_test_path()?
|
||||
init_and_check()?
|
||||
prepare_test_path()!
|
||||
init_and_check()!
|
||||
}
|
||||
|
||||
fn test_v_init_in_git_dir() {
|
||||
prepare_test_path()?
|
||||
prepare_test_path()!
|
||||
os.execute_or_exit('git init .')
|
||||
init_and_check()?
|
||||
init_and_check()!
|
||||
}
|
||||
|
||||
fn test_v_init_no_overwrite_gitignore() {
|
||||
prepare_test_path()?
|
||||
os.write_file('.gitignore', 'blah')?
|
||||
prepare_test_path()!
|
||||
os.write_file('.gitignore', 'blah')!
|
||||
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
|
||||
assert os.read_file('.gitignore')? == 'blah'
|
||||
assert os.read_file('.gitignore')! == 'blah'
|
||||
}
|
||||
|
||||
fn test_v_init_no_overwrite_gitattributes_and_editorconfig() {
|
||||
@ -95,13 +95,13 @@ trim_trailing_whitespace = true
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
'
|
||||
prepare_test_path()?
|
||||
os.write_file('.gitattributes', git_attributes_content)?
|
||||
os.write_file('.editorconfig', editor_config_content)?
|
||||
prepare_test_path()!
|
||||
os.write_file('.gitattributes', git_attributes_content)!
|
||||
os.write_file('.editorconfig', editor_config_content)!
|
||||
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
|
||||
|
||||
assert os.read_file('.gitattributes')? == git_attributes_content
|
||||
assert os.read_file('.editorconfig')? == editor_config_content
|
||||
assert os.read_file('.gitattributes')! == git_attributes_content
|
||||
assert os.read_file('.editorconfig')! == editor_config_content
|
||||
}
|
||||
|
||||
fn testsuite_end() {
|
||||
|
Reference in New Issue
Block a user