| 550 | } |
| 551 | |
| 552 | void JudgingThread::testlibSpecialJudge(const QString &fileName) { |
| 553 | if (! QFileInfo::exists(inputFile)) { |
| 554 | score = 0; |
| 555 | result = FileError; |
| 556 | message = tr("Cannot find standard input file"); |
| 557 | return; |
| 558 | } |
| 559 | |
| 560 | if (! QFileInfo::exists(fileName)) { |
| 561 | score = 0; |
| 562 | result = FileError; |
| 563 | message = tr(R"(Cannot find contestant's output file)"); |
| 564 | return; |
| 565 | } |
| 566 | |
| 567 | if (! QFileInfo::exists(outputFile)) { |
| 568 | score = 0; |
| 569 | result = FileError; |
| 570 | message = tr("Cannot find standard output file"); |
| 571 | return; |
| 572 | } |
| 573 | |
| 574 | auto judge = std::make_unique<QProcess>(this); |
| 575 | QStringList arguments; |
| 576 | arguments << inputFile << fileName << outputFile; |
| 577 | judge->setStandardErrorFile(workingDirectory + "_score"); |
| 578 | judge->start(Settings::dataPath() + task->getSpecialJudge(), arguments); |
| 579 | |
| 580 | if (! judge->waitForStarted(-1)) { |
| 581 | score = 0; |
| 582 | result = InvalidSpecialJudge; |
| 583 | return; |
| 584 | } |
| 585 | |
| 586 | QFile scoreFile(workingDirectory + "_score"); |
| 587 | |
| 588 | auto removeTempFiles = qScopeGuard([&] { scoreFile.remove(); }); |
| 589 | |
| 590 | QElapsedTimer timer; |
| 591 | timer.start(); |
| 592 | bool flag = false; |
| 593 | |
| 594 | while (timer.elapsed() < specialJudgeTimeLimit) { |
| 595 | if (judge->state() != QProcess::Running) { |
| 596 | flag = true; |
| 597 | break; |
| 598 | } |
| 599 | |
| 600 | QCoreApplication::processEvents(); |
| 601 | |
| 602 | if (stopJudging) { |
| 603 | judge->kill(); |
| 604 | return; |
| 605 | } |
| 606 | |
| 607 | msleep(10); |
| 608 | } |
| 609 |
nothing calls this directly
no test coverage detected