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

Busted Output (wip) #86

Closed

Conversation

Mathijs-Bakker
Copy link

@Mathijs-Bakker Mathijs-Bakker commented Mar 2, 2021

Yo! Here a draft... which is not perfect yet.
But maybe you could review it and see if I am on the right track.

Related issue: #73

Still have many things to address...

Like:

  • Show spec time,
  • Show total elapsed time in spec score,
  • Exit codes (only show one exit code at the end),
  • Prettying output,
  • Fetch last fixes from main repo,
  • ...

I am still a big noob at Lua, so constructive comments are welcome!

Current behavior/screens:

Headless:
Schermafbeelding 2021-03-02 om 10 39 25

Not headless:
Schermafbeelding 2021-03-02 om 10 38 36

@Conni2461
Copy link
Collaborator

Conni2461 commented Mar 2, 2021

Okay thats a lot of work. Good job. I will need to take a in depth look at this, this evening. One thing you can do, is update your description with a screenshot how it currently looks :)

Another thing we will probably do, after the conflicts are resolved, moves some files around:

lua/plenary/busted.lua -> lua/plenary/busted/init.lua
lua/plenary/busted_dots.lua -> lua/plenary/busted/dots.lua
lua/plenary/busted/reader.lua -> lua/plenary/busted/reader.lua

require'plenary.busted' will still work and load the init.lua file. I do everything else later today

@Mathijs-Bakker
Copy link
Author

Mathijs-Bakker commented Mar 2, 2021

I tried to respect current code and file structure. But yes... better to move them to it's own busted dir.
(btw... i added some screenies)

@Mathijs-Bakker
Copy link
Author

Note: Passing tests are still shown. But will be removed from visual output later. You can consider them redundant as you would typically show only the failing tests.

The output of: pending tests and errors, still need to be handled.

local trace = get_trace(nil, 3, msg)
return trace.message .. "\n" .. trace.traceback
-- return trace.message .. "\n" .. trace.traceback
return trace.message
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep the traceback

@kkharji
Copy link
Contributor

kkharji commented Mar 2, 2021

That looks really nice and clean @Mathijs-Bakker . I'd suggest to take out the path in front of Expected ... since it mentioned above it.

@Conni2461
Copy link
Collaborator

Conni2461 commented Mar 2, 2021

We can make the path relative with plenary.path

local new_path = Path:new(fullpath):make_relative()

I did look at the code and gave this a try. My 52 test file didn't run. So i am not sure if this works as expected. Would be great if you could point me to code that doesn't work.

Thats my output of the file i just ran:
image

Its one spec file but i get this multiple ENDOFSPEC things. Maybe that helps :) Also not all tests in plenary.nvim are running.

Edit: thats what is happening on master
image

@Mathijs-Bakker
Copy link
Author

Thanks, I will get into it.

@Conni2461
Copy link
Collaborator

I am sorry, i am really busy lately. I will do a productive review this evening :)

@Mathijs-Bakker
Copy link
Author

I am sorry, i am really busy lately. I will do a productive review this evening :)

Nothing new... I only synched with origin and solved a merge conflict.
When I pushed this to my own fork/branch this draft gets auto updated too.
(Fun fact: I was googling for a solution on 'how to update/push to a remote draft'. 🤣)
Gonna create a new branch to deviate from this one... So participants don't get notified on every push I do.

@Mathijs-Bakker
Copy link
Author

Mathijs-Bakker commented Mar 6, 2021

Ok, it's weekend, time to move on with this thing...

I need some advise on this:

For drawing the dots and score results, we need to count the 'fail', 'err', 'pending' and passed tests.

So we need to get the tests first.

The stdout of theJob in test_harness.lua spits everything out line-by-line. (output = vim.schedule_wrap(_, line, _, _))
That's why I choose to concat the lines and store them as tests in a table.

To identify a test and it's status:
The "{SPEC: FAIL}", "{SPEC: SUCC}", etc. are added into busted.lua.
So we can find an occurrence of the specific string in a line.

E.g:

if not ok then
     to_insert = results.fail
     test_result.msg = msg

     print(FAIL, "||", table.concat(test_result.descriptions, " "))
     print(indent(msg, 12))

     print("{SPEC: FAIL}")
     local spec = get_file_and_line_number()

     print(FAIL, "" .. color_string("cyan", spec.file) .. " @ " .. color_string("cyan", spec.linenumber) .. "\n")

     print(bold_string(table.concat(test_result.descriptions)))
     print(indent("\n" .. msg, 7))

     print("{ENDOFSPEC}")

It works, it's fast but it feels kind of hackie to me,
what do you think... maybe you know a better way?
@Conni2461

@Conni2461
Copy link
Collaborator

I need to think about this. I will answer you this evening or tomorrow morning :) Sorry that i am not really a help right now

print(HEADER)
print(HORIZONTALRULER)

os.exit(2)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be here

I am looking at the whole code now. Give me between 30 ~ 60 mins for an answer. I wanna play around with the code for a bit

Copy link
Collaborator

@Conni2461 Conni2461 Mar 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay i am trying to get nvim --headless --noplugin -u scripts/minimal.vim -c "PlenaryBustedFile tests/plenary/simple_busted_spec.lua" to work first. After that i am trying to deal with PlenaryBustedDirectory and test harness

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh i see what you doing. I am not sure if i like it i kinda wanna keep the current way of starting a test, with just executing busted itself. We not always wanna go thought test_harness

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's exactly the reason for reaching out.
I don't like it either.
I'm afk for +/- 2 hours. So will respond later.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is what i think we could do. When executing the file with PlenaryBustedFile we have basically the same output, a little bit cleaned up and for Directory we can then get the SUCCESS, FAILURE and PENDING outputs and count them and also convert them to dots.

For stacktrace and error, the line always starts with a and those always come after a FAILURE so, if we read failure we go in another state that captures all further lines that start with and memorizes them for later output. And on exit we just draw it. Colored dots, Failures and summarize. We also can have simple_busted print the summarize and just realize that its a summarize and capture it that way.

If you wanna have a more detailed talk, you can write me on gitter in private.

Comment on lines +11 to +12
local end_index = info.traceback:find(': in')
info.traceback = info.traceback:sub(start_index, end_index)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are subbing away here, only busted traceback?


print(FAIL, " → " .. color_string("cyan", spec.file) .. " @ " .. color_string("cyan", spec.linenumber) .. "\n")

print(bold_string(table.concat(test_result.descriptions)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing " " for concat

@tjdevries
Copy link
Member

@Mathijs-Bakker do you still want to continue on this PR? I'm trying to help out w/ some of these :)

@Mathijs-Bakker
Copy link
Author

@tjdevries Yes definitely! I'm feeling bad for @Conni2461 that I didn't respond earlier...
There's another project that that needed my attention first.
Priorities...
It will take a few days before I am able to get back into this.
And any help from the man himself will be welcome! X)
Cheers!

@Mathijs-Bakker
Copy link
Author

@Mathijs-Bakker do you still want to continue on this PR? I'm trying to help out w/ some of these :)
K, I'm getting back into it this tomorrow/weekend.

@Conni2461
Copy link
Collaborator

I took a break too from maintaining this project 😆

If the man himself didnt help, maybe i pick this up soon :)

@Conni2461
Copy link
Collaborator

Ill close this PR as abandoned. Ill probably fix this issue but i start from scratch.

Still thanks for looking into it and if you still work on it you can just reopen :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants