-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This fixes a "modules defined in multiple files" bug when a module is renamed. The rename is interpreted as one module being deleted (which triggers a restart) and one module being added (which triggers an `:add`). The bug is that it would restart `ghci`, thereby loading the new module, and then attempt to `:add` the new module anyways, which would fail.
- Loading branch information
Showing
4 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use test_harness::fs; | ||
use test_harness::test; | ||
use test_harness::GhcidNg; | ||
use test_harness::Matcher; | ||
|
||
/// Test that `ghcid-ng` can restart correctly when modules are removed and added (i.e., renamed) | ||
/// at the same time. | ||
#[test] | ||
async fn can_compile_renamed_module() { | ||
let mut session = GhcidNg::new("tests/data/simple") | ||
.await | ||
.expect("ghcid-ng starts"); | ||
session | ||
.wait_until_ready() | ||
.await | ||
.expect("ghcid-ng loads ghci"); | ||
|
||
let module_path = session.path("src/MyModule.hs"); | ||
let new_module_path = session.path("src/MyCoolModule.hs"); | ||
fs::rename(&module_path, &new_module_path).await.unwrap(); | ||
|
||
session | ||
.wait_until_restart() | ||
.await | ||
.expect("ghcid-ng restarts on module move"); | ||
|
||
session | ||
.assert_logged(Matcher::message("Compilation failed").in_span("reload")) | ||
.await | ||
.unwrap(); | ||
|
||
fs::replace(new_module_path, "module MyModule", "module MyCoolModule") | ||
.await | ||
.unwrap(); | ||
|
||
session | ||
.wait_until_reload() | ||
.await | ||
.expect("ghcid-ng reloads on module change"); | ||
|
||
session | ||
.assert_logged(Matcher::message("Compilation succeeded").in_span("reload")) | ||
.await | ||
.unwrap(); | ||
} |