CheckRequireFilesExists 检查配置文件里的所有文件是否存在
(config *commonStructs.JudgeConfiguration, configDir string)
| 53 | |
| 54 | // CheckRequireFilesExists 检查配置文件里的所有文件是否存在 |
| 55 | func CheckRequireFilesExists(config *commonStructs.JudgeConfiguration, configDir string) error { |
| 56 | var err error |
| 57 | // 检查特判程序是否存在 |
| 58 | if config.SpecialJudge.Mode != 0 { |
| 59 | _, err = os.Stat(path.Join(configDir, config.SpecialJudge.Checker)) |
| 60 | if os.IsNotExist(err) { |
| 61 | return errors.Errorf("special judge checker file (%s) not exists", config.SpecialJudge.Checker) |
| 62 | } |
| 63 | } |
| 64 | // 检查每个测试数据里的文件是否存在 |
| 65 | // 新版判题机要求无论有没有数据,都要有对应的输入输出文件。 |
| 66 | // 但Testlib模式例外,因为数据是由generator自动生成的。 |
| 67 | for i := 0; i < len(config.TestCases); i++ { |
| 68 | tcase := config.TestCases[i] |
| 69 | if !tcase.Enabled || tcase.UseGenerator { |
| 70 | continue |
| 71 | } |
| 72 | _, err = os.Stat(path.Join(configDir, tcase.Input)) |
| 73 | if os.IsNotExist(err) { |
| 74 | return errors.Errorf("test case (%s) input file (%s) not exists", tcase.Handle, tcase.Input) |
| 75 | } |
| 76 | _, err = os.Stat(path.Join(configDir, tcase.Output)) |
| 77 | if os.IsNotExist(err) { |
| 78 | return errors.Errorf("test case (%s) output file (%s) not exists", tcase.Handle, tcase.Output) |
| 79 | } |
| 80 | } |
| 81 | return nil |
| 82 | } |
| 83 | |
| 84 | // GetOrCreateBinaryRoot 获取二进制文件的目录 |
| 85 | func GetOrCreateBinaryRoot(config *commonStructs.JudgeConfiguration) (string, error) { |
no test coverage detected