Compare commits

...

2 Commits

Author SHA1 Message Date
df2ade4988
feat(executor/sandbox): 1 cmd each time
All checks were successful
submodules sync / sync (push) Successful in 58s
build / build (push) Successful in 2m14s
build / trigger-build-image (push) Successful in 9s
2025-04-05 05:14:16 -04:00
9f78569447
chore(parser/diff): simpler variables 2025-04-05 04:51:36 -04:00
2 changed files with 21 additions and 23 deletions

View File

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

View File

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