connorshea / vscode-ruby-test-adapter

A Ruby test adapter extension for the VS Code Test Explorer
https://marketplace.visualstudio.com/items?itemName=connorshea.vscode-ruby-test-adapter
MIT License
84 stars 50 forks source link

Can't get it to work :( #12

Closed gee-forr closed 5 years ago

gee-forr commented 5 years ago

Hi @connorshea

Firstly - thank you so much for building a test explorer for Ruby. I had given up hope of finding one for VSCode, and then got wind of yours. 1000.times { puts "THANK YOU!!!" }

Only problem is, I can't seem to get it to work...

When I first installed it, I got errors about something being out of bounds. Can't 100% remember, as they don't display anymore after restarting vscode.

What happens now, on any rspec tested project is that the test explorer refresh spinner just spins infinitely, and nothing loads.

My versions are:

I'm using Fish as my shell, and asdf as my ruby version manager.

Please let me know if I can give you any further debug data... I would love to start using this.

connorshea commented 5 years ago

Thanks, and sorry it isn’t working!

Can you share the specific error message? What’s your Ruby version and OS? Is the project particularly large?

I actually had the same problem yesterday after updating VS Code and it fixed itself after I restarted VS Code so I assumed it was a fluke.

gee-forr commented 5 years ago

Howdy,

OK, so I'm on macOS 10.14.5, and it's happening on all the different versions of ruby I'm using. from 2.3.x to 2.5.x

I can't see the error message anymore as it's not triggering - all the happens now is that the spinner spins indefinitely.

connorshea commented 5 years ago

Oh also, what version of RSpec does your project use? I’ve had problems with versions below 3.6.0.

The easiest way to debug it would be to run the RSpec command the extension uses to load the tests. It uses a custom RSpec formatter so you’ll need to figure out where the extension files are on your file system. The command should be something like bundle exec rspec --dry-run --require ~/.vscode/extensions/connorshea.vscode-ruby-test-adapter/custom_formatter.rb --format CustomFormatter.

You’ll probably need to modify the path to custom_formatter.rb since I’m going off memory and I’m not 100% sure that’ll be where it is.

If that command fails with an error that’d explain our problem, if not I’ll need to look into it more.

gee-forr commented 5 years ago

So, that seems to work... There are some project that emit a bunch of other stuff like deprecation warnings, or do stupid things like puts in a test, but I've mailed you an example of a clean project that's not working...

Re: rspec versions, different versions in 3.x range.

connorshea commented 5 years ago

The output definitely looks fine, and you're on version 3.6.0 so I don't think that should be a problem.

One workaround might be to downgrade the extension to a version before I introduced the custom formatter to see if that fixes the problem, so downgrading to 0.3.3. You can downgrade it by going to the extensions list, right-clicking the extension, then "Install Another Version...". It's not an ideal fix since you'd be losing live-updating test statuses, but if you want to get it working ASAP that might be a possibility.

Once I'm done with work in ~8 hours I can try releasing a new version that will have a toggle for printing debug info to the console so we can get more info about what's happening.

Also, if you go to Help > Toggle Developer Tools and look in the console do you see anything that looks related?

gee-forr commented 5 years ago

Ah... OK, so weirdly, downgrading doesn't work for me either... I've gone back to 0.4.2 and here's the exception being thrown in the console:

/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3205 SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at RspecTests.<anonymous> (/Users/gabrielf/.vscode/extensions/connorshea.vscode-ruby-test-adapter-0.4.2/out/rspecTests.js:107)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/gabrielf/.vscode/extensions/connorshea.vscode-ruby-test-adapter-0.4.2/node_modules/tslib/tslib.js:104)
$onExtensionRuntimeError @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3205
gee-forr commented 5 years ago

I took the JSON from the custom formatter, and it's definitely valid... so I don't think that's the problem... perhaps it's a stream buffer issue?

connorshea commented 5 years ago

That narrows it down a lot, so it's definitely something about the JSON being output.

It could definitely be a stream buffer problem. I wonder if one of your tests is outputting a linebreak in the middle of the JSON 🤔

Right now it uses a bit of a hack where the console output is parsed per-line and if the JSON gets split onto multiple lines that'd break it since it's not smart enough to put multiple lines together.

gee-forr commented 5 years ago

Nope - the json is definitely being output as just one line :)

I've written a custom rspec formatter before to try and get something working for the now-abandoned Tester for Atom... so if you need any assistance on the custom formatter, I can totally help there... TypeScript... not so much :)

connorshea commented 5 years ago

I just packaged a new version of the extension which will print to the console with the string it's attempting to parse as JSON, it should say JSON: string-being-parsed-here.

You can download it with Firefox Send (unfortunately GitHub doesn't let me upload vsix files, and I think you need Firefox to do the download?) and then load it into Code from the command line with code --install-extension=path/to/extension.vsix. I changed the extension version to v0.5.0 to help you make sure that it's installed.

The loading function actually works differently than the functions for parsing the output when the tests are actually run, I forgot I hadn't changed it yet. It just looks at all the output - regardless of linebreaks - and finds the first and last curly braces, then assumes everything in between is the JSON. If your tests output any other braces (the braces inside the JSON are fine as long as they're balanced), it'll break. I suspect this is what's happening and this should help confirm it.

If that is the problem then I can release a new version tonight that checks for START_OF_RSPEC_JSON and END_OF_RSPEC_JSON respectively, to prevent catching bad output.

connorshea commented 5 years ago

Oh, and if the output is too long it might say something like “can’t output to remote console, object is too big”, but based on what you sent me the test suite JSON probably shouldn’t be big enough to cause the problem.

connorshea commented 5 years ago

Alright, I've just released v0.4.3 that hopefully fixes this issue:

Please tell me if it works now :)

gee-forr commented 5 years ago

hey @connorshea - thanks for this - 0.4.3 is still unfortunately breaking - with the exact same error. I'm going to run 0.5.0 from ffx send, and will give let you know if that show's anything interesting.

connorshea commented 5 years ago

Did you get a chance to try the custom package?

I was hoping 0.4.3 would fix the problem :( I don’t know what else it’d be 🤔

One other thing maybe worth trying would be checking out if a newer version of RSpec fixes the problem.

gee-forr commented 5 years ago

I've now had a chance to test it out with 0.5.0, and the debug line that outputs the JSON to be parse is this:

[Extension Host]: JSON:

meaning, it's not getting any json at all. I'm using rspec 3.8, so it's not the rspec version...

I suspect it might have something to do with my shell, and my ruby version manager. I'm using fish as my shell, and asdf as my ruby version manager.

What are you using?

gee-forr commented 5 years ago

Hey - good news.... I removed all of the Test Explorer* plugins, reinstalled everything, up to 0.4.3 and it's working now. I have no idea why. I'm just so happy it's working.

This extension is amazing!!!!!!!!!! Thank you so much for it!

connorshea commented 5 years ago

tenor

Computers are amazing.

Glad to hear it's fixed and I'm happy it's useful to you! 🎉