+5
CHANGELOG.md
+5
CHANGELOG.md
-12
src/birdie.gleam
-12
src/birdie.gleam
···
465
465
<> "I couldn't locate the project's root where the snapshot's"
466
466
<> " folder should be."
467
467
468
-
CannotGetTitles(titles.TestModuleIsNotCompiling(file: file)) ->
469
-
"The test file "
470
-
<> ansi.italic("\"" <> file <> "\"\n")
471
-
<> " is not compiling.\n"
472
-
<> "All your test should be compiling for Birdie to work!"
473
-
474
468
CannotGetTitles(titles.CannotReadTestDirectory(reason: reason)) ->
475
469
heading(reason) <> "I couldn't list the contents of the test folder."
476
470
···
478
472
heading(reason)
479
473
<> "I couldn't read the test file "
480
474
<> ansi.italic("\"" <> file <> "\"\n")
481
-
482
-
CannotGetTitles(titles.ParseError(reason: _reason)) ->
483
-
"I couldn't parse the content of your test modules.\n"
484
-
<> "This most likely is a bug in Birdie, it would be grand if you could"
485
-
<> "open an issue on GitHub:\n"
486
-
<> "\"https://github.com/giacomocavalieri/birdie/issues\""
487
475
488
476
CannotGetTitles(titles.DuplicateLiteralTitles(
489
477
title: title,
+4
-16
src/birdie/internal/titles.gleam
+4
-16
src/birdie/internal/titles.gleam
···
42
42
///
43
43
pub type Error {
44
44
CannotFindProjectRoot(reason: simplifile.FileError)
45
-
TestModuleIsNotCompiling(file: String)
46
45
CannotReadTestDirectory(reason: simplifile.FileError)
47
46
CannotReadTestFile(reason: simplifile.FileError, file: String)
48
-
ParseError(reason: glance.Error)
49
47
DuplicateLiteralTitles(title: String, one: TestInfo, other: TestInfo)
50
48
OverlappingPrefixes(
51
49
prefix: String,
···
134
132
use <- bool.guard(when: !is_gleam_file, return: Ok(titles))
135
133
136
134
use raw_module <- try(simplifile.read(file), CannotReadTestFile(_, file))
137
-
let compile_module = glance.module(raw_module)
138
-
use module <- try_replace(compile_module, TestModuleIsNotCompiling(file))
139
-
from_module(titles, file, module)
135
+
case glance.module(raw_module) {
136
+
Ok(module) -> from_module(titles, file, module)
137
+
Error(_) -> Ok(titles)
138
+
}
140
139
}
141
140
142
141
pub fn from_module(
···
508
507
Error(e) -> Error(map_error(e))
509
508
}
510
509
}
511
-
512
-
fn try_replace(
513
-
result: Result(a, b),
514
-
replace_error: c,
515
-
fun: fn(a) -> Result(d, c),
516
-
) -> Result(d, c) {
517
-
case result {
518
-
Ok(a) -> fun(a)
519
-
Error(_) -> Error(replace_error)
520
-
}
521
-
}