File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,13 @@ var testPackage *TestPackage
1919// docker containers stepping on each other. For MSCs, use the MSC name. For versioned releases, use the version number
2020// along with any sub-directory name.
2121func TestMain (m * testing.M , namespace string ) {
22+ TestMainWithCleanup (m , namespace , nil )
23+ }
24+
25+ // TestMainWithCleanup is TestMain but with a cleanup function prior to terminating the test suite.
26+ // This function should be used for per-suite cleanup operations e.g tearing down containers, killing
27+ // child processes, etc.
28+ func TestMainWithCleanup (m * testing.M , namespace string , cleanup func ()) {
2229 var err error
2330 testPackage , err = NewTestPackage (namespace )
2431 if err != nil {
@@ -27,6 +34,9 @@ func TestMain(m *testing.M, namespace string) {
2734 }
2835 exitCode := m .Run ()
2936 testPackage .Cleanup ()
37+ if cleanup != nil {
38+ cleanup ()
39+ }
3040 os .Exit (exitCode )
3141}
3242
You can’t perform that action at this time.
0 commit comments