github / github/codeql

Tracing test code

Open
#9,309 0 comments 0 reactions 0 assignees View on GitHub
Go
Dominant language
CodeQL
Stars
10.1k
Forks
2.1k
Avg merge
2d 15h
Merged PRs (30d)
141

Description

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#'

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.