Skip to content

Commit

Permalink
Add event processing after run
Browse files Browse the repository at this point in the history
  • Loading branch information
iakov committed Oct 3, 2024
1 parent 344a4a0 commit 38ab4e5
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scripts/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $EXECUTOR bash -lic " set -x; \
ASAN_OPTIONS=disable_coredump=0:detect_stack_use_after_return=1:fast_unwind_on_malloc=0:symbolize=1:use_sigaltstack=0 \
LSAN_OPTIONS=suppressions=\$PWD/bin/lsan.supp:fast_unwind_on_malloc=0 \
MSAN_OPTIONS=poison_in_dtor=1 \
make check -k -j2 \
make check -k -j2 TESTARGS='--gtest_death_test_style=threadsafe --gtest_catch_exceptions=0 --gtest_color=yes --gtest_random_seed=0' \
&& ls bin/x86-$CONFIG"

#exec timeout -k 10s 100s scripts/runtests.sh trikKernelTests trikCameraPhotoTests trikCommunicatorTests trikJsRunnerTests trikPyRunnerTests
4 changes: 3 additions & 1 deletion tests/trikPyRunnerTests/trikPyRunnerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ int TrikPyRunnerTest::run(const QString &script)
rc = EXIT_SCRIPT_ERROR;
std::cerr << qPrintable(e) << std::endl;
}
QCoreApplication::processEvents(); // for stdout messages
l.exit(rc);
} );
mStdOut.clear();
Expand All @@ -74,7 +75,8 @@ int TrikPyRunnerTest::runDirectCommandAndWaitForQuit(const QString &script)
QEventLoop l;
QObject::connect(&*mScriptRunner, &trikScriptRunner::TrikScriptRunnerInterface::completed
, &l, [&l](const QString &e) {
l.exit(e.isEmpty() ? EXIT_SCRIPT_SUCCESS
QCoreApplication::processEvents(); // dispatch events for print/stdout
l.exit(e.isEmpty() ? EXIT_SCRIPT_SUCCESS
: (qDebug() << e, EXIT_SCRIPT_ERROR));
});
mStdOut.clear();
Expand Down
1 change: 0 additions & 1 deletion trikKernel/src/fileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <QtCore/QFile>
#include <QtCore/QDir>

#include "exceptions/failedToOpenFileException.h"
#include "exceptions/failedToParseXmlException.h"

Expand Down
2 changes: 2 additions & 0 deletions trikScriptRunner/src/pythonEngineWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,10 @@ void PythonEngineWorker::doRun(const QString &script, const QFileInfo &scriptFil

auto wasError = mState != ready && PythonQt::self()->hadError();
mState = ready;
QCoreApplication::processEvents(); //dispatch events before reset
mScriptExecutionControl->reset();
releaseContext();
QCoreApplication::processEvents(); //dispatch events before emitting the signal
if (wasError) {
emit completed(mErrorMessage, 0);
} else {
Expand Down
3 changes: 3 additions & 0 deletions trikScriptRunner/src/scriptEngineWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "scriptable.h"
#include "utils.h"

#include <QCoreApplication>
#include <QFileInfo>
#include <QsLog.h>

Expand Down Expand Up @@ -220,6 +221,7 @@ void ScriptEngineWorker::doRun(const QString &script)
mThreading.waitForAll();
const QString error = mThreading.errorMessage();
QLOG_INFO() << "ScriptEngineWorker: evaluation ended with message" << error;
QCoreApplication::processEvents();
emit completed(error, mScriptId);
}

Expand Down Expand Up @@ -254,6 +256,7 @@ void ScriptEngineWorker::doRunDirect(const QString &command, int scriptId)
msg = mDirectScriptsEngine->uncaughtException().toString();
mDirectScriptsEngine.reset();
}
QCoreApplication::processEvents();
Q_EMIT completed(msg, mScriptId);
}
}
Expand Down
5 changes: 5 additions & 0 deletions trikScriptRunner/src/trikScriptRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <trikKernel/timeVal.h>
#include "threading.h"
#include <QCoreApplication>
#include <QMetaMethod>

using namespace trikControl;
Expand Down Expand Up @@ -156,11 +157,15 @@ void TrikScriptRunner::run(const QString &script, ScriptType stype, const QStrin
abortAll(); // FIXME: or fetchRunner(stype)->abort()? or abort(/*last*/)?

fetchRunner(stype)->run(script, fileName);
// Enforce events dispatch before return, f.e. handling of stdout messages
QCoreApplication::processEvents();
}

void TrikScriptRunner::runDirectCommand(const QString &command)
{
fetchRunner(mLastRunner)->runDirectCommand(command);
// Enforce events dispatch before return, f.e. handling of stdout messages
QCoreApplication::processEvents();
}

void TrikScriptRunner::abort()
Expand Down

0 comments on commit 38ab4e5

Please sign in to comment.