Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Applications/SlicerApp/Testing/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ slicer_add_python_test(SCRIPT SlicerTestingExitSuccessTest.py)
slicer_add_python_test(SCRIPT SlicerTestingExitFailureTest.py)
set_tests_properties(py_SlicerTestingExitFailureTest PROPERTIES WILL_FAIL TRUE)

slicer_add_python_test(
SCRIPT SlicerTestingWithNonExistentScriptTest.py
SLICER_ARGS --no-main-window --disable-modules --exit-after-startup
TESTNAME_PREFIX nomainwindow_
)
set_tests_properties(py_nomainwindow_SlicerTestingWithNonExistentScriptTest PROPERTIES WILL_FAIL TRUE)

#
# Check if 'slicer.testing.runUnitTest()' works as expected
#
Expand Down
5 changes: 3 additions & 2 deletions Base/QTCore/qSlicerCoreApplication.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -928,14 +928,15 @@ void qSlicerCoreApplication::handleCommandLineArguments()
// Execute python script
if(!pythonScript.isEmpty())
{
qApp->processEvents();
if (QFile::exists(pythonScript))
{
qApp->processEvents();
this->corePythonManager()->executeFile(pythonScript);
}
else
{
qWarning() << "Specified python script doesn't exist:" << pythonScript;
this->corePythonManager()->executeString(
QString("raise RuntimeError(\"Specified python script doesn't exist: %1\")").arg(pythonScript));
}
}
QString pythonCode = options->pythonCode();
Expand Down