MCPcopy Create free account
hub / github.com/containerd/nerdctl / Run

Method Run

mod/tigron/test/case.go:81–283  ·  view source on GitHub ↗

Run prepares and executes the test, and any possible subtests.

(t *testing.T)

Source from the content-addressed store, hash-verified

79
80// Run prepares and executes the test, and any possible subtests.
81func (test *Case) Run(t *testing.T) {
82 t.Helper()
83 // Run the test
84 //nolint:thelper
85 testRun := func(subT *testing.T) {
86 subT.Helper()
87
88 silentT := assertive.WithSilentSuccess(subT)
89
90 assertive.True(silentT, test.t == nil, "You cannot run a test multiple times")
91 assertive.True(silentT, test.Description != "" || test.parent == nil,
92 "A subtest description cannot be empty")
93 assertive.True(silentT, test.Command == nil || test.Expected != nil,
94 "Expectations for a test command cannot be nil. You may want to use `Setup` instead"+
95 "of `Command`.")
96
97 // Attach testing.T
98 test.t = subT
99
100 // Ensure we have env
101 if test.Env == nil {
102 test.Env = map[string]string{}
103 }
104
105 // If we have a parent, get parent env, data and config
106 var parentData Data
107
108 var parentConfig Config
109
110 if test.parent != nil {
111 parentData = test.parent.Data
112 parentConfig = test.parent.Config
113
114 for k, v := range test.parent.Env {
115 if _, ok := test.Env[k]; !ok {
116 test.Env[k] = v
117 }
118 }
119 }
120
121 // Inherit and attach Data and Config
122 test.Data = newData(test.t, test.Data, parentData)
123 test.Config = configureConfig(test.Config, parentConfig)
124
125 var custCom CustomizableCommand
126 if registeredTestable == nil {
127 custCom = NewGenericCommand()
128 } else {
129 custCom = registeredTestable.CustomCommand(test, test.t)
130 }
131
132 // Separate cwd from the temp directory
133 custCom.WithCwd(test.t.TempDir())
134 custCom.withT(test.t)
135 // Set the command tempdir to another temp location.
136 // This is required for the current extension mechanism to allow creation of command dependent configuration
137 // assets. Note that this is a different location than both CWD and Data.Temp().Path().
138 custCom.withTempDir(test.t.TempDir())

Callers 15

TestCompletionFunction · 0.95
TestSharedNetworkSetupFunction · 0.95
TestNoneNetworkHostNameFunction · 0.95
TestHostNetworkHostNameFunction · 0.95
TestDNSWithGlobalConfigFunction · 0.95
TestReservePortsFunction · 0.95
TestExecFunction · 0.95

Calls 15

withTMethod · 0.95
withTempDirMethod · 0.95
withEnvMethod · 0.95
withConfigMethod · 0.95
newDataFunction · 0.85
configureConfigFunction · 0.85
NewGenericCommandFunction · 0.85
HelperMethod · 0.65
CustomCommandMethod · 0.65
WithCwdMethod · 0.65
TempDirMethod · 0.65
SkipMethod · 0.65

Tested by 15

TestCompletionFunction · 0.76
TestSharedNetworkSetupFunction · 0.76
TestNoneNetworkHostNameFunction · 0.76
TestHostNetworkHostNameFunction · 0.76
TestDNSWithGlobalConfigFunction · 0.76
TestReservePortsFunction · 0.76
TestExecFunction · 0.76