TestDialog::TestDialog(Settings* settings, QWidget *parent) : QDialog(parent), ui(new Ui::TestDialog) { ui->setupUi(this); s = settings; Testovac::initialize("testovac"); tasklist = toQStringList(Testovac::get_task_list()); for(int i=0;i<tasklist.size();i++) taskDescriptions.push_back(toQStringList(Testovac::get_task_description(tasklist.at(i).toStdString().c_str())).join("\n")); tasklist.push_back("Už si spravil všetky ulohy."); taskDescriptions.push_back("Už si spravil všetky ulohy."); currentTask = s->getInt("tasks/done"); }
int BaseCommand::run(char* argv[], int argc) { QStringList args = toQStringList(argv, argc); args = args.mid(2); Settings::parseCommonArguments(args); return runSimple(args); }
QValueList< QString > QDBusDataList::toStringList(bool *ok) const { return toQStringList(ok); }
int BaseCommand::run(char* argv[], int argc) { QStringList args = toQStringList(argv, argc); args = args.mid(2); bool foundOne = true; while (args.size() > 0 && foundOne) { if (args[0] == "--conf" || args[0] == "-C") { if (args.size() < 2) { throw HootException("--conf must be followed by a file name."); } conf().loadJson(args[1]); // move on to the next argument. args = args.mid(2); } else if (args[0] == "--debug") { Log::getInstance().setLevel(Log::Debug); args = args.mid(1); } else if (args[0] == "--info") { Log::getInstance().setLevel(Log::Info); args = args.mid(1); } else if (args[0] == "--warn") { Log::getInstance().setLevel(Log::Warn); args = args.mid(1); } else if (args[0] == "--error") { Log::getInstance().setLevel(Log::Error); args = args.mid(1); } else if (args[0] == "--define" || args[0] == "-D") { if (args.size() < 2) { throw HootException("--define or -D must be followed by key=value."); } QString kv = args[1]; QStringList kvl = kv.split("+="); bool append = true; if (kvl.size() != 2) { // split on the first '=' int sep = kv.indexOf('='); kvl.clear(); if (sep != -1) { kvl << kv.mid(0, sep); kvl << kv.mid(sep + 1); } append = false; } if (kvl.size() != 2) { throw HootException("define must takes the form key=value."); } if (append) { QStringList values = kvl[1].split(";", QString::SkipEmptyParts); conf().append(kvl[0], values); } else { conf().set(kvl[0], kvl[1]); } // move on to the next argument. args = args.mid(2); } else { foundOne = false; } } // re-initialize the logger and other resources after the settings have been parsed. Hoot::getInstance().reinit(); return runSimple(args); }
void TestDialog::on_pushButton_clicked() { Logger::log("Submit start"); ui->textBrowser->clear(); compile_output.clear(); output.clear(); if(currentTask>=tasklist.size()-1)return; compile_settings.compiler = (ui->comboBox->currentText()=="cpp")?CompileSettings::COMPILER_CPP:CompileSettings::COMPILER_PAS; compile_settings.compile_with_warnings = s->getInt("upgrades/showCompilationWarnings"); test_settings.memory_limit = s->getBool("upgrades/memoryLimit")?10000:1000; test_settings.time_limit = 2000; test_settings.full_test_log = s->getInt("upgrades/showFullLog"); prog = fromQStringList(program.split("\n")); // teraz za to zaplatia // COMPILE ONLY if(ui->radioButtonCompileOnly->isChecked()){ s->decrement("credits/count",s->getInt("prices/compileAction")); ui->pushButton->setEnabled(s->getInt("credits/count")>=s->getInt("prices/compileAction")); ui->textBrowser->append("COMPILING..."); int retval = Testovac::compile(prog,compile_settings,&compile_output); ui->textBrowser->append((retval==0)?"OK":"FAILED"); return; } // SUBMIT if(ui->radioButtonSubmit->isChecked()){ s->decrement("credits/count",s->getInt("prices/submitAction")); ui->pushButton->setEnabled(s->getInt("credits/count")>=s->getInt("prices/submitAction")); ui->textBrowser->append("SUBMITTING..."); emit submitting(); int retval = Testovac::submit_solution(tasklist.at(currentTask).toAscii(),prog,compile_settings,test_settings,&compile_output,&output); Logger::log("Submit uloha "+QString::number(currentTask)+": "+((retval==0)?"PASSED":"FAILED")); ui->textBrowser->append(retval==0?"PASSED":"FAILED"); if(s->getBool("upgrades/showCompilationStatus")){ ui->textBrowser->append(""); ui->textBrowser->append("<hr>COMPILATION OUTPUT: "); ui->textBrowser->append(toQStringList(compile_output).join("\n")); } if(s->getBool("upgrades/showLog")){ ui->textBrowser->append(""); ui->textBrowser->append("<hr>TEST LOG:"); ui->textBrowser->append(toQStringList(output).join("\n")); } if(retval==0){ qDebug() << currentTask << ": OK"; currentTask++; s->increment("credits/count",s->getInt("credits/submit_gain")); s->setProp("tasks/done",currentTask); if(currentTask==tasklist.size()-1) qDebug() << "HOTOVO"; } return; } // MANUAL TEST if(ui->radioButtonManualTest->isChecked()){ s->decrement("credits/count",s->getInt("prices/manualTestAction")); ui->pushButton->setEnabled(s->getInt("credits/count")>=s->getInt("prices/manualTestAction")); ui->textBrowser->append("MANUAL TESTING..."); std::vector<std::string> input = fromQStringList(ui->plainTextEdit->toPlainText().split("\n")); int retval = Testovac::test_on_input(prog,input,compile_settings,test_settings,&compile_output,&output); if(retval!=0)ui->textBrowser->append("FAILED TO RUN"); if(s->getBool("upgrades/showCompilationStatus")){ ui->textBrowser->append(""); ui->textBrowser->append("<hr>COMPILATION OUTPUT: "); ui->textBrowser->append(toQStringList(compile_output).join("\n")); } if(s->getBool("upgrades/showLog")){ ui->textBrowser->append(""); ui->textBrowser->append("<hr>TEST LOG:"); ui->textBrowser->append(toQStringList(output).join("\n")); } return; } }