1. Isolate tests that use the "unsafe" package in a separate package
assert/internal/unsafetests. That way the assert package is not
tainted with unsafe.
2. Remove one reference to the private assert.isNil() in assert tests.
3. Add more tests of assert.Nil and assert.NotNil with unsafe.Pointer.
* suite: fix TestSubtestPanic failure (#1501)
The subtest of TestSubtestPanic is expected to fail, but that must not
make the testuite of package 'suite' to fail. So call Skip to make 'go
test' to ignore that expected failure.
* suite: fix subtests names
We are doing dirty things with testing.InternalTest. It looks like test
names should have the same prefix as the parent test, like if they were
true subtests (testing.T.Run).
So until we drop our usage of testing.InternamTest, let's rename the
tests.
Also added a few checks of the testing.RunTests result.
This fix adds panic handling for subtests which will achieve:
- subtests will fail for the correct test context when panicking
- the test execution is not stopped; the next subtest will be executed
There were two problems with the order of execution in the Suite.Run() method:
- One could not access the correct testing context ("s.T()") inside the SetupSubTest and TearDownSubTest methods. If the testing context was used for e.g. assertions of mocks in the TearDownSubTest, the results would not be "attached" to the correct test in the test output.
- The behavior was different to the order of execution for "root" tests (see lines 167-201) regarding the SetupTest and TearDownTest methods. This could confuse users of the library.
Also the logic to be deferred was joined together. This was fine beforehand because a panic in the TearDownSubTest would have had no influence on the "suite.SetT(oldT)". Now since a panic in the TearDownSubTest would lead to omitting the "suite.SetT(oldT)" this defer was split into two separate defers.
Fix TestEventuallyIssue805 which was flaky because of the use of a timer
that has exactly the same duration as the Eventually timout. But time is
not a synchronization primitive.
Now we use channels to ensure that the condition is still running and
Eventually times out before checking its return value.
The test is also renamed to TestEventuallyTimeout to more clearly show
its purpose.
Reduce calls to reflect.Type in implementation of mock.IsType by
extracting the type early.
This also avoids to keep alive references to the argument value.