testing - 为特定的操作系统或架构去测试文件

标签 testing go

在 Go 中,文件名具有语义。例如:

*_windows.go // Only include in compilations for Windows
*_unix.go    // Only include in compilations for Unix
*_386.go     // Only include in compilations for 386 systems
*_test.go    // Only include when run with `go test`

但是,我似乎无法让以下工作正常进行:

*_windows_test.go // Only include when running `go test` on windows
*_test_windows.go // Another attempt

这甚至可以用 Go 实现吗?如果是,怎么办?

最佳答案

只需使用 build constraint在测试文件上。

// +build windows

A build constraint is evaluated as the OR of space-separated options; each option evaluates as the AND of its comma-separated terms; and each term is an alphanumeric word or, preceded by !, its negation. That is, the build constraint:

关于testing - 为特定的操作系统或架构去测试文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28387378/

相关文章:

xml - 在 go 中解码 XML 时出现问题

go - go tool yacc 中最简单的解析器

php - 如何为使用 ExcelImport、存储库和模型的自定义命令编写 Laravel 测试

testing - 如何综合编译器测试数据?

python - 带有测试管理系统的黑盒测试框架

go - 查找 Golang 应用程序的位置

go - 如果任何 channel 关闭,有没有办法中断选择?

php - Codeception Actor Actor vs Helper?

javascript - 测试函数以在 Jest 中抛出错误

go - 如何使用指定的位数来fmt.Printf(“%b”,…)?