jacobmendoza / rspec-tree-runner

RSpec runner and files analyzer for Atom editor
https://atom.io/packages/rspec-tree-runner
MIT License
9 stars 2 forks source link

Uncaught SyntaxError: Unexpected token A #4

Closed brand-it closed 7 years ago

brand-it commented 9 years ago

I just ran ctr+alt+x and it failed. I got nothig more then that.

Atom Version: 0.207.0 System: Mac OS X 10.10.3 Thrown From: rspec-tree-runner package, v0.1.1

Stack Trace

Uncaught SyntaxError: Unexpected token A

At file:///Applications/Atom.app/Contents/Resources/app.asar/static/index.html#%7B%22locationsToOpen%22%3A%5B%7B%22pathToOpen%22%3A%22%2FUsers%2Fnewdark%2Fapps%2Fruby%2Fgscs_deploy%22%7D%5D%2C%22bootstrapScript%22%3A%22%2FApplications%2FAtom.app%2FContents%2FResources%2Fapp.asar%2Fsrc%2Fwindow-bootstrap.js%22%2C%22resourcePath%22%3A%22%2FApplications%2FAtom.app%2FContents%2FResources%2Fapp.asar%22%2C%22devMode%22%3Afalse%2C%22safeMode%22%3Afalse%2C%22includeDeprecatedAPIs%22%3Afalse%2C%22profileStartup%22%3Afalse%2C%22appVersion%22%3A%220.207.0%22%2C%22initialPaths%22%3A%5B%22%2FUsers%2Fnewdark%2Fapps%2Fruby%2Fgscs_deploy%22%5D%7D:1

SyntaxError: Unexpected token A
  at Object.parse (native)
  at RSpecLauncherCommand.module.exports.RSpecLauncherCommand.parseRSpecResult (/Users/newdark/.atom/packages/rspec-tree-runner/lib/rspec-launcher-command.coffee:25:57)
  at /Users/newdark/.atom/packages/rspec-tree-runner/lib/rspec-launcher-command.coffee:17:54
  at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:82:11)
  at TerminalCommandRunner.module.exports.TerminalCommandRunner.onClose (/Users/newdark/.atom/packages/rspec-tree-runner/lib/terminal-command-runner.coffee:47:14)
  at ChildProcess.<anonymous> (/Users/newdark/.atom/packages/rspec-tree-runner/lib/terminal-command-runner.coffee:1:1)
  at emitTwo (events.js:87:13)
  at ChildProcess.emit (events.js:169:7)
  at maybeClose (child_process.js:997:16)
  at Socket.<anonymous> (child_process.js:1166:11)
  at emitOne (events.js:77:13)
  at Socket.emit (events.js:166:7)
  at Pipe.close (net.js:464:12)

Commands

     -2:02.0 editor:consolidate-selections (atom-text-editor.editor.is-focused)
     -2:02.0 core:cancel (atom-text-editor.editor.is-focused)
     -2:01.1.0 core:close (atom-text-editor.editor.is-focused)
     -2:00.7.0 editor:consolidate-selections (atom-text-editor.editor.is-focused)
     -2:00.7.0 core:cancel (atom-text-editor.editor.is-focused)
  5x -1:55.2.0 pane:show-next-item (atom-text-editor.editor.is-focused)
 16x -1:51 core:close (atom-text-editor.editor.is-focused)
     -1:38.6.0 editor:scroll-to-cursor (atom-text-editor.editor.is-focused)
  4x -1:35.8.0 key-binding-resolver:toggle (atom-text-editor.editor.is-focused)
     -1:26.1.0 rspec-tree-runner:run-tests (atom-text-editor.editor.is-focused)
     -0:19.6.0 editor:consolidate-selections (atom-text-editor.editor.is-focused)
     -0:19.6.0 core:cancel (atom-text-editor.editor.is-focused)
     -0:14.6.0 editor:consolidate-selections (atom-text-editor.editor.is-focused)
     -0:14.6.0 core:cancel (atom-text-editor.editor.is-focused)
     -0:14.2.0 core:close (atom-text-editor.editor.is-focused)
     -0:05.1.0 rspec-tree-runner:run-tests (atom-text-editor.editor.is-focused)

Config

{
  "core": {
    "disabledPackages": [
      "atom-lint"
    ],
    "themes": [
      "one-light-ui",
      "railscast-theme"
    ]
  },
  "rspec-tree-runner": {}
}

Installed Packages

# User
color-picker, v2.0.4
language-haml, v0.21.0
language-ruby, v0.56.0
language-salt, v0.4.0
linter, v0.12.6
linter-erb, v0.1.1
linter-jshint, v0.1.6
linter-rubocop, v0.2.7
linter-ruby, v0.1.6
pretty-json, v0.3.3
railscast-theme, v0.3.0
rspec-tree-runner, v0.1.1

# Dev
No dev packages
jacobmendoza commented 9 years ago

Hi!

Thank you very much for reporting!. I would say that this is happening because the package is not able to interpret the RSpec output. Obviously, something is happening because errors are not supposed to be communicated like that.

The package does two things when running a test file (ctrl+alt+x), changing to the project directory and then running RSpec to get the results (in JSON format). Something is happening with this result, that can't be correctly parsed.

Please, can you run RSpec inside your project and post here the relevant part of the result?. Should be similar to:

  1. Open a terminal
  2. cd project_directoy
  3. rspec --format=json spec/file_that_failed_spec.rb

Thanks a lot!

dennis-best commented 9 years ago

Running from the command line works fine on a dummy test

