From 1eedf1e3e76b4650015cec007a9d7f8c4be3898b Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Wed, 17 Apr 2024 15:31:35 -0700 Subject: Remove unused options from wasm-shell (#6508) None of our tests exercised the --entry or --skip options in wasm-shell, and since wasm-shell is probably not used for anything outside our testing, there's no reason to keep them. Remove them. --- src/tools/wasm-shell.cpp | 63 ++++++++---------------------------------------- 1 file changed, 10 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/tools/wasm-shell.cpp b/src/tools/wasm-shell.cpp index 29ccc6c7f..872d40c67 100644 --- a/src/tools/wasm-shell.cpp +++ b/src/tools/wasm-shell.cpp @@ -43,46 +43,6 @@ Name INVOKE("invoke"); Name REGISTER("register"); Name GET("get"); -struct ShellOptions : public Options { - Name entry; - std::set skipped; - - const std::string WasmShellOption = "wasm-shell options"; - - ShellOptions(const std::string& command, const std::string& description) - : Options(command, description) { - (*this) - .add("--entry", - "-e", - "Call the entry point after parsing the module", - WasmShellOption, - Options::Arguments::One, - [this](Options*, const std::string& argument) { entry = argument; }) - .add("--skip", - "-s", - "Skip input on certain lines (comma-separated-list)", - WasmShellOption, - Options::Arguments::One, - [this](Options*, const std::string& argument) { - size_t i = 0; - while (i < argument.size()) { - auto ending = argument.find(',', i); - if (ending == std::string::npos) { - ending = argument.size(); - } - auto sub = argument.substr(i, ending - i); - skipped.insert(atoi(sub.c_str())); - i = ending + 1; - } - }) - .add_positional("INFILE", - Options::Arguments::One, - [](Options* o, const std::string& argument) { - o->extra["infile"] = argument; - }); - } -}; - class Shell { protected: std::map> modules; @@ -320,7 +280,7 @@ protected: } protected: - ShellOptions& options; + Options& options; // spectest module is a default host-provided module defined by the spec's // reference interpreter. It's been replaced by the `(register ...)` @@ -376,21 +336,13 @@ protected: } public: - Shell(ShellOptions& options) : options(options) { buildSpectestModule(); } + Shell(Options& options) : options(options) { buildSpectestModule(); } bool parseAndRun(Element& root) { size_t i = 0; while (i < root.size()) { Element& curr = *root[i]; - if (options.skipped.count(curr.line) > 0) { - Colors::green(std::cerr); - std::cerr << "SKIPPING [line: " << curr.line << "]\n"; - Colors::normal(std::cerr); - i++; - continue; - } - if (curr[0]->str() != MODULE) { Colors::red(std::cerr); std::cerr << i << '/' << (root.size() - 1); @@ -416,11 +368,16 @@ int main(int argc, const char* argv[]) { Name entry; std::set skipped; - ShellOptions options("wasm-shell", "Execute .wast files"); + // Read stdin by default. + std::string infile = "-"; + Options options("wasm-shell", "Execute .wast files"); + options.add_positional( + "INFILE", + Options::Arguments::One, + [&](Options* o, const std::string& argument) { infile = argument; }); options.parse(argc, argv); - auto input( - read_file>(options.extra["infile"], Flags::Text)); + auto input = read_file(infile, Flags::Text); bool checked = false; try { -- cgit v1.2.3