github.com/thediveo/gons@v0.9.9/package_test.go (about) 1 // Copyright 2019 Harald Albrecht. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package gons_test 16 17 import ( 18 "testing" 19 20 "github.com/thediveo/gons/reexec" 21 rxtst "github.com/thediveo/gons/reexec/testing" 22 23 . "github.com/onsi/ginkgo/v2" 24 . "github.com/onsi/gomega" 25 ) 26 27 func TestMain(m *testing.M) { 28 // There were no namespace switching errors, so we next register this 29 // generic re-execution handler that helps our test procedures. It simply 30 // puts the re-executed child to sleep, waiting to be killed. This allows 31 // the parent test to examine the child's namespaces taking all the time 32 // it needs in order to figure out if all went well. 33 reexec.Register("sleepingunbeauty", func() { 34 // Just keep this re-executed child sleeping; we will be killed by our 35 // parent when the test is done. What a lovely family. 36 select {} 37 }) 38 // Do NOT USE rxtst.TestMainWithCoverage in your own tests. Use instead: 39 // mm := &rxtst.M{M: m} 40 // os.Exit(mm.Run()) 41 rxtst.TestMainWithCoverage(m) 42 } 43 44 func TestPackage(t *testing.T) { 45 // Okay, we're a real test suite, and there was no re-executed child 46 // handler triggering... :) 47 RegisterFailHandler(Fail) 48 RunSpecs(t, "gons package") 49 }