dongyuan1160 2019-02-11 21:34
浏览 32

在“全部测试”中如何处理预期的+不相关的故障?

I'm using NPM to manage build/test/version lifecycle of a go package using go 1.11 modules. Prior to publishing, I'd like to check 'everything', included the modules, so I run: go test all (which runs tests in all included modules).

The problem is that the standard os package in go 1.11.5 (at least) fail on some Mac versions/environments (including mine). That's OK and irrelevant for my purposes, since the failures are in functions I don't use. However, this causes the publish process to fail since go test exits with a non-zero status.

Any advice on how to deal with this?

It would be great if there was a way to run all the tests for functions that are in the call tree of my local tests (go test all -relevant). Or, if I could name and skip the tests, that would be fine as well.

I'm aware of the -run flag, but that doesn't seem to help because I cannot know beforehand what tests to run, and (from what I've seen) the regex used by -run doesn't support negative lookaheads so it would be very tedious to construct a regular expression to exclude certain tests.

Failing os tests:

--- FAIL: TestStatError (0.00s)
    os_test.go:200: symlink no-such-file symlink: permission denied
--- FAIL: TestHardLink (0.00s)
    os_test.go:694: open "hardlinktestto" failed: open hardlinktestto: permission denied
--- FAIL: TestSymlink (0.00s)
    os_test.go:780: Create("symlinktestto") failed: open symlinktestto: permission denied
--- FAIL: TestLongSymlink (0.00s)
    os_test.go:847: symlink "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", "longsymlinktestfrom" failed: symlink 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef longsymlinktestfrom: permission denied
--- FAIL: TestRename (0.00s)
    os_test.go:868: open "renamefrom" failed: open renamefrom: permission denied
--- FAIL: TestRenameOverwriteDest (0.00s)
    os_test.go:896: write file "renameto" failed: open renameto: permission denied
--- FAIL: TestAppend (0.00s)
    os_test.go:1684: Open: open append.txt: permission denied
--- FAIL: TestSameFile (0.00s)
    os_test.go:1766: Create(a): open a: permission denied
FAIL
FAIL    os  19.145s
  • 写回答

1条回答 默认 最新

  • dongou3286 2019-02-11 21:38
    关注

    You can use build constraints to choose which tests are run by OS, architecture, or build tag. For those that are for OS-specific functionality, just make the tests OS-specific. There should be no such thing as "expected failures", these are just tests that are being misapplied.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分