mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-12 19:29:46 +08:00
fix: panic by data racing
This commit is contained in:
@@ -44,25 +44,27 @@ func (s *StepTestCaseWithOptionalArgs) Struct() *TStep {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *StepTestCaseWithOptionalArgs) Run(r *SessionRunner) (*StepResult, error) {
|
func (s *StepTestCaseWithOptionalArgs) Run(r *SessionRunner) (*StepResult, error) {
|
||||||
stepVariables, err := r.MergeStepVariables(s.step.Variables)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
s.step.Variables = stepVariables
|
|
||||||
|
|
||||||
stepResult := &StepResult{
|
stepResult := &StepResult{
|
||||||
Name: s.step.Name,
|
Name: s.step.Name,
|
||||||
StepType: stepTypeTestCase,
|
StepType: stepTypeTestCase,
|
||||||
Success: false,
|
Success: false,
|
||||||
}
|
}
|
||||||
testcase := s.step.TestCase.(*TestCase)
|
|
||||||
|
|
||||||
// copy testcase to avoid data racing
|
stepVariables, err := r.MergeStepVariables(s.step.Variables)
|
||||||
copiedTestCase := &TestCase{}
|
if err != nil {
|
||||||
if err := copier.Copy(copiedTestCase, testcase); err != nil {
|
|
||||||
log.Error().Err(err).Msg("copy testcase failed")
|
|
||||||
return stepResult, err
|
return stepResult, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// copy step to avoid data racing
|
||||||
|
copiedStep := &TStep{}
|
||||||
|
if err := copier.Copy(copiedStep, s.step); err != nil {
|
||||||
|
log.Error().Err(err).Msg("copy step failed")
|
||||||
|
return stepResult, err
|
||||||
|
}
|
||||||
|
|
||||||
|
copiedStep.Variables = stepVariables
|
||||||
|
copiedTestCase := copiedStep.TestCase.(*TestCase)
|
||||||
|
|
||||||
// override testcase config
|
// override testcase config
|
||||||
extendWithTestCase(s.step, copiedTestCase)
|
extendWithTestCase(s.step, copiedTestCase)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user