From d5ef91799df1cf590e8cb99b5dc6b07890c4cd8a Mon Sep 17 00:00:00 2001 From: Tingan Ho Date: Fri, 23 Jun 2017 00:03:06 +0200 Subject: [PATCH] Fixes failing tests --- src/Program/CommandParser.cpp | 14 +++++++------- src/Program/Utils.cpp | 1 - .../Projects/Commands_DefaultHelp/Output.txt | 18 +++++++++--------- .../Projects/Commands_DefaultHelp/Output.txt | 18 +++++++++--------- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/Program/CommandParser.cpp b/src/Program/CommandParser.cpp index 6cec52a7..141d8702 100644 --- a/src/Program/CommandParser.cpp +++ b/src/Program/CommandParser.cpp @@ -133,17 +133,17 @@ Session* parse_command_args(int argc, char* argv[]) { const Flag* flag_which_awaits_value = NULL; vector all_flags(default_flags); - auto add_command = [&](const char* arg) -> void { + auto add_command = [&](const char* command) -> void { if (has_command) { add_diagnostic(session, D::You_cannot_run_several_commands); return; } - for (auto const& command : commands) { - if (strcmp(command.name->c_str(), arg) == 0) { - session->command = command.kind; - if (command.flags != NULL) { - all_flags.insert(all_flags.end(), command.flags->begin(), command.flags->end()); + for (auto const& c : commands) { + if (strcmp(c.name->c_str(), command) == 0) { + session->command = c.kind; + if (c.flags != NULL) { + all_flags.insert(all_flags.end(), c.flags->begin(), c.flags->end()); } has_command = true; return; @@ -151,7 +151,7 @@ Session* parse_command_args(int argc, char* argv[]) { } // We can only reach here if the command is unknown. - add_diagnostic(session, D::Unknown_command, arg); + add_diagnostic(session, D::Unknown_command, command); }; auto add_command_flag = [&](const char* arg) -> bool { diff --git a/src/Program/Utils.cpp b/src/Program/Utils.cpp index 4a39d871..5b914eb8 100644 --- a/src/Program/Utils.cpp +++ b/src/Program/Utils.cpp @@ -190,7 +190,6 @@ string read_file(string filename) { while (getline(f, line)) { result += line + '\n'; } - result = result.substr(0, result.length() - 1); f.close(); return result; } diff --git a/src/Tests/Current/Projects/Commands_DefaultHelp/Output.txt b/src/Tests/Current/Projects/Commands_DefaultHelp/Output.txt index 829829c1..9db84bc6 100644 --- a/src/Tests/Current/Projects/Commands_DefaultHelp/Output.txt +++ b/src/Tests/Current/Projects/Commands_DefaultHelp/Output.txt @@ -2,17 +2,17 @@ Usage: l10ns [] Commands: - init Initialize project. - sync Synchronize localization keys. - log Show latest added localizations. - set Set localization. - extension-run-testsRun extension tests. - extension-accept-baselinesAccept baselines. + init Initialize project. + sync Synchronize localization keys. + log Show latest added localizations. + set Set localization. + extension-run-tests Run extension tests. + extension-accept-baselines Accept baselines. For more details: 'l10ns --help'. Options: - --help, -h Print help description. - --rootDir, -rd Specify current root dir(mainly for testing purposes). - --version Print current version. + --help, -h Print help description. + --rootDir, -rd Specify current root dir(mainly for testing purposes). + --version Print current version. diff --git a/src/Tests/Reference/Projects/Commands_DefaultHelp/Output.txt b/src/Tests/Reference/Projects/Commands_DefaultHelp/Output.txt index 829829c1..9db84bc6 100644 --- a/src/Tests/Reference/Projects/Commands_DefaultHelp/Output.txt +++ b/src/Tests/Reference/Projects/Commands_DefaultHelp/Output.txt @@ -2,17 +2,17 @@ Usage: l10ns [] Commands: - init Initialize project. - sync Synchronize localization keys. - log Show latest added localizations. - set Set localization. - extension-run-testsRun extension tests. - extension-accept-baselinesAccept baselines. + init Initialize project. + sync Synchronize localization keys. + log Show latest added localizations. + set Set localization. + extension-run-tests Run extension tests. + extension-accept-baselines Accept baselines. For more details: 'l10ns --help'. Options: - --help, -h Print help description. - --rootDir, -rd Specify current root dir(mainly for testing purposes). - --version Print current version. + --help, -h Print help description. + --rootDir, -rd Specify current root dir(mainly for testing purposes). + --version Print current version.