github / github/codeql

Tracing test code

Ouverte
#9,309 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Go
Langage dominant
CodeQL
Étoiles
10.1k
Forks
2.1k
Merge moyen
2 j 15 h
PR mergées (30 j)
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#'

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.