net.ftp: make ftp's tests just compile (not run) on CI

pull/3253/head
Delyan Angelov 2019-12-28 14:55:53 +02:00 committed by Alexander Medvednikov
parent 48585e54df
commit 68e1d8e8eb
5 changed files with 29 additions and 24 deletions

View File

@ -59,6 +59,9 @@ fn v_files() []string {
if tfile in known_failing_exceptions {
continue
}
if tfile.starts_with('./vlib/v/cgen/tests') {
continue
}
files_that_can_be_formatted << tfile
}
return files_that_can_be_formatted

View File

@ -3019,6 +3019,7 @@ fn (p mut Parser) attribute() {
if p.tok == .key_if {
// [if vfmt]
p.next()
p.fspace()
p.attr = 'if ' + p.check_name()
}
else {

View File

@ -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().trim_space()
//p.scanner.fgenln('// nice')
s1 := p.scanner.fmt_lines.join('')
mut s := p.scanner.fmt_lines.join('')
/*.replace_each([
'\n\n\n\n', '\n\n',
' \n', '\n',
@ -268,13 +268,12 @@ fn (p &Parser) gen_fmt() {
*/
//.replace('\n\n\n\n', '\n\n')
s2 := s1.replace(' \n', '\n')
s3 := s2.replace(') or{', ') or {')
s4 := s3.replace(')or{', ') or {')
s5 := s4.replace('or{', 'or {')
s6 := s5.replace('}}\n', '}\n\t}\n')
s := s6
s = s.replace(' \n', '\n')
s = s.replace(') or {', ') or {')
s = s.replace(') or{', ') or {')
s = s.replace(')or{', ') or {')
s = s.replace('or{', 'or {')
s = s.replace('}}\n', '}\n\t}\n')
if s == '' {
return

View File

@ -2,31 +2,36 @@ module main
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()
defer {
ftp.close()
}
assert ftp.connect('ftp.redhat.com')
assert ftp.login('ftp','ftp')
assert ftp.login('ftp', 'ftp')
pwd := ftp.pwd()
assert pwd.len > 0
ftp.cd('/')
dir_list1 := ftp.dir() or {
assert false
return
}
assert dir_list1.len > 0
ftp.cd('/suse/linux/enterprise/11Server/en/SAT-TOOLS/SRPMS/')
dir_list2 := ftp.dir() or {
assert false
return
}
assert dir_list2.len > 0
blob := ftp.get('katello-host-tools-3.3.5-8.sles11_4sat.src.rpm') or {
assert false
return

View File

@ -13,17 +13,14 @@ const (
fn test_c_files() {
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 {
text := os.read_file('$dir/tests/${i}.v') or {
exit(0)
// panic(err)
// exit(1)
text := os.read_file('$vroot/vlib/v/cgen/tests/${i}.v') or {
panic(err)
}
ctext := os.read_file('$dir/tests/${i}.c') or {
exit(0)
// exit(1)
// panic(err)
ctext := os.read_file('$vroot/vlib/v/cgen/tests/${i}.c') or {
panic(err)
}
table := &table.Table{}
program := parser.parse_file(text, table)