Help to write Promises to get specs working, probably activatePackage problem


#1

The current implementation of activatePackage is here and this global.lintserverisrunning flag is used here in Promise:

       return new Promise (resolve, reject) ->
          if lintserverisrunning
            resolve()
        .then (response) ->

This doesn’t work with specs.

In other words the wanted functionality is to get new Promise in activatePackage, which would be resolved after the jserver.stdout has the phrase “Server running on port/pipe”. I tried few different ways writing the promise around the existing code, but these will hang the Atom and thus are slow to develop by trial and error.

Currently I believe the problem is in activatePackage, but any help to get forward is appreciated.


#2

I think I got the Promises working: https://github.com/TeroFrondelius/linter-julia/blob/specs/lib/linter-julia.coffee

However, I still haven’t figured out: how to write the specs. Now the error is Uncaught (in promise) TypeError: Bad argument


#3

I found my Bad argument mistake as well. I was getting the julia executable location from different package julia-client, but I didn’t require this package to be available.


#4

I would need help to understand the concept of spec-file. My latest attempt is [here linter-julia-spec.coffee] (https://github.com/TeroFrondelius/linter-julia/blob/specs/spec/linter-julia-spec.coffee).

Based on the output it looks like that it doesn’t want to wait my promises but rushes through and doesn’t find any problems. Now I am pretty sure that the problem is on the spec side. This is most probably a trivial rookie mistake, thus any ideas are welcome.

Error deactivating package 'linter-julia' Error: ENOENT: no such file or directory, unlink '/tmp/lintserver2968CKA8ScoIoMF8sock'
    at Error (native)
    at Object.fs.unlinkSync (fs.js:1099:18)
    at Object.deactivate (/home/tero/.atom/packages/linter-julia/lib/linter-julia.coffee:77:10)
    at Package.module.exports.Package.deactivate (/usr/share/atom/resources/app.asar/src/package.js:693:20)
    at PackageManager.module.exports.PackageManager.deactivatePackage (/usr/share/atom/resources/app.asar/src/package-manager.js:643:12)
    at /usr/share/atom/resources/app.asar/src/package-manager.js:629:19
    at Config.module.exports.Config.transact (/usr/share/atom/resources/app.asar/src/config.js:312:16)
    at PackageManager.module.exports.PackageManager.deactivatePackages (/usr/share/atom/resources/app.asar/src/package-manager.js:623:19)
    at PackageManager.module.exports.PackageManager.reset (/usr/share/atom/resources/app.asar/src/package-manager.js:67:12)
    at AtomEnvironment.module.exports.AtomEnvironment.reset (/usr/share/atom/resources/app.asar/src/atom-environment.js:468:21)
    at .<anonymous> (/usr/share/atom/resources/app.asar/spec/spec-helper.js:145:10)
    at jasmine.Block.execute (/usr/share/atom/resources/app.asar/vendor/jasmine.js:1070:17)
    at jasmine.Queue.next_ (/usr/share/atom/resources/app.asar/vendor/jasmine.js:2102:31)
    at /usr/share/atom/resources/app.asar/vendor/jasmine.js:2092:18module.exports.Package.deactivate @ package.coffee:426module.exports.PackageManager.deactivatePackage @ package-manager.coffee:516(anonymous function) @ package-manager.coffee:507module.exports.Config.transact @ config.coffee:715module.exports.PackageManager.deactivatePackages @ package-manager.coffee:506module.exports.PackageManager.reset @ package-manager.coffee:68module.exports.AtomEnvironment.reset @ atom-environment.coffee:336(anonymous function) @ spec-helper.coffee:110jasmine.Block.execute @ jasmine.js:1070jasmine.Queue.next_ @ jasmine.js:2102(anonymous function) @ jasmine.js:2092
package.coffee:426Error deactivating package 'linter-julia' Error: ENOENT: no such file or directory, unlink '/tmp/lintserver2968SmTcaptZkgwBsock'
    at Error (native)
    at Object.fs.unlinkSync (fs.js:1099:18)
    at Object.deactivate (/home/tero/.atom/packages/linter-julia/lib/linter-julia.coffee:77:10)
    at Package.module.exports.Package.deactivate (/usr/share/atom/resources/app.asar/src/package.js:693:20)
    at PackageManager.module.exports.PackageManager.deactivatePackage (/usr/share/atom/resources/app.asar/src/package-manager.js:643:12)
    at /usr/share/atom/resources/app.asar/src/package-manager.js:629:19
    at Config.module.exports.Config.transact (/usr/share/atom/resources/app.asar/src/config.js:312:16)
    at PackageManager.module.exports.PackageManager.deactivatePackages (/usr/share/atom/resources/app.asar/src/package-manager.js:623:19)
    at PackageManager.module.exports.PackageManager.reset (/usr/share/atom/resources/app.asar/src/package-manager.js:67:12)
    at AtomEnvironment.module.exports.AtomEnvironment.reset (/usr/share/atom/resources/app.asar/src/atom-environment.js:468:21)
    at .<anonymous> (/usr/share/atom/resources/app.asar/spec/spec-helper.js:145:10)
    at jasmine.Block.execute (/usr/share/atom/resources/app.asar/vendor/jasmine.js:1070:17)
    at jasmine.Queue.next_ (/usr/share/atom/resources/app.asar/vendor/jasmine.js:2102:31)
    at onComplete (/usr/share/atom/resources/app.asar/vendor/jasmine.js:2098:18)
    at jasmine.WaitsForBlock.MultiCompletion.attemptCompletion (/usr/share/atom/resources/app.asar/vendor/jasmine.js:2648:8)
    at /usr/share/atom/resources/app.asar/vendor/jasmine.js:2658:10module.exports.Package.deactivate @ package.coffee:426module.exports.PackageManager.deactivatePackage @ package-manager.coffee:516(anonymous function) @ package-manager.coffee:507module.exports.Config.transact @ config.coffee:715module.exports.PackageManager.deactivatePackages @ package-manager.coffee:506module.exports.PackageManager.reset @ package-manager.coffee:68module.exports.AtomEnvironment.reset @ atom-environment.coffee:336(anonymous function) @ spec-helper.coffee:110jasmine.Block.execute @ jasmine.js:1070jasmine.Queue.next_ @ jasmine.js:2102onComplete @ jasmine.js:2098jasmine.WaitsForBlock.MultiCompletion.attemptCompletion @ jasmine.js:2648(anonymous function) @ jasmine.js:2658
linter-julia-spec.coffee [sm]:41 true
package.coffee:426 Error deactivating package 'linter-julia' Error: ENOENT: no such file or directory, unlink '/tmp/lintserver2968VYb1ZNdNjY1Asock'
    at Error (native)
    at Object.fs.unlinkSync (fs.js:1099:18)
    at Object.deactivate (/home/tero/.atom/packages/linter-julia/lib/linter-julia.coffee:77:10)
    at Package.module.exports.Package.deactivate (/usr/share/atom/resources/app.asar/src/package.js:693:20)
    at PackageManager.module.exports.PackageManager.deactivatePackage (/usr/share/atom/resources/app.asar/src/package-manager.js:643:12)
    at /usr/share/atom/resources/app.asar/src/package-manager.js:629:19
    at Config.module.exports.Config.transact (/usr/share/atom/resources/app.asar/src/config.js:312:16)
    at PackageManager.module.exports.PackageManager.deactivatePackages (/usr/share/atom/resources/app.asar/src/package-manager.js:623:19)
    at PackageManager.module.exports.PackageManager.reset (/usr/share/atom/resources/app.asar/src/package-manager.js:67:12)
    at AtomEnvironment.module.exports.AtomEnvironment.reset (/usr/share/atom/resources/app.asar/src/atom-environment.js:468:21)
    at .<anonymous> (/usr/share/atom/resources/app.asar/spec/spec-helper.js:145:10)
    at jasmine.Block.execute (/usr/share/atom/resources/app.asar/vendor/jasmine.js:1070:17)
    at jasmine.Queue.next_ (/usr/share/atom/resources/app.asar/vendor/jasmine.js:2102:31)
    at onComplete (/usr/share/atom/resources/app.asar/vendor/jasmine.js:2098:18)
    at jasmine.WaitsForBlock.MultiCompletion.attemptCompletion (/usr/share/atom/resources/app.asar/vendor/jasmine.js:2648:8)
    at /usr/share/atom/resources/app.asar/vendor/jasmine.js:2658:10module.exports.Package.deactivate @ package.coffee:426module.exports.PackageManager.deactivatePackage @ package-manager.coffee:516(anonymous function) @ package-manager.coffee:507module.exports.Config.transact @ config.coffee:715module.exports.PackageManager.deactivatePackages @ package-manager.coffee:506module.exports.PackageManager.reset @ package-manager.coffee:68module.exports.AtomEnvironment.reset @ atom-environment.coffee:336(anonymous function) @ spec-helper.coffee:110jasmine.Block.execute @ jasmine.js:1070jasmine.Queue.next_ @ jasmine.js:2102onComplete @ jasmine.js:2098jasmine.WaitsForBlock.MultiCompletion.attemptCompletion @ jasmine.js:2648(anonymous function) @ jasmine.js:2658
package.coffee:426 Error deactivating package 'linter-julia' Error: ENOENT: no such file or directory, unlink '/tmp/lintserver2968GMQbxKm2WWwNsock'
    at Error (native)
    at Object.fs.unlinkSync (fs.js:1099:18)
    at Object.deactivate (/home/tero/.atom/packages/linter-julia/lib/linter-julia.coffee:77:10)
    at Package.module.exports.Package.deactivate (/usr/share/atom/resources/app.asar/src/package.js:693:20)
    at PackageManager.module.exports.PackageManager.deactivatePackage (/usr/share/atom/resources/app.asar/src/package-manager.js:643:12)
    at /usr/share/atom/resources/app.asar/src/package-manager.js:629:19
    at Config.module.exports.Config.transact (/usr/share/atom/resources/app.asar/src/config.js:312:16)
    at PackageManager.module.exports.PackageManager.deactivatePackages (/usr/share/atom/resources/app.asar/src/package-manager.js:623:19)
    at PackageManager.module.exports.PackageManager.reset (/usr/share/atom/resources/app.asar/src/package-manager.js:67:12)
    at AtomEnvironment.module.exports.AtomEnvironment.reset (/usr/share/atom/resources/app.asar/src/atom-environment.js:468:21)
    at .<anonymous> (/usr/share/atom/resources/app.asar/spec/spec-helper.js:145:10)
    at jasmine.Block.execute (/usr/share/atom/resources/app.asar/vendor/jasmine.js:1070:17)
    at jasmine.Queue.next_ (/usr/share/atom/resources/app.asar/vendor/jasmine.js:2102:31)
    at /usr/share/atom/resources/app.asar/vendor/jasmine.js:2092:18module.exports.Package.deactivate @ package.coffee:426module.exports.PackageManager.deactivatePackage @ package-manager.coffee:516(anonymous function) @ package-manager.coffee:507module.exports.Config.transact @ config.coffee:715module.exports.PackageManager.deactivatePackages @ package-manager.coffee:506module.exports.PackageManager.reset @ package-manager.coffee:68module.exports.AtomEnvironment.reset @ atom-environment.coffee:336(anonymous function) @ spec-helper.coffee:110jasmine.Block.execute @ jasmine.js:1070jasmine.Queue.next_ @ jasmine.js:2102(anonymous function) @ jasmine.js:2092
linter-julia.coffee [sm]:19 Server running on port/pipe /tmp/lintserver2968CKA8ScoIoMF8sock ...
linter-julia.coffee [sm]:19 
linter-julia.coffee [sm]:19 Server running on port/pipe /tmp/lintserver2968VYb1ZNdNjY1Asock ...
linter-julia.coffee [sm]:19 
linter-julia.coffee [sm]:19 Server running on port/pipe /tmp/lintserver2968SmTcaptZkgwBsock ...
linter-julia.coffee [sm]:19 
linter-julia.coffee [sm]:19 Server running on port/pipe /tmp/lintserver2968GMQbxKm2WWwNsock ...
linter-julia.coffee [sm]:19 

#5

Hi @steelbrain, sorry to bother again, but could you take a quick look? This is probably a rookie mistake in async programming.


#6

Hi @TeroFrondelius

Are you on Atom Slack? I feel like it would be a less latency involved way of communication, I have the same username on Atom slack. Let’s discuss this there, I have a fix for these bugs in mind