Skip to content

Commit 2e4535f

Browse files
committed
More debugging.
1 parent f6dfa00 commit 2e4535f

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

src/commands/run.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,11 @@ impl RunCommand {
118118
.handle_module(&store, &module_registry)
119119
.with_context(|| format!("failed to run main module `{}`", self.module.display()))
120120
{
121-
Ok(()) => (),
121+
Ok(()) => {
122+
eprintln!("ok!");
123+
}
122124
Err(e) => {
125+
eprintln!("error: {:?}", e);
123126
// If the program exited because of a trap, return an error code
124127
// to the outside environment indicating a more severe problem
125128
// than a simple failure.
@@ -139,6 +142,7 @@ impl RunCommand {
139142
return Err(e);
140143
}
141144
}
145+
eprintln!("all good");
142146

143147
Ok(())
144148
}
@@ -227,27 +231,32 @@ impl RunCommand {
227231
}
228232

229233
fn handle_module(&self, store: &Store, module_registry: &ModuleRegistry) -> Result<()> {
234+
eprintln!("instantiating module...");
230235
let (instance, module, data) =
231236
Self::instantiate_module(store, module_registry, &self.module)?;
232237

233238
// If a function to invoke was given, invoke it.
234239
if let Some(name) = self.invoke.as_ref() {
240+
eprintln!("invoking {}...", name);
235241
let data = ModuleData::new(&data)?;
236242
self.invoke_export(instance, &data, name)?;
237243
} else if module
238244
.exports()
239245
.iter()
240246
.any(|export| export.name().is_empty())
241247
{
248+
eprintln!("invoking default command export...");
242249
// Launch the default command export.
243250
let data = ModuleData::new(&data)?;
244251
self.invoke_export(instance, &data, "")?;
245252
} else {
253+
eprintln!("invoking the _start function...");
246254
// If the module doesn't have a default command export, launch the
247255
// _start function if one is present, as a compatibility measure.
248256
let data = ModuleData::new(&data)?;
249257
self.invoke_export(instance, &data, "_start")?;
250258
}
259+
eprintln!("success!");
251260

252261
Ok(())
253262
}

tests/cli_tests.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ fn run_wasmtime_for_output(args: &[&str]) -> Result<Output> {
1010
me.pop(); // chop off the file name
1111
me.pop(); // chop off `deps`
1212
me.push("wasmtime");
13-
Command::new(&me).args(args).output().map_err(Into::into)
13+
Command::new(&me)
14+
.args(args)
15+
.env("RUST_LOG", "trace")
16+
.output()
17+
.map_err(Into::into)
1418
}
1519

1620
// Run the wasmtime CLI with the provided args and, if it succeeds, return
@@ -85,21 +89,29 @@ fn run_wasmtime_simple_wat() -> Result<()> {
8589
// Running a wat that traps.
8690
#[test]
8791
fn run_wasmtime_unreachable_wat() -> Result<()> {
92+
dbg!("hi");
8893
let wasm = build_wasm("tests/wasm/unreachable.wat")?;
94+
dbg!("go");
8995
let output = run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"])?;
9096

97+
dbg!("yes");
9198
eprintln!(
92-
"stderr='{:?}' stdout='{:?}' status='{:?}'",
93-
output.stderr, output.stdout, output.status
99+
"stderr='{}' stdout='{}' status='{:?}'",
100+
String::from_utf8_lossy(&output.stderr),
101+
String::from_utf8_lossy(&output.stdout),
102+
output.status
94103
);
95-
assert_ne!(output.stderr, b"");
96-
assert_eq!(output.stdout, b"");
104+
dbg!("printed");
105+
assert_ne!(String::from_utf8_lossy(&output.stderr), "".to_owned());
106+
assert_eq!(String::from_utf8_lossy(&output.stdout), "".to_owned());
97107
assert!(!output.status.success());
108+
dbg!("ok");
98109

99110
let code = output
100111
.status
101112
.code()
102113
.expect("wasmtime process should exit normally");
114+
dbg!("done");
103115

104116
// Test for the specific error code Wasmtime uses to indicate a trap return.
105117
#[cfg(unix)]

0 commit comments

Comments
 (0)