Skip to content

Commit 8502395

Browse files
lf-9999years
andauthoredMar 12, 2025··
[DUX-1897]: more clear output for interpreting modules for eval (#349)
This output was confusing and adding another log line does make it clearer what it's doing even though it just takes a couple of seconds. - [ ] Labeled the PR with `patch`, `minor`, or `major` to request a version bump when it's merged. - [ ] Updated the user manual in `docs/`. - [ ] Added integration / regression tests in `tests/`. --------- Co-authored-by: Rebecca Turner <[email protected]>
1 parent 90c2d37 commit 8502395

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed
 

‎src/ghci/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,6 @@ impl Ghci {
564564
// restore the old value when the function returns.
565565
for (path, commands) in self.eval_commands.clone() {
566566
for command in commands {
567-
tracing::info!("{path}:{command}");
568567
// If the `module` was already compiled, `ghci` may have loaded the interface file instead
569568
// of the interpreted bytecode, giving us this error message when we attempt to
570569
// load the top-level scope with `:module + *{module}`:
@@ -574,8 +573,10 @@ impl Ghci {
574573
// We use `:add *{module}` to force interpreting the module. We do this here instead of in
575574
// `add_module` to save time if eval commands aren't used (or aren't needed for a
576575
// particular module).
576+
tracing::info!("Loading {path} in interpreted mode for eval commands");
577577
self.interpret_module(&path, log).await?;
578578
let module = self.search_paths.path_to_module(&path)?;
579+
tracing::info!("Eval {path}:{command}");
579580
self.stdin
580581
.eval(&mut self.stdout, &module, &command.command, log)
581582
.await?;

‎src/ghci/parse/eval.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ pub struct EvalCommand {
3939

4040
impl Display for EvalCommand {
4141
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42-
write!(f, "{}:{}: {}", self.line, self.column, self.display_command)
42+
write!(
43+
f,
44+
"{}:{}: -- $> {}",
45+
self.line, self.column, self.display_command
46+
)
4347
}
4448
}
4549

‎tests/eval.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async fn can_eval_commands() {
3333
let defined_in_multiple_files =
3434
BaseMatcher::message("Read stderr line").with_field("line", "defined in multiple files");
3535

36-
let eval_message = BaseMatcher::message(r"MyModule.hs:\d+:\d+: example \+\+ example")
36+
let eval_message = BaseMatcher::message(r"MyModule.hs:\d+:\d+: -- \$> example \+\+ example")
3737
.but_not(defined_in_multiple_files.clone());
3838
session
3939
.assert_logged_or_wait(eval_message.clone())
@@ -95,8 +95,10 @@ async fn can_load_new_eval_commands_multiline() {
9595
.await
9696
.unwrap();
9797

98-
let eval_message =
99-
BaseMatcher::message(&format!(r"MyModule.hs:\d+:\d+: {}", regex::escape(cmd)));
98+
let eval_message = BaseMatcher::message(&format!(
99+
r"MyModule.hs:\d+:\d+: -- \$> {}",
100+
regex::escape(cmd)
101+
));
100102
session
101103
.wait_for_log(&eval_message)
102104
.await
@@ -177,7 +179,7 @@ async fn can_eval_commands_in_non_interpreted_modules() {
177179
BaseMatcher::message("All good!")
178180
// Evals the command.
179181
.and(BaseMatcher::message(
180-
r"MyModule.hs:\d+:\d+: example \+\+ example",
182+
r"MyModule.hs:\d+:\d+: -- \$> example \+\+ example",
181183
))
182184
// Reads eval output.
183185
.and(BaseMatcher::message("Read line").with_field("line", "exampleexample"))
@@ -220,7 +222,7 @@ async fn can_eval_commands_twice() {
220222
let ok_reload = BaseMatcher::message("All good!")
221223
// Evals the command.
222224
.and(BaseMatcher::message(
223-
r"MyModule.hs:\d+:\d+: example \+\+ example",
225+
r"MyModule.hs:\d+:\d+: -- \$> example \+\+ example",
224226
))
225227
// Reads eval output.
226228
.and(BaseMatcher::message("Read line").with_field("line", "exampleexample"))

0 commit comments

Comments
 (0)
Please sign in to comment.