You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[net] for whether the external network can be used
I initially thought - great! It must do some quick check to see if there's a network connection, and if the internet can be reached. I wrote many of my test scripts with lines like [!net] skip 'requires network access'.
Imagine my confusion when I peeked at the implementation:
This makes sense for the Go project's trybots, but not much else. I think the docs should either discourage the use of [net], or implement one that actually does something useful.
I can think of multiple implementations:
Try to dial a static IP, defaulting to a common and fast one like 8.8.8.8. A bit slow, but portable and effective. If someone is concerned about "dialing home", they can change the IP, or not use [net].
A best-effort check on a per-platform basis. For example, on Linux one can use ip route to see if there's a default network route. There usually is none if there's no network connection. For example, ip route get 8.8.8.8 can tell you if there's a possible route to a public IP:
$ ip route get 8.8.8.8
8.8.8.8 via 192.168.1.1 dev wlp2s0 src 192.168.1.111 uid 1000
cache
This best-effort method could always return true on platforms that don't yet implement a decent check.
The text was updated successfully, but these errors were encountered:
I personally think that this should be a best-effort immediate check. The check should be "is the machine connected to the external network", and not "does the internet work right now". If a laptop is connected to the internet but the internet connection is slow or flaky, the test should fail, not get skipped. Otherwise the user could very easily be misled or confused.
I think [net] should only skip tests on machines that are not connected to the internet on purpose. Like an offline test machine, or a laptop on an airplane, and so on.
The godoc reads:
I initially thought - great! It must do some quick check to see if there's a network connection, and if the internet can be reached. I wrote many of my test scripts with lines like
[!net] skip 'requires network access'
.Imagine my confusion when I peeked at the implementation:
This makes sense for the Go project's trybots, but not much else. I think the docs should either discourage the use of
[net]
, or implement one that actually does something useful.I can think of multiple implementations:
Try to dial a static IP, defaulting to a common and fast one like
8.8.8.8
. A bit slow, but portable and effective. If someone is concerned about "dialing home", they can change the IP, or not use[net]
.A best-effort check on a per-platform basis. For example, on Linux one can use
ip route
to see if there's a default network route. There usually is none if there's no network connection. For example,ip route get 8.8.8.8
can tell you if there's a possible route to a public IP:This best-effort method could always return true on platforms that don't yet implement a decent check.
The text was updated successfully, but these errors were encountered: