github / github/codeql

Tracing test code

未关闭
#9,309 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Go
主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 15 小时
30 天内合并 PR
141

描述

For some use-cases (probably not security), it would be useful to instrument test code. This involves some correctness properties, and in my case a custom query to check proper use of the GORM database interface (checking the `Error` code after a SQL query).

I tried commands such as:

codeql database create ../ -l go -c "go test ./foo -c -count 1"

However, the tracer log indicates that we do not consider `go test` suitable for tracing.

Renaming all the `_test.go` files and then building them normally runs into problems with the implicit package structure around tests, e.g:

find . -name '*_test.go' | perl -p -e 's#(.*)_test.go#\1#' | xargs -I {} mv {}_test.go {}_tmp.go
rg 'package .*_test' -l | xargs perl -p -i -e 's#package (.*)_test#package \1#'

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。