Skip to content
Permalink
Browse files

Fix arguments parser not skipping the executable name

  • Loading branch information
Prof9 committed Feb 23, 2020
1 parent aa5b9a5 commit f4e78c1d08d53cf8f3dac86f8458b20d53d48a33
Showing with 14 additions and 10 deletions.
  1. +1 −1 Main/CommandLineInterface.cpp
  2. +6 −4 Main/Tests.cpp
  3. +4 −2 Main/Tests.h
  4. +3 −3 Main/main.cpp
@@ -31,7 +31,7 @@ static void printUsage(std::wstring executableName)

static bool parseArguments(const StringList& arguments, ArmipsArguments& settings)
{
size_t argpos = 0;
size_t argpos = 1;
bool readflags = true;
while (argpos < arguments.size())
{
@@ -164,7 +164,7 @@ bool TestRunner::executeTest(const std::wstring& dir, const std::wstring& testNa

// first word is error code, rest is arguments
expectedRetVal = std::stoi(args[0]);
args.erase(args.begin());
args[0] = this->executableName;
}
else
{
@@ -242,8 +242,10 @@ bool TestRunner::executeTest(const std::wstring& dir, const std::wstring& testNa
return result;
}

bool TestRunner::runTests(const std::wstring& dir)
bool TestRunner::runTests(const std::wstring& dir, const std::wstring& executableName)
{
this->executableName = executableName;

StringList tests = getTestsList(dir);
if (tests.empty())
{
@@ -285,8 +287,8 @@ bool TestRunner::runTests(const std::wstring& dir)
return successCount == tests.size();
}

bool runTests(const std::wstring& dir)
bool runTests(const std::wstring& dir, const std::wstring& executableName)
{
TestRunner runner;
return runner.runTests(dir);
return runner.runTests(dir, executableName);
}
@@ -12,9 +12,11 @@
class TestRunner
{
public:
bool runTests(const std::wstring& dir);
bool runTests(const std::wstring& dir, const std::wstring& executableName);
private:
enum class ConsoleColors { White, Red, Green };

std::wstring executableName;

StringList getTestsList(const std::wstring& dir, const std::wstring& prefix = L"/");
bool executeTest(const std::wstring& dir, const std::wstring& testName, std::wstring& errorString);
@@ -31,4 +33,4 @@ class TestRunner

};

bool runTests(const std::wstring& dir);
bool runTests(const std::wstring& dir, const std::wstring& executableName);
@@ -15,14 +15,14 @@ int wmain(int argc, wchar_t* argv[])
std::wstring name;

if (argc < 2)
return !runTests(L"Tests");
return !runTests(L"Tests", argv[0]);
else
return !runTests(argv[1]);
return !runTests(argv[1], argv[0]);
#endif

StringList arguments = getStringListFromArray(argv,argc);

runFromCommandLine(arguments);
return runFromCommandLine(arguments);
}

#ifndef _WIN32

0 comments on commit f4e78c1

Please sign in to comment.
You can’t perform that action at this time.