Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ghci/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,6 @@ impl Ghci {
// restore the old value when the function returns.
for (path, commands) in self.eval_commands.clone() {
for command in commands {
tracing::info!("{path}:{command}");
// If the `module` was already compiled, `ghci` may have loaded the interface file instead
// of the interpreted bytecode, giving us this error message when we attempt to
// load the top-level scope with `:module + *{module}`:
Expand All @@ -574,8 +573,10 @@ impl Ghci {
// We use `:add *{module}` to force interpreting the module. We do this here instead of in
// `add_module` to save time if eval commands aren't used (or aren't needed for a
// particular module).
tracing::info!("Loading {path} in interpreted mode for eval commands");
self.interpret_module(&path, log).await?;
let module = self.search_paths.path_to_module(&path)?;
tracing::info!("Eval {path}:{command}");
self.stdin
.eval(&mut self.stdout, &module, &command.command, log)
.await?;
Expand Down
6 changes: 5 additions & 1 deletion src/ghci/parse/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ pub struct EvalCommand {

impl Display for EvalCommand {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}:{}: {}", self.line, self.column, self.display_command)
write!(
f,
"{}:{}: -- $> {}",
self.line, self.column, self.display_command
)
}
}

Expand Down
12 changes: 7 additions & 5 deletions tests/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async fn can_eval_commands() {
let defined_in_multiple_files =
BaseMatcher::message("Read stderr line").with_field("line", "defined in multiple files");

let eval_message = BaseMatcher::message(r"MyModule.hs:\d+:\d+: example \+\+ example")
let eval_message = BaseMatcher::message(r"MyModule.hs:\d+:\d+: -- \$> example \+\+ example")
.but_not(defined_in_multiple_files.clone());
session
.assert_logged_or_wait(eval_message.clone())
Expand Down Expand Up @@ -95,8 +95,10 @@ async fn can_load_new_eval_commands_multiline() {
.await
.unwrap();

let eval_message =
BaseMatcher::message(&format!(r"MyModule.hs:\d+:\d+: {}", regex::escape(cmd)));
let eval_message = BaseMatcher::message(&format!(
r"MyModule.hs:\d+:\d+: -- \$> {}",
regex::escape(cmd)
));
session
.wait_for_log(&eval_message)
.await
Expand Down Expand Up @@ -177,7 +179,7 @@ async fn can_eval_commands_in_non_interpreted_modules() {
BaseMatcher::message("All good!")
// Evals the command.
.and(BaseMatcher::message(
r"MyModule.hs:\d+:\d+: example \+\+ example",
r"MyModule.hs:\d+:\d+: -- \$> example \+\+ example",
))
// Reads eval output.
.and(BaseMatcher::message("Read line").with_field("line", "exampleexample"))
Expand Down Expand Up @@ -220,7 +222,7 @@ async fn can_eval_commands_twice() {
let ok_reload = BaseMatcher::message("All good!")
// Evals the command.
.and(BaseMatcher::message(
r"MyModule.hs:\d+:\d+: example \+\+ example",
r"MyModule.hs:\d+:\d+: -- \$> example \+\+ example",
))
// Reads eval output.
.and(BaseMatcher::message("Read line").with_field("line", "exampleexample"))
Expand Down