{"messages":["Run options: include {:focus=\u003etrue}","\nAll examples were filtered out; ignoring {:focus=\u003etrue}","No examples found."],"examples":[],"summary":{"duration":0.09842,"example_count":0,"failure_count":0,"pending_count":0},"summary_line":"0 examples, 0 failures"}
require 'rails_helper'
RSpec.describe SiloStatusesController, type: :controller do
  describe "GET #index" do
    puts 'foo'
  end
end
brand-it commented 9 years ago

This is what I got running the command you send me.

13:18:28 (master) ~/apps/ruby/quote_management_fork$ rspec --format=json spec/models/comment_spec.rb

Elastic Search is running with status yellow
To run without elastic search run rspec with environment variable SKIP_ELASTIC eg. 'SKIP_ELASTIC=true rspec spec/model/some_spec.rb'
Set environment variable DEBUG for more info.
{"messages":["Run options: exclude {:broken=\u003etrue}","\nAll examples were filtered out"],"examples":[],"summary":{"duration":0.098698,"example_count":0,"failure_count":0,"pending_count":0},"summary_line":"0 examples, 0 failures"}Coverage report generated for RSpec to /Users/bran0899/apps/ruby/quote_management_fork/coverage. 645 / 1382 LOC (46.67%) covered.
jacobmendoza commented 9 years ago

Hi @newdark and @dennis-best!

I'm really sorry that it took so long. Just released a new version that includes a new feature (run only one test by @jmorais) and also a fix for the problem that you both were having (hopefully).

I've realised that sometimes the output returns some characters unescaped, when they should be escaped for a JSON parsing. I don't have all the information and I don't really know the reason for that. Anyway, are characters that shouldn't be useful when parsing so I'm removing them now.

Commit: ee09a416f3f5c6691748766885c381ef7ca1fc6c

It would be great to have your feedback if you can download the new version.

Thanks a lot!

brand-it commented 9 years ago

@jacobmendoza how do I get the fix on atom?

jacobmendoza commented 9 years ago

Hi @newdark,

I don't know if I understood you correctly, but getting the fix it's only an update inside Atom.

Go to Preferences (Atom > Preferences). There's a menu in the left with several options, one of them "Updates". One of the outdated packages should be rspec-tree-runner. Just clicking the update button should do the trick.

I really hope that it works. Please, let me know the result. If it doesn't work, I'll keep investigating.

brand-it commented 9 years ago

@jacobmendoza Looks like the error is still handing around. Sorry no fix :(

screen shot 2015-09-11 at 3 10 49 pm
brand-it commented 9 years ago

Ran the command in terminal. Running version 0.2.0 of rspec-tree-runner

15:12:05 (master) ~/apps/ruby/quote_management_client$ rspec --format=json spec/lib/quote_management_client/better_exceptions_spec.rb
{"examples":[{"description":"BadRequest for 400","full_description":"BetterExceptions#error_class BadRequest for 400","status":"passed","file_path":"./spec/lib/quote_management_client/better_exceptions_spec.rb","line_number":6},{"description":"NotFound for 404","full_description":"BetterExceptions#error_class NotFound for 404","status":"passed","file_path":"./spec/lib/quote_management_client/better_exceptions_spec.rb","line_number":10},{"description":"RequestTimeout for 408","full_description":"BetterExceptions#error_class RequestTimeout for 408","status":"passed","file_path":"./spec/lib/quote_management_client/better_exceptions_spec.rb","line_number":24},{"description":"InternalServerError for 500","full_description":"BetterExceptions#error_class InternalServerError for 500","status":"passed","file_path":"./spec/lib/quote_management_client/better_exceptions_spec.rb","line_number":28},{"description":"ServiceUnavailable for 503","full_description":"BetterExceptions#error_class ServiceUnavailable for 503","status":"passed","file_path":"./spec/lib/quote_management_client/better_exceptions_spec.rb","line_number":32},{"description":"for 401","full_description":"BetterExceptions#error_class Unauthorized for 401","status":"passed","file_path":"./spec/lib/quote_management_client/better_exceptions_spec.rb","line_number":15},{"description":"for 403","full_description":"BetterExceptions#error_class Unauthorized for 403","status":"passed","file_path":"./spec/lib/quote_management_client/better_exceptions_spec.rb","line_number":19}],"summary":{"duration":0.001408,"example_count":7,"failure_count":0,"pending_count":0},"summary_line":"7 examples, 0 failures"}Coverage report generated for RSpec to /Users/bran0899/apps/ruby/quote_management_client/coverage. 724 / 926 LOC (78.19%) covered.
jacobmendoza commented 9 years ago

Hey @newdark,

Thanks for your help. It's very strange, I think it's possible that we are missing something.

Basically, my way to test this is take the output that your rspec generates and that you pasted me, and force the package to parse that output to see if everything is ok. In this case, is parsing it without problems. It's strange that doesn't work for you.

Please, if you can, I'd like to:

Really, thanks for your help with the issue :).

brand-it commented 9 years ago

Yes it is strange I will see about getting you better results and finding out exactly what is happening in debug mode.

jacobmendoza commented 8 years ago

Hey @newdark and @dennis-best,

I have just released a new version that is supposed to deal with some of the problems when reading the output of the RSpec runner. Can you guys give it a go if you have time and let me know how it goes?.

Thank you so much!

brand-it commented 8 years ago

@jacobmendoza Sure I will be happy to take a look at it for you. Also thanks for trying to fix this bug. :+1:

jacobmendoza commented 7 years ago

Hey @newdark, @dennis-best,

I've released a new version. You'd need to get manually the update as it has breaking changes. Would love to hear feedback, a few things changed.

Closing this issue as they code has changed quite a lot and probably it does not apply anymore.