From 8c8d21d1306461d4c262f75fd68d6025ff24605e Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 17 Jul 2023 15:51:50 +0300 Subject: [PATCH] checker: add -skip-unused support for vweb.run_at too (#18884) --- vlib/v/checker/fn.v | 2 +- vlib/v/tests/skip_unused/vweb_run_at.run.out | 3 +++ .../vweb_run_at.skip_unused.run.out | 3 +++ vlib/v/tests/skip_unused/vweb_run_at.vv | 21 +++++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 vlib/v/tests/skip_unused/vweb_run_at.run.out create mode 100644 vlib/v/tests/skip_unused/vweb_run_at.skip_unused.run.out create mode 100644 vlib/v/tests/skip_unused/vweb_run_at.vv diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index 37ce829ea1e4ae..f8a76b9e815f13 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -2261,7 +2261,7 @@ fn (mut c Checker) post_process_generic_fns() ! { for concrete_types in gtypes { c.table.cur_concrete_types = concrete_types c.fn_decl(mut node) - if node.name == 'vweb.run' { + if node.name in ['vweb.run', 'vweb.run_at'] { for ct in concrete_types { if ct !in c.vweb_gen_types { c.vweb_gen_types << ct diff --git a/vlib/v/tests/skip_unused/vweb_run_at.run.out b/vlib/v/tests/skip_unused/vweb_run_at.run.out new file mode 100644 index 00000000000000..fe110d23148964 --- /dev/null +++ b/vlib/v/tests/skip_unused/vweb_run_at.run.out @@ -0,0 +1,3 @@ +[Vweb] Running app on http://localhost:38090/ +[Vweb] We have 1 workers +done diff --git a/vlib/v/tests/skip_unused/vweb_run_at.skip_unused.run.out b/vlib/v/tests/skip_unused/vweb_run_at.skip_unused.run.out new file mode 100644 index 00000000000000..fe110d23148964 --- /dev/null +++ b/vlib/v/tests/skip_unused/vweb_run_at.skip_unused.run.out @@ -0,0 +1,3 @@ +[Vweb] Running app on http://localhost:38090/ +[Vweb] We have 1 workers +done diff --git a/vlib/v/tests/skip_unused/vweb_run_at.vv b/vlib/v/tests/skip_unused/vweb_run_at.vv new file mode 100644 index 00000000000000..576402790d3284 --- /dev/null +++ b/vlib/v/tests/skip_unused/vweb_run_at.vv @@ -0,0 +1,21 @@ +import vweb +import time + +struct App { + vweb.Context +} + +fn main() { + spawn fn () { + time.sleep(100 * time.millisecond) + println('done') + exit(0) + }() + vweb.run_at(&App{}, port: 38090, nr_workers: 1)! + // vweb.run(&App{}, 38091) +} + +['/'] +pub fn (mut app App) app_main() vweb.Result { + return app.text('Hello World') +}