mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 23:48:05 +03:00
Re-throw package activation exceptions in test mode
This commit is contained in:
parent
e4a218ff45
commit
a57b627a58
@ -546,8 +546,9 @@ describe "PackageManager", ->
|
||||
waitsFor -> activatedPackage?
|
||||
runs -> expect(activatedPackage.name).toBe 'package-with-main'
|
||||
|
||||
describe "when the package throws an error while loading", ->
|
||||
describe "when the package's main module throws an error on load", ->
|
||||
it "adds a notification instead of throwing an exception", ->
|
||||
spyOn(atom, 'inSpecMode').andReturn(false)
|
||||
atom.config.set("core.disabledPackages", [])
|
||||
addErrorHandler = jasmine.createSpy()
|
||||
atom.notifications.onDidAddNotification(addErrorHandler)
|
||||
@ -556,6 +557,11 @@ describe "PackageManager", ->
|
||||
expect(addErrorHandler.argsForCall[0][0].message).toContain("Failed to load the package-that-throws-an-exception package")
|
||||
expect(addErrorHandler.argsForCall[0][0].options.packageName).toEqual "package-that-throws-an-exception"
|
||||
|
||||
it "re-throws the exception in test mode", ->
|
||||
atom.config.set("core.disabledPackages", [])
|
||||
addErrorHandler = jasmine.createSpy()
|
||||
expect(-> atom.packages.activatePackage("package-that-throws-an-exception")).toThrow("This package throws an exception")
|
||||
|
||||
describe "when the package is not found", ->
|
||||
it "rejects the promise", ->
|
||||
atom.config.set("core.disabledPackages", [])
|
||||
|
@ -711,6 +711,9 @@ class Package
|
||||
incompatibleNativeModules
|
||||
|
||||
handleError: (message, error) ->
|
||||
if atom.inSpecMode()
|
||||
throw error
|
||||
|
||||
if error.filename and error.location and (error instanceof SyntaxError)
|
||||
location = "#{error.filename}:#{error.location.first_line + 1}:#{error.location.first_column + 1}"
|
||||
detail = "#{error.message} in #{location}"
|
||||
|
Loading…
Reference in New Issue
Block a user