V: naming of v source files impacts the compiler behaviour

Created on 12 Sep 2019  路  6Comments  路  Source: vlang/v

V version: V 0.1.19 a555b1f
OS: Linux Mint 19.1

What did you do?
test.v with content:

import net.urllib
import http

pub fn main() {
urls := [
'http://bugurl'
]
for url in urls {
println('Getting Bugs: $url ')
}
}

then:

./v compile test.v

and run
./test
with output:
Getting Bugs: http://bugurl

Then renamed the source file test.v into test_test.v
and then a compiler run
./v compile test_test.v

and a execute
./test_test

and no println output nothing at all.

Is there a special meaning with test in the source file name ?

What did you expect to see?
The same output

What did you see instead?

Bug

All 6 comments

Yes, @schoko123, file names ending in _test.v are ment for testing and are treated differently. Please see here: https://vlang.io/docs#testing
For the files ending in _test.v, the compiler compiles and runs every function with the test_ in the begining of the function name.

Ok it seems to be a feature... Close this now..

I'd keep it open until V handles this case.

It should show an error message if there's fn main in a test file.

It should also then show an error message if there are no test_* functions in a file.

@schoko123 btw, there is no need to specify v compile file.v . v file.v is enough.

Fixed.

It should also then show an error message if there are no test_* functions in a file.

@avitkauskas This has been implemented as well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ArcDrake picture ArcDrake  路  3Comments

arg2das picture arg2das  路  3Comments

choleraehyq picture choleraehyq  路  3Comments

radare picture radare  路  3Comments

oleg-kachan picture oleg-kachan  路  3Comments