UNPKG

4.54 kBtext/coffeescriptView Raw
1###
2try these:
3* node-expat
4* ffi
5* midi
6maybe:
7* airtunes
8* canvas
9try (with npg):
10* mapnik
11* osmium
12* osrm
13never worked:
14* node-sass
15* nodegit
16###
17
18os = require 'os'
19fs = require 'fs'
20path = require 'path'
21exec = require('child_process').exec
22
23chai = require 'chai'
24expect = chai.expect
25request = require 'request'
26
27aspm = require '../lib'
28
29platform = os.platform()
30
31defaultTargets = '0.17.2 0.19.5 0.20.1'.split ' '
32defaultArchs = 'ia32 x64'.split ' '
33defaultArchs = ['ia32'] if platform is 'win32'
34
35
36testModule = (moduleName, opts, cb) ->
37 [moduleName] = moduleName.split '@' # get rid of version
38 quiet = opts.quiet
39 atomShellExe = path.join 'atom-shell', "atom-shell-v#{opts.target}-#{platform}-#{opts.arch}", 'atom'
40 atomShellExe += '.exe' if platform is 'win32'
41 testDir = path.join 'tmp', moduleName
42 cmd = """
43 env ATOM_SHELL_INTERNAL_RUN_AS_NODE=1 #{atomShellExe} -e "require('./tmp/node_modules/#{moduleName}'); console.log('OK: required #{moduleName}')"
44 """
45 errMsg = ''
46 child = exec cmd
47 child.stdout.pipe process.stdout unless quiet
48 unless quiet
49 child.stderr.pipe process.stderr
50 else
51 child.stderr.on 'data', (chunk) -> errMsg += chunk; return
52 child.on 'exit', (code) ->
53 return cb?(new Error "command failed: #{cmd}\n#{errMsg}") if code isnt 0
54 cb?()
55 return
56
57testInstallMulti = (moduleName, targets=defaultTargets, archs=defaultArchs, opts={}) ->
58 for target in targets
59 for arch in archs
60 currentOpts = {}
61 currentOpts[key] = val for key, val of opts # copy opts
62 currentOpts.target = target
63 currentOpts.arch = arch
64
65 testInstall moduleName, currentOpts
66 return
67
68testInstall = (moduleName, opts={}) ->
69 opts.quiet = yes unless '--verbose' in process.argv
70 opts.cwd = 'tmp'
71 msg = moduleName
72 msg += " for Atom-Shell@#{opts.target} on #{platform} #{opts.arch}" if opts.target and opts.arch
73 msg += " from #{opts.tarball}" if opts.tarball
74 it msg, (done) ->
75 #process.chdir opts.cwd if opts.cwd
76 aspm.installModule moduleName, opts, (err) ->
77 return done err if err
78 return done err unless opts.target and opts.arch
79 testModule moduleName, opts, (err) ->
80 return done err
81 return
82 return
83 return
84
85downloadAtomShellMulti = (targets=defaultTargets, archs=defaultArchs, opts={}) ->
86 for target in targets
87 for arch in archs
88 do (target, arch) ->
89 it "#{target} #{platform} #{arch}", (done) -> downloadAtomShell target, arch, done
90 return
91
92downloadAtomShell = (target, arch, cb) ->
93 try fs.mkdirSync 'atom-shell'
94 releaseName = "atom-shell-v#{target}-#{platform}-#{arch}"
95 dir = path.join 'atom-shell', releaseName
96 return cb() if fs.existsSync dir # skip if we already have it
97 url = "http://github.com/atom/atom-shell/releases/download/v#{target}/#{releaseName}.zip"
98 zipfileName = path.join 'atom-shell', "#{releaseName}.zip"
99 zipfile = fs.createWriteStream zipfileName
100 request(url).pipe(zipfile).on 'finish', ->
101 zipfile.close ->
102 exec "unzip #{zipfileName} -d #{dir}", (err) ->
103 fs.unlink zipfileName, cb
104 return
105 return
106 return
107 return
108
109
110describe 'download atom-shell', ->
111 @timeout 1000*60 * 5 # minutes
112
113 downloadAtomShellMulti()
114
115describe 'build', ->
116 @timeout 1000*60 * 2 # minutes
117
118 try fs.mkdirSync 'tmp'
119 # create stub package.json in ./tmp/
120 fs.writeFileSync path.join('tmp', 'package.json'), """
121 {
122 "name": "aspm-test",
123 "description": "...",
124 "version": "0.0.1",
125 "private": true
126 }
127 """
128
129 describe 'js-only module', ->
130 testInstall 'async'
131
132 # !!! first enable recursive building
133 #describe 'js-only module /w native dependency', ->
134 # testInstallMulti 'nino@0.1.2'
135
136 describe 'native module', ->
137 testInstallMulti 'time@0.11.0'
138 testInstallMulti 'leveldown@1.0.0'
139 testInstallMulti 'nslog@1.0.1'
140 testInstallMulti 'pathwatcher@2.3.5'
141 ## testInstallMulti 'node-sass@1.2.3'
142
143 describe 'native module /w node-pre-gyp', ->
144 ## testInstallMulti 'nodegit@0.2.4', null, null, compatibility: yes
145 ## testInstallMulti 'node-expat@2.3.3'
146 ## testInstallMulti 'ffi@1.2.7'
147 ## testInstallMulti 'midi@0.9.0'
148
149 testInstallMulti 'serialport@1.4.9'
150 testInstallMulti 'zipfile@0.5.4'
151 testInstallMulti 'v8-profiler@5.2.1'
152 testInstallMulti 'sqlite3@3.0.4', ['0.17.2']
153 testInstallMulti 'sqlite3@master', ['0.19.5', '0.20.1'], null, tarball: 'https://github.com/mapbox/node-sqlite3/archive/master.tar.gz'
154
155 describe 'node-pre-gyp test app', ->
156 testInstallMulti 'node-pre-gyp-test-app1', null, null, tarball: '../test/node-pre-gyp/app1.tar.gz'
157 testInstallMulti 'node-pre-gyp-test-app3', null, null, tarball: '../test/node-pre-gyp/app3.tar.gz'