Removed pointer to external editor resource in IsolTestOptions, changed TestTool::handleResponse() to get editor value from m_options member variable

This commit is contained in:
hawkess 2021-09-20 13:22:58 -05:00
parent 5edabc014d
commit 4fd5093d94
3 changed files with 6 additions and 11 deletions

View File

@ -56,20 +56,18 @@ std::string editorPath()
} }
IsolTestOptions::IsolTestOptions(std::string* _editor): IsolTestOptions::IsolTestOptions():
CommonOptions(description) CommonOptions(description)
{ {
editor = _editor;
enforceViaYul = true; enforceViaYul = true;
enforceGasTest = (evmVersion() == langutil::EVMVersion{}); enforceGasTest = (evmVersion() == langutil::EVMVersion{});
enforceGasTestMinValue = 100000;
} }
void IsolTestOptions::addOptions() void IsolTestOptions::addOptions()
{ {
CommonOptions::addOptions(); CommonOptions::addOptions();
options.add_options() options.add_options()
("editor", po::value<std::string>(editor)->default_value(editorPath()), "Path to editor for opening test files.") ("editor", po::value<std::string>(&editor)->default_value(editorPath()), "Path to editor for opening test files.")
("help", po::bool_switch(&showHelp)->default_value(showHelp), "Show this help screen.") ("help", po::bool_switch(&showHelp)->default_value(showHelp), "Show this help screen.")
("no-color", po::bool_switch(&noColor)->default_value(noColor), "Don't use colors.") ("no-color", po::bool_switch(&noColor)->default_value(noColor), "Don't use colors.")
("accept-updates", po::bool_switch(&acceptUpdates)->default_value(acceptUpdates), "Automatically accept expectation updates.") ("accept-updates", po::bool_switch(&acceptUpdates)->default_value(acceptUpdates), "Automatically accept expectation updates.")

View File

@ -33,9 +33,9 @@ struct IsolTestOptions: CommonOptions
bool noColor = false; bool noColor = false;
bool acceptUpdates = false; bool acceptUpdates = false;
std::string testFilter = std::string{}; std::string testFilter = std::string{};
std::string* editor = nullptr; std::string editor = std::string{};
explicit IsolTestOptions(std::string* _editor); explicit IsolTestOptions();
void addOptions() override; void addOptions() override;
bool parse(int _argc, char const* const* _argv) override; bool parse(int _argc, char const* const* _argv) override;
void validate() const override; void validate() const override;

View File

@ -121,8 +121,6 @@ public:
fs::path const& _basepath, fs::path const& _basepath,
fs::path const& _path fs::path const& _path
); );
static string editor;
private: private:
enum class Request enum class Request
{ {
@ -145,7 +143,6 @@ private:
static bool m_exitRequested; static bool m_exitRequested;
}; };
string TestTool::editor;
bool TestTool::m_exitRequested = false; bool TestTool::m_exitRequested = false;
TestTool::Result TestTool::process() TestTool::Result TestTool::process()
@ -258,7 +255,7 @@ TestTool::Request TestTool::handleResponse(bool _exception)
} }
case 'e': case 'e':
cout << endl << endl; cout << endl << endl;
if (system((TestTool::editor + " \"" + m_path.string() + "\"").c_str())) if (system((m_options.editor + " \"" + m_path.string() + "\"").c_str()))
cerr << "Error running editor command." << endl << endl; cerr << "Error running editor command." << endl << endl;
return Request::Rerun; return Request::Rerun;
case 'q': case 'q':
@ -425,7 +422,7 @@ int main(int argc, char const *argv[])
setupTerminal(); setupTerminal();
{ {
auto options = std::make_unique<solidity::test::IsolTestOptions>(&TestTool::editor); auto options = std::make_unique<solidity::test::IsolTestOptions>();
if (!options->parse(argc, argv)) if (!options->parse(argc, argv))
return -1; return -1;