Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too long filenames cause test failure #57

Open
juntuu opened this issue Apr 8, 2020 · 1 comment
Open

Too long filenames cause test failure #57

juntuu opened this issue Apr 8, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@juntuu
Copy link

juntuu commented Apr 8, 2020

Description

This demonstrates failure mode of some tests, where the temporary directory path generated by pytest is too long to fully fit into the header. (encountered on MacOS)

This leads to the assertions on the visible contents to fail. For example: looking for the modified indicator ' *', or exact match on the filename or particular part of it.

Example breaking test

from testing.runner import and_exit

def test_failing_too_long_filename(run, tmpdir):
    path = str(tmpdir.join('file' * 20 + '.txt'))
    assert len(path) > 80
    with run(path) as h, and_exit(h):
        h.press('a')
        h.await_text(' *')

The top of the resulting screen:

===============================================================================
 babi v0.0.7 lefilefilefilefilefilefilefilefilefilefilefilefilefilefilefilefilef
a

Possible solution

The filename should probably be truncated in a consistent manner, without hiding the indicator or other such information.

This is also what nano does:

  GNU nano 2.0.6 File: ...filefilefilefilefilefile.txt Modified

a

Currently failing tests

Running with pytest tests/ -k fake:

=============================================== short test summary info ===============================================
FAILED tests/features/cut_uncut_test.py::test_cut_and_uncut[fake] - AssertionError: expected: ' *'
FAILED tests/features/cut_uncut_test.py::test_selection_cut_uncut[fake] - AssertionError: expected: ' *'
FAILED tests/features/cut_uncut_test.py::test_selection_cut_uncut_backwards_select[fake] - AssertionError: expected:...
FAILED tests/features/cut_uncut_test.py::test_selection_cut_uncut_within_line[fake] - AssertionError: expected: ' *'
FAILED tests/features/multiple_files_test.py::test_multiple_files[fake] - AssertionError: expected: 'file_a'
FAILED tests/features/multiple_files_test.py::test_multiple_files_close_from_beginning[fake] - AssertionError: expec...
FAILED tests/features/multiple_files_test.py::test_multiple_files_close_from_end[fake] - AssertionError: expected: '...
FAILED tests/features/replace_test.py::test_replace_actual_contents[fake] - AssertionError: expected: ' *'
FAILED tests/features/save_test.py::test_mixed_newlines[fake] - AssertionError: expected: 'f *'
FAILED tests/features/save_test.py::test_modify_file_with_windows_newlines[fake] - AssertionError: expected: '*'
FAILED tests/features/save_test.py::test_saving_file_with_multiple_lines_at_end_maintains_those[fake] - AssertionErr...
FAILED tests/features/save_test.py::test_not_a_file[fake] - AssertionError: expected: "d' is not a file"
FAILED tests/features/save_test.py::test_save_on_exit[fake] - AssertionError: expected: 'enter filename: /private/va...
FAILED tests/features/text_editing_test.py::test_backspace_joins_lines[fake] - AssertionError: expected: 'f *'
FAILED tests/features/text_editing_test.py::test_backspace_deletes_text[fake-BSpace] - AssertionError: expected: 'f *'
FAILED tests/features/text_editing_test.py::test_backspace_deletes_text[fake-^H] - AssertionError: expected: 'f *'
FAILED tests/features/text_editing_test.py::test_delete_removes_character_afterwards[fake] - AssertionError: expecte...
FAILED tests/features/text_editing_test.py::test_delete_at_end_of_line[fake] - AssertionError: expected: 'f *'
FAILED tests/features/text_editing_test.py::test_press_enter_beginning_of_file[fake] - AssertionError: expected: 'f *'
FAILED tests/features/undo_redo_test.py::test_undo_redo_mixed_newlines[fake] - AssertionError: expected: ' *'
FAILED tests/features/undo_redo_test.py::test_undo_redo_with_save[fake] - AssertionError: expected: ' *'
@asottile
Copy link
Owner

asottile commented Apr 8, 2020

yeah this is especially prevalent on macos where the temporary directory is some wildly deep thing by default.

I wanted to fix this with a "smart" truncation but hadn't found time to implement an algorithm for it, something which partially preserves the folder names similar to what you'd see in a sparkline

that said, fixing this wasn't very high priority since it rarely appears in normal usage (usually you're not passing fully qualified paths to a text editor) and was mostly only impacting the tests

@asottile asottile added the bug Something isn't working label Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants