From f2c281eadf2c5f9b69e31c5cf809d6fbdbe6ea28 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Fri, 29 Nov 2024 02:46:09 +0200 Subject: [PATCH] markused: only add .vtest_ functions, *when* compiling _test.v files (#23003) --- .github/workflows/c2v_ci.yml | 18 ++++++++++++++++++ vlib/v/markused/markused.v | 8 +++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/c2v_ci.yml b/.github/workflows/c2v_ci.yml index 0ed2b4a8ae050b..4cac63e62c3e76 100644 --- a/.github/workflows/c2v_ci.yml +++ b/.github/workflows/c2v_ci.yml @@ -38,6 +38,15 @@ jobs: - uses: actions/checkout@v4 - name: Build V run: make -j4 && ./v symlink + + - name: Set 8.8.8.8 as dns server + run: | + sudo sed -i 's/#DNS=/DNS=8.8.8.8 8.8.4.4/g' /etc/systemd/resolved.conf + sudo systemctl daemon-reload + sudo systemctl restart systemd-networkd + sudo systemctl restart systemd-resolved + dig distro.ibiblio.org + - name: Install C2V run: | v retry -- v install --git https://github.com/vlang/c2v @@ -73,6 +82,15 @@ jobs: - uses: actions/checkout@v4 - name: Build V run: make -j4 && ./v symlink + + - name: Set 8.8.8.8 as dns server + run: | + sudo sed -i 's/#DNS=/DNS=8.8.8.8 8.8.4.4/g' /etc/systemd/resolved.conf + sudo systemctl daemon-reload + sudo systemctl restart systemd-networkd + sudo systemctl restart systemd-resolved + dig distro.ibiblio.org + - name: Install C2V run: | v retry -- v install --git https://github.com/vlang/c2v diff --git a/vlib/v/markused/markused.v b/vlib/v/markused/markused.v index e5deed36a01cda..99fb2ced411fc5 100644 --- a/vlib/v/markused/markused.v +++ b/vlib/v/markused/markused.v @@ -42,12 +42,9 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a 'error', 'builtin_init', 'fast_string_eq', - // TODO: process the _vinit const initializations automatically too - 'main.vtest_init', - 'main.vtest_new_metainfo', - 'main.vtest_new_filemetainfo', 'println', ] + $if debug_used_features ? { dump(table.used_features) } @@ -295,7 +292,7 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a } // testing framework: if pref_.is_test { - if k.starts_with('test_') || k.contains('.test_') { + if k.starts_with('test_') || k.contains('.test_') || k.contains('.vtest_') { all_fn_root_names << k continue } @@ -400,6 +397,7 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a all_fn_root_names << 'time.unix' // used by json table.used_features.used_maps++ // json needs new_map etc } + mut walker := Walker.new( table: table files: ast_files