Skip to content

Commit

Permalink
adding windows test driver fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kreuzberger committed Apr 8, 2024
1 parent 7583400 commit 83c7559
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/drivers/QtTestDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,32 @@ namespace cucumber {
namespace internal {

const InvokeResult QtTestStep::invokeStepBody() {
QTemporaryFile file;
if (!file.open()) {
return InvokeResult::failure("Unable to open temporary file needed for this test");
QString file_name;
{
QTemporaryFile file;
if (!file.open()) {
return InvokeResult::failure("Unable to open temporary file needed for this test");
}
file.close();
}
file.close();

QtTestObject testObject(this);
file_name += ".txt";

QtTestObject testObject( this );
int returnValue = QTest::qExec(
&testObject,
QStringList() << "test"
<< "-o" << file.fileName()
<< "-o" << file_name
);
if (returnValue == 0) {
return InvokeResult::success();
} else {
file.open();
QTextStream ts(&file);
return InvokeResult::failure(ts.readAll().toLocal8Bit());
auto ok = ( returnValue == 0 ) ? true : false;
std::string error_text;
QFile file( file_name );
if(!ok) {
file.open( QIODevice::ReadOnly );
error_text = QString::fromLocal8Bit( file.readAll() ).toStdString();
}
//file.remove();
return ok ? InvokeResult::success() : InvokeResult::failure( error_text );
}

}
Expand Down

0 comments on commit 83c7559

Please sign in to comment.