diff --git a/.github/workflows/installer.yml b/.github/workflows/installer.yml index d65c80b9cc..908ff204d1 100644 --- a/.github/workflows/installer.yml +++ b/.github/workflows/installer.yml @@ -140,7 +140,7 @@ jobs: - name: Run minimal Python interpeter tests in direct script mode run: | PATH="" $SHELL -c 'for i in "$GITHUB_WORKSPACE"/tests/*.qrs; do "$TWOD_EXEC_NAME" --generate-path "$i".py \ - --close -s 5 --script-path "$i".py -m script "$i"; done' + --generate-mode python --close -s 5 --script-path "$i".py -m script "$i"; done' timeout-minutes: 15 - name: Run minimal Javascript interpeter tests as fields in .qrs (For backward compatibility) @@ -154,3 +154,16 @@ jobs: PATH="" $SHELL -c 'for i in "$GITHUB_WORKSPACE"/tests/*.qrs; do "$PATCHER_NAME" -s "$i".py "$i" \ && "$TWOD_EXEC_NAME" --close -s 5 -m script "$i"; done' timeout-minutes: 5 + + - name: Run nxt generation tests + run: | + curl --output nxt_tests.7z "https://dl.trikset.com/edu/.solutions20200701/nxt_generation.7z" + 7z x nxt_tests.7z || 7za x nxt_tests.7z + set -x + for i in "$GITHUB_WORKSPACE"/nxt/*.qrs; + do + "$TWOD_EXEC_NAME" --generate-mode nxt --generate-path "$i".c --only-generate "$i" + ls "$GITHUB_WORKSPACE"/nxt/ + cat "$i".c + done + timeout-minutes: 5 diff --git a/plugins/robots/checker/twoDModelRunner/main.cpp b/plugins/robots/checker/twoDModelRunner/main.cpp index f71082b23b..27d0515e87 100644 --- a/plugins/robots/checker/twoDModelRunner/main.cpp +++ b/plugins/robots/checker/twoDModelRunner/main.cpp @@ -129,10 +129,13 @@ int main(int argc, char *argv[]) ", to save the generated JavaScript or Python code.") , "path-to-save-code", QString()); QCommandLineOption generateModeOption("generate-mode", QObject::tr("Select \"python\" or \"javascript\".") - , "generate-mode", "python"); + , "generate-mode", "javascript"); QCommandLineOption directScriptExecutionPathOption("script-path" , QObject::tr("The path to the Python or JavaScript file that will be used for interpretation.") , "script-path", QString()); + QCommandLineOption onlyGenerateOption("only-generate" + , QObject::tr("Do not run the interpretation in any mode, "\ + "this is a parameter that is only used to generate a file.")); parser.addOption(backgroundOption); parser.addOption(reportOption); parser.addOption(trajectoryOption); @@ -145,6 +148,7 @@ int main(int argc, char *argv[]) parser.addOption(generatePathOption); parser.addOption(generateModeOption); parser.addOption(directScriptExecutionPathOption); + parser.addOption(onlyGenerateOption); parser.process(*app); const QStringList positionalArgs = parser.positionalArguments(); if (positionalArgs.size() != 1) { @@ -162,12 +166,14 @@ int main(int argc, char *argv[]) const QString generatePath = parser.value(generatePathOption); const QString generateMode = parser.value(generateModeOption); const QString scriptFilePath = parser.value(directScriptExecutionPathOption); + const bool onlyGenerate = parser.isSet(onlyGenerateOption); QScopedPointer runner(new twoDModel::Runner(report, trajectory, input, mode, qrsFile)); auto speedFactor = parser.value(speedOption).toInt(); if (!generatePath.isEmpty()) { - if (generateMode != "python" and generateMode != "javascript") { + if (generateMode != "python" and generateMode != "javascript" + and generateMode != "nxt") { parser.showHelp(); QLOG_ERROR() << "Problem with generate code to " << generatePath; return TWO_D_MODEL_RUNNER_GENERATE_MODE_NOT_EXIST; @@ -178,6 +184,10 @@ int main(int argc, char *argv[]) } } + if (onlyGenerate || mode == "nxt") { + return 0; + } + if (!runner->interpret(backgroundMode, speedFactor, closeOnFinishMode, closeOnSuccessMode, showConsoleMode, scriptFilePath)) { return TWO_D_MODEL_RUNNER_INTERPRET_ERROR; diff --git a/plugins/robots/checker/twoDModelRunner/runner.cpp b/plugins/robots/checker/twoDModelRunner/runner.cpp index 7dc328138e..27a7bc7762 100644 --- a/plugins/robots/checker/twoDModelRunner/runner.cpp +++ b/plugins/robots/checker/twoDModelRunner/runner.cpp @@ -107,6 +107,11 @@ bool Runner::generate(const QString &generatePath, const QString &generateMode) emit action.action()->triggered(); } } + if (generateMode == "nxt") { + if (action.action()->objectName() == "generateCode") { + emit action.action()->triggered(); + } + } } auto codes = mTextManager->code(mMainWindow->activeDiagram()); diff --git a/qrtranslations/fr/plugins/robots/twoDModelRunner_fr.ts b/qrtranslations/fr/plugins/robots/twoDModelRunner_fr.ts index bee733e4f5..2564d5bebc 100644 --- a/qrtranslations/fr/plugins/robots/twoDModelRunner_fr.ts +++ b/qrtranslations/fr/plugins/robots/twoDModelRunner_fr.ts @@ -51,7 +51,12 @@ In background mode the session will be terminated just after the execution ended - + + Do not run the interpretation in any mode, this is a parameter that is only used to generate a file. + + + + Select "python" or "javascript". @@ -87,7 +92,7 @@ In background mode the session will be terminated just after the execution ended twoDModel::Runner - + Robot console diff --git a/qrtranslations/ru/plugins/robots/twoDModelRunner_ru.ts b/qrtranslations/ru/plugins/robots/twoDModelRunner_ru.ts index acbb364f09..158044b3b0 100644 --- a/qrtranslations/ru/plugins/robots/twoDModelRunner_ru.ts +++ b/qrtranslations/ru/plugins/robots/twoDModelRunner_ru.ts @@ -57,7 +57,16 @@ In background mode the session will be terminated just after the execution ended Путь к Python или Javascript файлу, который будет использоваться для интерпретации. - + + Do not run the interpretation in any mode, this is a parameter that is only used to generate a file. + + + + Do not run the interpretation in any mode, this is a parameter used only to generate a file. + Не запускайте интерпретацию ни в каком режиме, этот параметр используется только для генерации файла. + + + Select "python" or "javascript". Выберите "python" или "javascript". @@ -89,7 +98,7 @@ In background mode the session will be terminated just after the execution ended twoDModel::Runner - + Robot console Консоль робота