mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 05:53:59 +00:00
Simplify highlight tests by changing into dedicated test dir
This commit is contained in:
parent
29ebd4a5ff
commit
865abebd11
1 changed files with 10 additions and 17 deletions
|
@ -5058,9 +5058,11 @@ static void test_error_messages() {
|
||||||
|
|
||||||
static void test_highlighting() {
|
static void test_highlighting() {
|
||||||
say(L"Testing syntax highlighting");
|
say(L"Testing syntax highlighting");
|
||||||
if (system("mkdir -p test/fish_highlight_test/")) err(L"mkdir failed");
|
if (!pushd("test/fish_highlight_test/")) return;
|
||||||
if (system("touch test/fish_highlight_test/foo")) err(L"touch failed");
|
cleanup_t pop{[] { popd(); }};
|
||||||
if (system("touch test/fish_highlight_test/bar")) err(L"touch failed");
|
if (system("mkdir -p dir")) err(L"mkdir failed");
|
||||||
|
if (system("touch foo")) err(L"touch failed");
|
||||||
|
if (system("touch bar")) err(L"touch failed");
|
||||||
|
|
||||||
// Here are the components of our source and the colors we expect those to be.
|
// Here are the components of our source and the colors we expect those to be.
|
||||||
struct highlight_component_t {
|
struct highlight_component_t {
|
||||||
|
@ -5079,14 +5081,14 @@ static void test_highlighting() {
|
||||||
param_valid_path.valid_path = true;
|
param_valid_path.valid_path = true;
|
||||||
|
|
||||||
highlight_tests.push_back({{L"echo", highlight_role_t::command},
|
highlight_tests.push_back({{L"echo", highlight_role_t::command},
|
||||||
{L"test/fish_highlight_test/foo", param_valid_path},
|
{L"./foo", param_valid_path},
|
||||||
{L"&", highlight_role_t::statement_terminator}});
|
{L"&", highlight_role_t::statement_terminator}});
|
||||||
|
|
||||||
highlight_tests.push_back({
|
highlight_tests.push_back({
|
||||||
{L"command", highlight_role_t::keyword},
|
{L"command", highlight_role_t::keyword},
|
||||||
{L"echo", highlight_role_t::command},
|
{L"echo", highlight_role_t::command},
|
||||||
{L"abc", highlight_role_t::param},
|
{L"abc", highlight_role_t::param},
|
||||||
{L"test/fish_highlight_test/foo", param_valid_path},
|
{L"foo", param_valid_path},
|
||||||
{L"&", highlight_role_t::statement_terminator},
|
{L"&", highlight_role_t::statement_terminator},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -5105,12 +5107,12 @@ static void test_highlighting() {
|
||||||
// Verify that cd shows errors for non-directories.
|
// Verify that cd shows errors for non-directories.
|
||||||
highlight_tests.push_back({
|
highlight_tests.push_back({
|
||||||
{L"cd", highlight_role_t::command},
|
{L"cd", highlight_role_t::command},
|
||||||
{L"test/fish_highlight_test", param_valid_path},
|
{L"dir", param_valid_path},
|
||||||
});
|
});
|
||||||
|
|
||||||
highlight_tests.push_back({
|
highlight_tests.push_back({
|
||||||
{L"cd", highlight_role_t::command},
|
{L"cd", highlight_role_t::command},
|
||||||
{L"test/fish_highlight_test/foo", highlight_role_t::error},
|
{L"foo", highlight_role_t::error},
|
||||||
});
|
});
|
||||||
|
|
||||||
highlight_tests.push_back({
|
highlight_tests.push_back({
|
||||||
|
@ -5386,16 +5388,7 @@ static void test_highlighting() {
|
||||||
// Hackish space handling. We don't care about the colors in spaces.
|
// Hackish space handling. We don't care about the colors in spaces.
|
||||||
if (text.at(i) == L' ') continue;
|
if (text.at(i) == L' ') continue;
|
||||||
|
|
||||||
auto e = expected_colors.at(i);
|
if (expected_colors.at(i) != 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' ');
|
const wcstring spaces(i, L' ');
|
||||||
err(L"Wrong color in test at index %lu in text (expected %#x, actual "
|
err(L"Wrong color in test at index %lu in text (expected %#x, actual "
|
||||||
L"%#x):\n%ls\n%ls^",
|
L"%#x):\n%ls\n%ls^",
|
||||||
|
|
Loading…
Reference in a new issue