|
|
|
|
@ -83,41 +83,43 @@ void ShellRunnerTest::testShellrunnerQueries_data() |
|
|
|
|
QTest::newRow("Should bot show result for non-existent path") |
|
|
|
|
<< 0 << "/bin/trueeeeeee" << QString() << QStringList{}; |
|
|
|
|
QTest::newRow("Should show result for executable name") |
|
|
|
|
<< 1 << "true" << "true" << QStringList{}; |
|
|
|
|
<< 1 << "true" << executablePath << QStringList{}; |
|
|
|
|
QTest::newRow("Should show result for executable name and args") |
|
|
|
|
<< 1 << "true --help" << "true --help" << QStringList{}; |
|
|
|
|
<< 1 << "true --help" << executablePath + " --help" << QStringList{}; |
|
|
|
|
|
|
|
|
|
QTest::newRow("Should show result for executable and ENV variables") |
|
|
|
|
<< 1 << "LC_ALL=C true" << "true" << QStringList{"LC_ALL=C"}; |
|
|
|
|
<< 1 << "LC_ALL=C true" << executablePath << QStringList{"LC_ALL=C"}; |
|
|
|
|
QTest::newRow("Should show result for executable + args and ENV variables") |
|
|
|
|
<< 1 << "LC_ALL=C true --help" << "true --help" << QStringList{"LC_ALL=C"}; |
|
|
|
|
<< 1 << "LC_ALL=C true --help" << executablePath + " --help" << QStringList{"LC_ALL=C"}; |
|
|
|
|
QTest::newRow("Should show result for executable and multiple ENV variables") |
|
|
|
|
<< 1 << "LC_ALL=C TEST=1 true" << "true" << QStringList{"LC_ALL=C", "TEST=1"}; |
|
|
|
|
<< 1 << "LC_ALL=C TEST=1 true" << executablePath << QStringList{"LC_ALL=C", "TEST=1"}; |
|
|
|
|
QTest::newRow("Should show no result for non-existent executable path and ENV variable") |
|
|
|
|
<< 0 << "LC_ALL=C /bin/trueeeeeeeeeeee" << "" << QStringList{}; |
|
|
|
|
|
|
|
|
|
// Some file we can access with a ~
|
|
|
|
|
const QFileInfo testFile = createExecutableFile("test.sh"); |
|
|
|
|
const QString tildePath = KShell::tildeCollapse(testFile.absoluteFilePath()); |
|
|
|
|
const QString testFilePath = testFile.absoluteFilePath(); |
|
|
|
|
const QString tildePath = KShell::tildeCollapse(testFilePath); |
|
|
|
|
|
|
|
|
|
QTest::newRow("Should show result for full path with tilde") |
|
|
|
|
<< 1 << tildePath << KShell::quoteArg(tildePath) << QStringList{}; |
|
|
|
|
<< 1 << tildePath << KShell::quoteArg(testFilePath) << QStringList{}; |
|
|
|
|
QTest::newRow("Should show result for full path with tilde and envs") |
|
|
|
|
<< 1 << "LC_ALL=C " + tildePath << KShell::quoteArg(tildePath) << QStringList{"LC_ALL=C"}; |
|
|
|
|
<< 1 << "LC_ALL=C " + tildePath << KShell::quoteArg(testFilePath) << QStringList{"LC_ALL=C"}; |
|
|
|
|
QTest::newRow("Should show result for full path with tilde + args and envs") |
|
|
|
|
<< 1 << "LC_ALL=C " + tildePath + " --help" << KShell::quoteArg(tildePath) + " --help" << QStringList{"LC_ALL=C"}; |
|
|
|
|
<< 1 << "LC_ALL=C " + tildePath + " --help" << KShell::quoteArg(testFilePath) + " --help" << QStringList{"LC_ALL=C"}; |
|
|
|
|
|
|
|
|
|
// Some file we can access with a ~ and which has a space in its filename
|
|
|
|
|
const QFileInfo testSpaceFile = createExecutableFile("test space.sh"); |
|
|
|
|
const QString testSpaceFilePath = testSpaceFile.absoluteFilePath(); |
|
|
|
|
const QString tildeSpacePath = KShell::tildeCollapse(testSpaceFile.absoluteFilePath()); |
|
|
|
|
|
|
|
|
|
QTest::newRow("Should show no result for full path with tilde and unquoted space") |
|
|
|
|
<< 0 << tildeSpacePath << QString() << QStringList{}; |
|
|
|
|
QTest::newRow("Should show result for full path with tilde and quoted space") |
|
|
|
|
<< 1 << KShell::quoteArg(tildeSpacePath) << KShell::quoteArg(tildeSpacePath) << QStringList{}; |
|
|
|
|
<< 1 << KShell::quoteArg(tildeSpacePath) << KShell::quoteArg(testSpaceFilePath) << QStringList{}; |
|
|
|
|
QTest::newRow("Should show result for full path with tilde, quoted space and args") |
|
|
|
|
<< 1 << KShell::quoteArg(tildeSpacePath) + " --help" |
|
|
|
|
<< KShell::joinArgs({tildeSpacePath, "--help"}) << QStringList{}; |
|
|
|
|
<< KShell::joinArgs({testSpaceFilePath, "--help"}) << QStringList{}; |
|
|
|
|
// clang-format on
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|