summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tools/tool-options.h11
-rw-r--r--src/tools/wasm-opt.cpp10
-rw-r--r--test/unit/test_asyncify.py2
-rw-r--r--test/unit/test_warnings.py18
4 files changed, 36 insertions, 5 deletions
diff --git a/src/tools/tool-options.h b/src/tools/tool-options.h
index 33a631975..46720d203 100644
--- a/src/tools/tool-options.h
+++ b/src/tools/tool-options.h
@@ -22,7 +22,7 @@
#include "support/command-line.h"
//
-// Shared optimization options for commandline tools
+// Shared options for commandline tools
//
namespace wasm {
@@ -30,6 +30,8 @@ namespace wasm {
struct ToolOptions : public Options {
PassOptions passOptions;
+ bool quiet = false;
+
ToolOptions(const std::string& command, const std::string& description)
: Options(command, description) {
(*this)
@@ -60,7 +62,12 @@ struct ToolOptions : public Options {
detectFeatures = true;
enabledFeatures.makeMVP();
disabledFeatures.makeMVP();
- });
+ })
+ .add("--quiet",
+ "-q",
+ "Emit less verbose output and hide trivial warnings.",
+ Arguments::Zero,
+ [this](Options*, const std::string&) { quiet = true; });
(*this)
.addFeature(FeatureSet::SignExt, "sign extension operations")
.addFeature(FeatureSet::Atomics, "atomic operations")
diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp
index 33e9a0396..b2d1f2c14 100644
--- a/src/tools/wasm-opt.cpp
+++ b/src/tools/wasm-opt.cpp
@@ -318,7 +318,11 @@ int main(int argc, const char* argv[]) {
curr = &other;
}
- if (options.runningPasses()) {
+ if (!options.runningPasses()) {
+ if (!options.quiet) {
+ std::cerr << "warning: no passes specified, not doing any work\n";
+ }
+ } else {
if (options.debug) {
std::cerr << "running passes...\n";
}
@@ -363,7 +367,9 @@ int main(int argc, const char* argv[]) {
}
if (options.extra.count("output") == 0) {
- std::cerr << "no output file specified, not emitting output\n";
+ if (!options.quiet) {
+ std::cerr << "warning: no output file specified, not emitting output\n";
+ }
return 0;
}
diff --git a/test/unit/test_asyncify.py b/test/unit/test_asyncify.py
index 9b7c403c0..052dedb0e 100644
--- a/test/unit/test_asyncify.py
+++ b/test/unit/test_asyncify.py
@@ -45,7 +45,7 @@ class AsyncifyTest(BinaryenTestCase):
('--pass-arg=asyncify-whitelist@DOS_ReadFile(unsigned short, unsigned char*, unsigned short*, bool)', None),
]:
print(arg, warning)
- err = run_process(WASM_OPT + [self.input_path('asyncify-pure.wast'), '--asyncify', arg], stdout=subprocess.PIPE, stderr=subprocess.PIPE).stderr.strip()
+ err = run_process(WASM_OPT + ['-q', self.input_path('asyncify-pure.wast'), '--asyncify', arg], stdout=subprocess.PIPE, stderr=subprocess.PIPE).stderr.strip()
if warning:
self.assertIn('warning', err)
self.assertIn(warning, err)
diff --git a/test/unit/test_warnings.py b/test/unit/test_warnings.py
new file mode 100644
index 000000000..9fb43a12b
--- /dev/null
+++ b/test/unit/test_warnings.py
@@ -0,0 +1,18 @@
+import subprocess
+
+from scripts.test.shared import WASM_OPT, run_process
+from .utils import BinaryenTestCase
+
+
+class WarningsText(BinaryenTestCase):
+ def test_warn_on_no_passes(self):
+ err = run_process(WASM_OPT + [self.input_path('asyncify-pure.wast'), '-o', 'a.wasm'], stderr=subprocess.PIPE).stderr
+ self.assertIn('warning: no passes specified, not doing any work', err)
+
+ def test_warn_on_no_output(self):
+ err = run_process(WASM_OPT + [self.input_path('asyncify-pure.wast'), '-O1'], stderr=subprocess.PIPE).stderr
+ self.assertIn('warning: no output file specified, not emitting output', err)
+
+ def test_quiet_suppresses_warnings(self):
+ err = run_process(WASM_OPT + [self.input_path('asyncify-pure.wast'), '-q'], stderr=subprocess.PIPE).stderr
+ self.assertNotIn('warning', err)