aboutsummaryrefslogtreecommitdiff
path: root/src/stage1/analyze.cpp
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2021-01-22 15:18:39 +0100
committerLemonBoy <thatlemon@gmail.com>2021-01-22 15:46:58 +0100
commitac004e1bf13d00804c30f55d479b554774798307 (patch)
tree53f6540c14b043db95aed562945e66d0d9493dc5 /src/stage1/analyze.cpp
parentfc5ae1c4096fa814b97671525db17c0b4f0b786d (diff)
downloadzig-ac004e1bf13d00804c30f55d479b554774798307.tar.gz
zig-ac004e1bf13d00804c30f55d479b554774798307.zip
stage1: Allow nameless test blocks
Nameless blocks are never filtered, the test prefix is still applied.
Diffstat (limited to 'src/stage1/analyze.cpp')
-rw-r--r--src/stage1/analyze.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/stage1/analyze.cpp b/src/stage1/analyze.cpp
index a98bd28bb6..faf66f59f3 100644
--- a/src/stage1/analyze.cpp
+++ b/src/stage1/analyze.cpp
@@ -3871,13 +3871,18 @@ static void preview_test_decl(CodeGen *g, AstNode *node, ScopeDecls *decls_scope
return;
Buf *decl_name_buf = node->data.test_decl.name;
+ Buf *test_name;
- Buf *test_name = g->test_name_prefix ?
- buf_sprintf("%s%s", buf_ptr(g->test_name_prefix), buf_ptr(decl_name_buf)) : decl_name_buf;
+ if (decl_name_buf != nullptr) {
+ test_name = g->test_name_prefix ?
+ buf_sprintf("%s%s", buf_ptr(g->test_name_prefix), buf_ptr(decl_name_buf)) : decl_name_buf;
- if (g->test_filter != nullptr && buf_len(test_name) > 0 &&
- strstr(buf_ptr(test_name), buf_ptr(g->test_filter)) == nullptr) {
- return;
+ if (g->test_filter != nullptr && strstr(buf_ptr(test_name), buf_ptr(g->test_filter)) == nullptr) {
+ return;
+ }
+ } else {
+ // Unnamed test blocks are always executed.
+ test_name = buf_sprintf("%s", g->test_name_prefix ? buf_ptr(g->test_name_prefix) : "");
}
TldFn *tld_fn = heap::c_allocator.create<TldFn>();