If you’re looking for something assertion-like, that’s if foo { panic("bug: foo happened") }. The cases where that’s warranted are few and far between
though, think “something happened that proves our assumptions are wildly incorrect and continuing at this point will eat the user’s data”.
For something of note that should end up in the log, use l.Infoln. If it’s something serious and actionable that the user can fix use l.Warnln.
Keeping in mind that Syncthing will be dead in the water and the action will probably be retried repeatedly with the same crash. So if there’s a safer option, better take that.
l.Warnf() seems to have a negative side effect that is it displayed to the user every time the warning is issued. Is there a way to show it only once, or once a day, or so?
I have tested mine changes on Windows. How can I test that it works on Linux etc. too? Would you test it after I send the pull request? Or what are my options?
Tests should clean up after themselves. (Maybe it doesn’t, but it should.) Keep in kind you can’t assume the tests run with admin privileges. It may not be feasible to automatically create junctions and test traversing them. There may be other aspects you can reasonably test.
I want to run that single test only, I do not know what running all the tests would do on my computer.
C:\Workspaces\Syncthing\lib>go test -run=fs/walkfs_test
can't load package: package .: no Go files in C:\Workspaces\Syncthing\lib
C:\Workspaces\Syncthing\lib>go test fs/walkfs_test
can't load package: package fs/walkfs_test is not in GOROOT (C:\Program Files\go\src\fs\walkfs_test)
Run takes a function name, not a directory. The non-run argument takes a fully qualified (not relative) go package name (import path), not a directory.
C:\Workspaces\Syncthing\lib>go test -run=fs.testWalkSkipSymlink
can't load package: package .: no Go files in C:\Workspaces\Syncthing\lib
C:\Workspaces\Syncthing\lib>go test -run=fs/testWalkSkipSymlink
can't load package: package .: no Go files in C:\Workspaces\Syncthing\lib
C:\Workspaces\Syncthing\lib>go test -run=fs/walkfs_test.go/testWalkSkipSymlink
can't load package: package .: no Go files in C:\Workspaces\Syncthing\lib
I simply don’t know. Could you please write me down a command that works?
It also works with explicitly relative paths (at least on linux), i.e. they must be preceeded by ./. E.g. go test ./lib/model -run SomeTest works, while go test lib/model -run SomeTest does not.
A pull request created. We can bring the discussion about the code there.
I need your assistance there, as it seems to me that the failed tests are not related with my code changes.