Compare commits

..

No commits in common. "df2ade4988f9845f19d019fa0bed3e8fcbf93478" and "ee117b388b5e99eed99735e0830a5eae60397902" have entirely different histories.

2 changed files with 23 additions and 21 deletions

View File

@ -21,7 +21,6 @@ func (e *Sandbox) Run(cmds []stage.Cmd) ([]stage.ExecutorResult, error) {
} }
} }
// cannot use range loop since we need to change the value // cannot use range loop since we need to change the value
results := make([]stage.ExecutorResult, len(cmds))
for i := 0; i < len(cmds); i += 1 { for i := 0; i < len(cmds); i += 1 {
cmd := &cmds[i] cmd := &cmds[i]
if cmd.CopyIn == nil { if cmd.CopyIn == nil {
@ -32,20 +31,23 @@ func (e *Sandbox) Run(cmds []stage.Cmd) ([]stage.ExecutorResult, error) {
cmd.CopyIn[k] = stage.CmdFile{FileID: &fileID} cmd.CopyIn[k] = stage.CmdFile{FileID: &fileID}
} }
} }
pbCmd := convertPBCmd([]stage.Cmd{*cmd}) }
slog.Debug("sandbox execute", "i", i, "pbCmd size", proto.Size(pbCmd[0])) pbCmds := convertPBCmd(cmds)
pbReq := &pb.Request{Cmd: pbCmd} for i, pbCmd := range pbCmds {
slog.Debug("sandbox execute", "pbReq size", proto.Size(pbReq)) slog.Debug("sandbox execute", "i", i, "pbCmd size", proto.Size(pbCmd))
pbRet, err := e.execClient.Exec(context.TODO(), pbReq) }
if err != nil { pbReq := &pb.Request{Cmd: pbCmds}
return nil, err slog.Debug("sandbox execute", "pbReq size", proto.Size(pbReq))
} pbRet, err := e.execClient.Exec(context.TODO(), pbReq)
if pbRet.Error != "" { if err != nil {
return nil, fmt.Errorf("sandbox execute error: %s", pbRet.Error) return nil, err
} }
result := convertPBResult(pbRet.Results)[0] if pbRet.Error != "" {
return nil, fmt.Errorf("sandbox execute error: %s", pbRet.Error)
}
results := convertPBResult(pbRet.Results)
for _, result := range results {
maps.Copy(e.cachedMap, result.FileIDs) maps.Copy(e.cachedMap, result.FileIDs)
results[i] = result
} }
return results, nil return results, nil
} }

View File

@ -39,19 +39,17 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) (
if err != nil { if err != nil {
return nil, true, err return nil, true, err
} }
answerStr := string(answer)
resultStr := result.Files[output.FileName]
isSame := stringsEqual( isSame := stringsEqual(
answerStr, string(answer),
resultStr, result.Files[output.FileName],
output.CompareSpace, output.CompareSpace,
) )
slog.Info( slog.Debug(
"compare", "compare",
"filename", output.FileName, "filename", output.FileName,
"answerPath", output.AnswerPath, "answerPath", output.AnswerPath,
"actualLength", len(resultStr), "actualLength", len(result.Files[output.FileName]),
"answerLength", len(answerStr), "answerLength", len(string(answer)),
"index", i, "index", i,
"isSame", isSame, "isSame", isSame,
) )
@ -75,6 +73,8 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) (
} }
// Convert answer to string and split by lines // Convert answer to string and split by lines
truncated := false truncated := false
answerStr := string(answer)
resultStr := result.Files[output.FileName]
if len(answerStr) > output.MaxDiffLength { if len(answerStr) > output.MaxDiffLength {
answerStr = answerStr[:output.MaxDiffLength] answerStr = answerStr[:output.MaxDiffLength]
truncated = true truncated = true