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

QuietQuality gets upset if rspec returns something other than JSON #86

Closed
cdimartino opened this issue Jun 1, 2023 · 4 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@cdimartino
Copy link
Collaborator

When QQ runs the default rspec config, it may have other plugins outputting that interfere with the parsing of the JSON output:

❯ qq
#<Thread:0x0000000118914b28 /Users/cdimartino/.rvm/gems/ruby-3.1.2/gems/quiet_quality-1.0.3/lib/quiet_quality/executors/concurrent_executor.rb:13 run> terminated with exception (report_on_exception is true):
/Users/cdimartino/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/json-2.6.2/lib/json/common.rb:216:in `parse': 859: unexpected token at 'Coverage report generated for RSpec to /Users/cdimartino/source/******/coverage. 195 / 2488 LOC (7.84%) covered. (JSON::ParserError)
'
	from /Users/cdimartino/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/json-2.6.2/lib/json/common.rb:216:in `parse'
	from /Users/cdimartino/.rvm/gems/ruby-3.1.2@noti/gems/quiet_quality-1.0.3/lib/quiet_quality/tools/rspec/parser.rb:20:in `content'
@nevinera nevinera added the bug Something isn't working label Jun 1, 2023
@nevinera
Copy link
Owner

nevinera commented Jun 1, 2023

I've had trouble with the rspec output a few times, but I hadn't seen this situation - I guess simplecov is writing using puts to write logging-type output to stdout.

This is awkward to deal with - we can work around it by writing the output to a file and reading the file, but rspec's runner would need to stop inheriting from BaseRunner to do that well, and the block forms of managing temporary files/directories are painful to use in memoized-immutable-style objects like the current runners :-\

I sure with people would write their logging output to the right stream..

@nevinera
Copy link
Owner

nevinera commented Jun 1, 2023

The smaller change we can make is to be more accomodating in the parser - if we assume rspec might come with arbitrary junk on the front, it might be possible to detect when the real json starts and only parse that?

@nevinera
Copy link
Owner

nevinera commented Jun 1, 2023

Ugh, it's on the end, and doesn't even include a newline:

"QuietQuality::Tools::MarkdownLint::Parser#messages when there are no offenses is expected to be empty","status":"passed","file_path":"./spec/quiet_quality/tools/markdown_lint/parser_spec.rb","line_number":16,"run_time":9.5e-05,"pending_message":null}],"summary":{"duration":0.79184,"example_count":708,"failure_count":0,"pending_count":0,"errors_outside_of_examples_count":0},"summary_line":"708 examples, 0 failures"}Coverage report generated for RSpec to /Users/emueller/src/quiet_quality/coverage. 1032 / 1032 LOC (100.0%) covered.

I do think the problem here is with simplecov, but obviously tons of people use that. Though I think the standard approach is to enable it controlled with an environment variable (so you don't get failures and coverage reports when you run a single spec file)..

I think I see a solution using a regex in the parser though, I'm going to pursue that.

@nevinera nevinera self-assigned this Jun 4, 2023
@nevinera
Copy link
Owner

nevinera commented Jun 4, 2023

Resolved by #91 in 1.2.2

@nevinera nevinera closed this as completed Jun 4, 2023
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