Skip to content

Commit

Permalink
Add a regression test
Browse files Browse the repository at this point in the history
This should help keep at least the "starting with failed modules" source
of the "module defined in multiple files" bug gone.
  • Loading branch information
9999years committed Sep 11, 2023
1 parent a57400c commit 47f1f24
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions ghcid-ng/tests/failed_modules.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use test_harness::fs;
use test_harness::test;
use test_harness::GhcidNgBuilder;

/// Test that `ghcid-ng` can start with compile errors.
///
/// This is a regression test for [#43](https://github.com/MercuryTechnologies/ghcid-ng/issues/43).
#[test]
async fn can_start_with_failed_modules() {
let module_path = "src/MyModule.hs";
let mut session = GhcidNgBuilder::new("tests/data/simple")
.before_start(move |path| async move {
fs::replace(path.join(module_path), "example :: String", "example :: ()").await
})
.start()
.await
.expect("ghcid-ng starts");
let module_path = session.path(module_path);

session
.get_log("Compilation failed")
.await
.expect("ghcid-ng fails to load with errors");

session.wait_until_ready().await.expect("ghcid-ng loads");

fs::replace(&module_path, "example :: ()", "example :: String")
.await
.unwrap();

session
.get_log("Compilation succeeded")
.await
.expect("ghcid-ng reloads fixed modules");
}

0 comments on commit 47f1f24

Please sign in to comment.