diff options
author | Thomas Lively <tlively@google.com> | 2024-04-17 15:31:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-17 15:31:35 -0700 |
commit | 1eedf1e3e76b4650015cec007a9d7f8c4be3898b (patch) | |
tree | 8aeb16e88b8b2d877438a111b74584de1b2e99de | |
parent | 4a84a4b047021dfefd59d5d6dfd53e55c99f6d8d (diff) | |
download | binaryen-1eedf1e3e76b4650015cec007a9d7f8c4be3898b.tar.gz binaryen-1eedf1e3e76b4650015cec007a9d7f8c4be3898b.tar.bz2 binaryen-1eedf1e3e76b4650015cec007a9d7f8c4be3898b.zip |
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.
-rw-r--r-- | src/tools/wasm-shell.cpp | 63 | ||||
-rw-r--r-- | test/lit/help/wasm-shell.test | 8 |
2 files changed, 10 insertions, 61 deletions
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<size_t> 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<Name, std::shared_ptr<Module>> 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<size_t> 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<std::vector<char>>(options.extra["infile"], Flags::Text)); + auto input = read_file<std::string>(infile, Flags::Text); bool checked = false; try { diff --git a/test/lit/help/wasm-shell.test b/test/lit/help/wasm-shell.test index c93045ef9..8214c06f9 100644 --- a/test/lit/help/wasm-shell.test +++ b/test/lit/help/wasm-shell.test @@ -6,14 +6,6 @@ ;; CHECK-NEXT: ================================================================================ ;; CHECK-NEXT: ;; CHECK-NEXT: -;; CHECK-NEXT: wasm-shell options: -;; CHECK-NEXT: ------------------- -;; CHECK-NEXT: -;; CHECK-NEXT: --entry,-e Call the entry point after parsing the module -;; CHECK-NEXT: -;; CHECK-NEXT: --skip,-s Skip input on certain lines (comma-separated-list) -;; CHECK-NEXT: -;; CHECK-NEXT: ;; CHECK-NEXT: General options: ;; CHECK-NEXT: ---------------- ;; CHECK-NEXT: |