mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
tests: Don't break when a file unexpectedly exists
Creating a file called "xfoo" could break the highlight tests because we'd suddenly get a color with valid_path set to true. So what we do is simply compare foreground/background and forced underline, but only check for path validity if we're expecting a valid path. If we're not expecting a valid path, we don't fail whether it is there or not. This means that we can't check for a non-valid path, but we don't currently do that anyway and we can just burn that bridge when we get to it. cc @siteshwar @krobelus, who both came across this
This commit is contained in:
parent
3c3bf7ffd7
commit
29ebd4a5ff
1 changed files with 10 additions and 1 deletions
|
@ -5386,7 +5386,16 @@ static void test_highlighting() {
|
|||
// Hackish space handling. We don't care about the colors in spaces.
|
||||
if (text.at(i) == L' ') continue;
|
||||
|
||||
if (expected_colors.at(i) != colors.at(i)) {
|
||||
auto e = expected_colors.at(i);
|
||||
auto c = colors.at(i);
|
||||
// Compare the colors, but don't care about pathness
|
||||
// unless we're asking for a valid path.
|
||||
//
|
||||
// That way stray files in the build directory don't break the test.
|
||||
if (e.foreground != c.foreground
|
||||
|| e.background != c.background
|
||||
|| e.force_underline != c.force_underline
|
||||
|| (e.valid_path && !c.valid_path)) {
|
||||
const wcstring spaces(i, L' ');
|
||||
err(L"Wrong color in test at index %lu in text (expected %#x, actual "
|
||||
L"%#x):\n%ls\n%ls^",
|
||||
|
|
Loading…
Reference in a new issue