@@ -124,6 +124,7 @@ See also https://github.com/LinuxSuRen/api-testing/tree/master/sample`,
124124}
125125
126126func (o * runOption ) preRunE (cmd * cobra.Command , args []string ) (err error ) {
127+ o .context = cmd .Context ()
127128 writer := cmd .OutOrStdout ()
128129
129130 if o .reportFile != "" && ! strings .HasPrefix (o .reportFile , "http://" ) && ! strings .HasPrefix (o .reportFile , "https://" ) {
@@ -191,7 +192,7 @@ func (o *runOption) startMonitor() (err error) {
191192 sockFile := os .ExpandEnv (fmt .Sprintf ("$HOME/.config/atest/%s.sock" , "atest-monitor-docker" ))
192193 os .MkdirAll (filepath .Dir (sockFile ), 0755 )
193194
194- execer := fakeruntime.DefaultExecer {}
195+ execer := fakeruntime .NewDefaultExecerWithContext ( o . context )
195196 go func (socketURL , plugin string ) {
196197 if err = execer .RunCommandWithIO (plugin , "" , os .Stdout , os .Stderr , "server" , "--socket" , socketURL ); err != nil {
197198 log .Printf ("failed to start %s, error: %v" , socketURL , err )
@@ -216,7 +217,6 @@ func (o *runOption) startMonitor() (err error) {
216217
217218func (o * runOption ) runE (cmd * cobra.Command , args []string ) (err error ) {
218219 o .startTime = time .Now ()
219- o .context = cmd .Context ()
220220 o .limiter = limit .NewDefaultRateLimiter (o .qps , o .burst )
221221 defer func () {
222222 cmd .Printf ("\n consume: %s\n " , time .Since (o .startTime ).String ())
0 commit comments