@@ -45,6 +45,14 @@ pub const is_node_present = os.execute('node --version').exit_code == 0
45
45
46
46
pub const is_go_present = os.execute ('go version' ).exit_code == 0
47
47
48
+ pub const is_ruby_present = os.execute ('ruby --version' ).exit_code == 0
49
+
50
+ pub const is_python_present = os.execute ('python --version' ).exit_code == 0
51
+
52
+ pub const is_sqlite3_present = os.execute ('sqlite3 --version' ).exit_code == 0
53
+
54
+ pub const is_openssl_present = os.execute ('openssl --version' ).exit_code == 0
55
+
48
56
pub const all_processes = get_all_processes ()
49
57
50
58
pub const header_bytes_to_search_for_module_main = 500
@@ -101,6 +109,7 @@ pub mut:
101
109
exec_mode ActionMode = .compile // .compile_and_run only for `v test`
102
110
103
111
build_environment build_constraint.Environment // see the documentation in v.build_constraint
112
+ custom_defines []string // for adding custom defines, known only to the individual runners
104
113
}
105
114
106
115
pub fn (mut ts TestSession) add_failed_cmd (cmd string ) {
@@ -219,107 +228,14 @@ pub fn (mut ts TestSession) print_messages() {
219
228
pub fn new_test_session (_vargs string , will_compile bool ) TestSession {
220
229
mut skip_files := []string {}
221
230
if will_compile {
222
- // Skip the call_v_from_* files. They need special instructions for compilation.
223
- // Check the README.md for detailed information.
224
- skip_files << 'examples/call_v_from_c/v_test_print.v'
225
- skip_files << 'examples/call_v_from_c/v_test_math.v'
226
- skip_files << 'examples/call_v_from_python/test.v' // the example only makes sense to be compiled, when python is installed
227
- skip_files << 'examples/call_v_from_ruby/test.v' // the example only makes sense to be compiled, when ruby is installed
228
- // Skip the compilation of the coroutines example for now, since the Photon wrapper
229
- // is only available on macos for now, and it is not yet trivial enough to
230
- // build/install on the CI:
231
- skip_files << 'examples/coroutines/simple_coroutines.v'
232
- skip_files << 'examples/coroutines/coroutines_bench.v'
233
- $if msvc {
234
- skip_files << 'vlib/v/tests/consts/const_comptime_eval_before_vinit_test.v' // _constructor used
235
- }
236
- $if solaris {
237
- skip_files << 'examples/pico/pico.v'
238
- skip_files << 'examples/pico/raw_callback.v'
239
- skip_files << 'examples/sokol/fonts.v'
240
- skip_files << 'examples/sokol/drawing.v'
241
- }
242
- $if macos {
243
- skip_files << 'examples/database/mysql.v'
244
- skip_files << 'examples/database/orm.v'
245
- skip_files << 'examples/database/psql/customer.v'
246
- }
247
- $if windows {
248
- skip_files << 'examples/vanilla_http_server' // requires epoll
249
- skip_files << 'examples/1brc/solution/main.v' // requires mmap
250
- skip_files << 'examples/database/mysql.v'
251
- skip_files << 'examples/database/orm.v'
252
- skip_files << 'examples/smtp/mail.v' // requires OpenSSL
253
- skip_files << 'examples/websocket/ping.v' // requires OpenSSL
254
- skip_files << 'examples/websocket/client-server/client.v' // requires OpenSSL
255
- skip_files << 'examples/websocket/client-server/server.v' // requires OpenSSL
256
- skip_files << 'examples/minimal_c_like_program_using_puts.v' // declares its own `main` function, while on windows it needs to be `wWinMain` ... although only for gcc for some reason ¯\_(ツ)_/¯
257
- skip_files << 'vlib/v/tests/websocket_logger_interface_should_compile_test.v' // requires OpenSSL
258
- skip_files << 'vlib/crypto/ecdsa/ecdsa_test.v' // requires OpenSSL
259
- skip_files << 'vlib/crypto/ecdsa/util_test.v' // requires OpenSSL
260
- skip_files << 'vlib/crypto/ecdsa/example/ecdsa_seed_test.v' // requires OpenSSL
261
- skip_files << 'vlib/crypto/ecdsa/example/ensure_compatibility_with_net_openssl_test.v' // requires OpenSSL
262
- $if tinyc {
263
- skip_files << 'examples/database/orm.v' // try fix it
264
- }
265
- }
266
231
$if windows {
267
- // TODO: remove when closures on windows are supported...
268
- skip_files << 'examples/pendulum-simulation/animation.v'
269
- skip_files << 'examples/pendulum-simulation/full.v'
270
- skip_files << 'examples/pendulum-simulation/parallel.v'
271
- skip_files << 'examples/pendulum-simulation/parallel_with_iw.v'
272
- skip_files << 'examples/pendulum-simulation/sequential.v'
273
- if github_job == 'tcc-windows' {
274
- // TODO: fix these by adding declarations for the missing functions in the prebuilt tcc
275
- skip_files << 'vlib/net/mbedtls/mbedtls_compiles_test.v'
276
- skip_files << 'vlib/net/ssl/ssl_compiles_test.v'
277
- }
232
+ skip_files << 'examples/vanilla_http_server' // requires epoll // TODO: find a way to support `// vtest build:` for project folders too...
278
233
}
279
234
if runner_os != 'Linux' || ! github_job.starts_with ('tcc-' ) {
280
235
if ! os.exists ('/usr/local/include/wkhtmltox/pdf.h' ) {
281
236
skip_files << 'examples/c_interop_wkhtmltopdf.v' // needs installation of wkhtmltopdf from https://github.com/wkhtmltopdf/packaging/releases
282
237
}
283
- skip_files << 'vlib/vweb/vweb_app_test.v' // imports the `sqlite` module, which in turn includes `sqlite3.h`
284
- skip_files << 'vlib/veb/tests/veb_app_test.v' // imports the `sqlite` module, which in turn includes `sqlite3.h`
285
- }
286
- $if ! macos {
287
- skip_files << 'examples/macos_tray/tray.v'
288
- }
289
- if github_job == 'docker-ubuntu-musl' {
290
- skip_files << 'vlib/net/openssl/openssl_compiles_test.c.v'
291
- skip_files << 'vlib/crypto/ecdsa/ecdsa_test.v' // requires OpenSSL
292
- skip_files << 'vlib/crypto/ecdsa/util_test.v' // requires OpenSSL
293
- skip_files << 'vlib/crypto/ecdsa/example/ecdsa_seed_test.v' // requires OpenSSL
294
- skip_files << 'vlib/crypto/ecdsa/example/ensure_compatibility_with_net_openssl_test.v' // requires OpenSSL
295
- skip_files << 'vlib/x/ttf/ttf_test.v'
296
- skip_files << 'vlib/encoding/iconv/iconv_test.v' // needs libiconv to be installed
297
- }
298
- if github_job == 'sanitize-memory-clang' {
299
- skip_files << 'vlib/net/openssl/openssl_compiles_test.c.v'
300
- skip_files << 'vlib/crypto/ecdsa/ecdsa_test.v' // requires OpenSSL
301
- skip_files << 'vlib/crypto/ecdsa/util_test.v' // requires OpenSSL
302
- skip_files << 'vlib/crypto/ecdsa/example/ecdsa_seed_test.v' // requires OpenSSL
303
- skip_files << 'vlib/crypto/ecdsa/example/ensure_compatibility_with_net_openssl_test.v' // requires OpenSSL
304
- // Fails compilation with: `/usr/bin/ld: /lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line`
305
- skip_files << 'examples/sokol/sounds/simple_sin_tones.v'
306
- skip_files << 'examples/sokol/sounds/simple_sin_tone_using_audio_push.v'
307
- }
308
- if github_job != 'misc-tooling' {
309
- // These examples need .h files that are produced from the supplied .glsl files,
310
- // using by the shader compiler tools in https://github.com/floooh/sokol-tools-bin/archive/pre-feb2021-api-changes.tar.gz
311
- skip_files << 'examples/sokol/02_cubes_glsl/cube_glsl.v'
312
- skip_files << 'examples/sokol/03_march_tracing_glsl/rt_glsl.v'
313
- skip_files << 'examples/sokol/04_multi_shader_glsl/rt_glsl.v'
314
- skip_files << 'examples/sokol/05_instancing_glsl/rt_glsl.v'
315
- skip_files << 'examples/sokol/07_simple_shader_glsl/simple_shader.v'
316
- skip_files << 'examples/sokol/08_sdf/sdf.v'
317
- // Skip obj_viewer code in the CI
318
- skip_files << 'examples/sokol/06_obj_viewer/show_obj.v'
319
- }
320
- // requires special compilation flags: `-b wasm -os browser`, skip it for now:
321
- skip_files << 'examples/wasm/mandelbrot/mandelbrot.wasm.v'
322
- skip_files << 'examples/wasm/change_color_by_id/change_color_by_id.wasm.v'
238
+ }
323
239
}
324
240
skip_files = skip_files.map (os.abs_path)
325
241
vargs := _vargs.replace ('-progress' , '' )
@@ -394,25 +310,9 @@ pub fn (mut ts TestSession) test() {
394
310
mut remaining_files := []string {}
395
311
for dot_relative_file in ts.files {
396
312
file := os.real_path (dot_relative_file)
397
- $if windows {
398
- if file.contains ('sqlite' ) || file.contains ('httpbin' ) {
399
- continue
400
- }
401
- }
402
- $if ! macos {
403
- if file.contains ('customer' ) {
404
- continue
405
- }
406
- }
407
- $if msvc {
408
- if file.contains ('asm' ) {
409
- continue
410
- }
411
- }
412
313
if ts.build_tools && dot_relative_file.ends_with ('_test.v' ) {
413
314
continue
414
315
}
415
-
416
316
// Skip OS-specific tests if we are not running that OS
417
317
// Special case for android_outside_termux because of its
418
318
// underscores
@@ -447,7 +347,7 @@ pub fn (mut ts TestSession) test() {
447
347
pool_of_test_runners.set_shared_context (ts)
448
348
ts.reporter.worker_threads_start (remaining_files, mut ts)
449
349
450
- ts.build_environment = get_build_environment ()
350
+ ts.setup_build_environment ()
451
351
452
352
// all the testing happens here:
453
353
pool_of_test_runners.work_on_pointers (unsafe { remaining_files.pointers () })
@@ -974,8 +874,44 @@ fn get_max_header_len() int {
974
874
return cols
975
875
}
976
876
977
- fn get_build_environment () & build_constraint.Environment {
877
+ // is_started_mysqld is true, when the test runner determines that there is a running mysql server
878
+ pub const is_started_mysqld = find_started_process ('mysqld' ) or { '' }
879
+
880
+ // is_started_postgres is true, when the test runner determines that there is a running postgres server
881
+ pub const is_started_postgres = find_started_process ('postgres' ) or { '' }
882
+
883
+ pub fn (mut ts TestSession) setup_build_environment () {
978
884
facts := os.getenv ('VBUILD_FACTS' ).split_any (',' )
979
- defines := os.getenv ('VBUILD_DEFINES' ).split_any (',' )
980
- return build_constraint.new_environment (facts, defines)
885
+ mut defines := os.getenv ('VBUILD_DEFINES' ).split_any (',' )
886
+ // add the runtime information, that the test runner has already determined by checking once:
887
+ if is_started_mysqld != '' {
888
+ defines << 'started_mysqld'
889
+ }
890
+ if is_started_postgres != '' {
891
+ defines << 'started_postgres'
892
+ }
893
+ if is_node_present {
894
+ defines << 'present_node'
895
+ }
896
+ if is_python_present {
897
+ defines << 'present_python'
898
+ }
899
+ if is_ruby_present {
900
+ defines << 'present_ruby'
901
+ }
902
+ if is_go_present {
903
+ defines << 'present_go'
904
+ }
905
+ if is_sqlite3_ present {
906
+ defines << 'present_sqlite3'
907
+ }
908
+ if is_openssl_present {
909
+ defines << 'present_openssl'
910
+ }
911
+ defines << ts.custom_defines
912
+ $if trace_vbuild ? {
913
+ eprintln ('>>> testing.get_build_environment facts: ${facts} ' )
914
+ eprintln ('>>> testing.get_build_environment defines: ${defines} ' )
915
+ }
916
+ ts.build_environment = build_constraint.new_environment (facts, defines)
981
917
}
0 commit comments