net.ftp: make ftp's tests just compile (not run) on CI
parent
48585e54df
commit
68e1d8e8eb
|
@ -59,6 +59,9 @@ fn v_files() []string {
|
||||||
if tfile in known_failing_exceptions {
|
if tfile in known_failing_exceptions {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if tfile.starts_with('./vlib/v/cgen/tests') {
|
||||||
|
continue
|
||||||
|
}
|
||||||
files_that_can_be_formatted << tfile
|
files_that_can_be_formatted << tfile
|
||||||
}
|
}
|
||||||
return files_that_can_be_formatted
|
return files_that_can_be_formatted
|
||||||
|
|
|
@ -3019,6 +3019,7 @@ fn (p mut Parser) attribute() {
|
||||||
if p.tok == .key_if {
|
if p.tok == .key_if {
|
||||||
// [if vfmt]
|
// [if vfmt]
|
||||||
p.next()
|
p.next()
|
||||||
|
p.fspace()
|
||||||
p.attr = 'if ' + p.check_name()
|
p.attr = 'if ' + p.check_name()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -259,7 +259,7 @@ fn (p &Parser) gen_fmt() {
|
||||||
//s := p.scanner.fmt_out.str().replace('\n\n\n', '\n').trim_space()
|
//s := p.scanner.fmt_out.str().replace('\n\n\n', '\n').trim_space()
|
||||||
//s := p.scanner.fmt_out.str().trim_space()
|
//s := p.scanner.fmt_out.str().trim_space()
|
||||||
//p.scanner.fgenln('// nice')
|
//p.scanner.fgenln('// nice')
|
||||||
s1 := p.scanner.fmt_lines.join('')
|
mut s := p.scanner.fmt_lines.join('')
|
||||||
/*.replace_each([
|
/*.replace_each([
|
||||||
'\n\n\n\n', '\n\n',
|
'\n\n\n\n', '\n\n',
|
||||||
' \n', '\n',
|
' \n', '\n',
|
||||||
|
@ -268,13 +268,12 @@ fn (p &Parser) gen_fmt() {
|
||||||
*/
|
*/
|
||||||
//.replace('\n\n\n\n', '\n\n')
|
//.replace('\n\n\n\n', '\n\n')
|
||||||
|
|
||||||
s2 := s1.replace(' \n', '\n')
|
s = s.replace(' \n', '\n')
|
||||||
s3 := s2.replace(') or{', ') or {')
|
s = s.replace(') or {', ') or {')
|
||||||
s4 := s3.replace(')or{', ') or {')
|
s = s.replace(') or{', ') or {')
|
||||||
s5 := s4.replace('or{', 'or {')
|
s = s.replace(')or{', ') or {')
|
||||||
s6 := s5.replace('}}\n', '}\n\t}\n')
|
s = s.replace('or{', 'or {')
|
||||||
|
s = s.replace('}}\n', '}\n\t}\n')
|
||||||
s := s6
|
|
||||||
|
|
||||||
if s == '' {
|
if s == '' {
|
||||||
return
|
return
|
||||||
|
|
|
@ -2,31 +2,36 @@ module main
|
||||||
|
|
||||||
import net.ftp
|
import net.ftp
|
||||||
|
|
||||||
fn test_all() {
|
fn test_ftp_client() {
|
||||||
|
make_client_connection()
|
||||||
|
assert true
|
||||||
|
}
|
||||||
|
|
||||||
|
// NB: this function makes network calls to external servers,
|
||||||
|
// that is why it is not a very good idea to run it in CI.
|
||||||
|
// If you want to run it manually, use `v -d network vlib/net/ftp/ftp_test.v`
|
||||||
|
[if network]
|
||||||
|
fn make_client_connection() {
|
||||||
mut ftp := ftp.new()
|
mut ftp := ftp.new()
|
||||||
defer {
|
defer {
|
||||||
ftp.close()
|
ftp.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
assert ftp.connect('ftp.redhat.com')
|
assert ftp.connect('ftp.redhat.com')
|
||||||
assert ftp.login('ftp','ftp')
|
assert ftp.login('ftp', 'ftp')
|
||||||
|
|
||||||
pwd := ftp.pwd()
|
pwd := ftp.pwd()
|
||||||
|
assert pwd.len > 0
|
||||||
ftp.cd('/')
|
ftp.cd('/')
|
||||||
dir_list1 := ftp.dir() or {
|
dir_list1 := ftp.dir() or {
|
||||||
assert false
|
assert false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
assert dir_list1.len > 0
|
assert dir_list1.len > 0
|
||||||
|
|
||||||
ftp.cd('/suse/linux/enterprise/11Server/en/SAT-TOOLS/SRPMS/')
|
ftp.cd('/suse/linux/enterprise/11Server/en/SAT-TOOLS/SRPMS/')
|
||||||
dir_list2 := ftp.dir() or {
|
dir_list2 := ftp.dir() or {
|
||||||
assert false
|
assert false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
assert dir_list2.len > 0
|
assert dir_list2.len > 0
|
||||||
|
|
||||||
blob := ftp.get('katello-host-tools-3.3.5-8.sles11_4sat.src.rpm') or {
|
blob := ftp.get('katello-host-tools-3.3.5-8.sles11_4sat.src.rpm') or {
|
||||||
assert false
|
assert false
|
||||||
return
|
return
|
||||||
|
|
|
@ -13,17 +13,14 @@ const (
|
||||||
|
|
||||||
fn test_c_files() {
|
fn test_c_files() {
|
||||||
println('Running V => C tests')
|
println('Running V => C tests')
|
||||||
dir := filepath.dir(os.executable())
|
vexe := os.getenv('VEXE')
|
||||||
|
vroot := filepath.dir(vexe)
|
||||||
for i in 1 .. nr_tests + 1 {
|
for i in 1 .. nr_tests + 1 {
|
||||||
text := os.read_file('$dir/tests/${i}.v') or {
|
text := os.read_file('$vroot/vlib/v/cgen/tests/${i}.v') or {
|
||||||
exit(0)
|
panic(err)
|
||||||
// panic(err)
|
|
||||||
// exit(1)
|
|
||||||
}
|
}
|
||||||
ctext := os.read_file('$dir/tests/${i}.c') or {
|
ctext := os.read_file('$vroot/vlib/v/cgen/tests/${i}.c') or {
|
||||||
exit(0)
|
panic(err)
|
||||||
// exit(1)
|
|
||||||
// panic(err)
|
|
||||||
}
|
}
|
||||||
table := &table.Table{}
|
table := &table.Table{}
|
||||||
program := parser.parse_file(text, table)
|
program := parser.parse_file(text, table)
|
||||||
|
|
Loading…
Reference in New Issue