Skip to content

Commit 2ed0e2c

Browse files
authored
Merge pull request #19 from electron/add-tests
Add initial tests
2 parents 600eb01 + 4c34bc7 commit 2ed0e2c

File tree

9 files changed

+130
-16
lines changed

9 files changed

+130
-16
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "deps/breakpad"]
22
path = deps/breakpad
3-
url = https://github.com/atom/chromium-breakpad.git
3+
url = https://github.com/electron/chromium-breakpad.git

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.gitmodules
2+
.npmignore
3+
.travis.yml
4+
test

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
language: node_js
22

33
node_js:
4-
- "0.11"
5-
- "0.10"
6-
- "0.8"
4+
- "node"
5+
6+
os:
7+
- osx
78

89
notifications:
910
email:
1011
on_success: never
1112
on_failure: change
1213

1314
before_install:
14-
git submodule sync && git submodule update --init --recursive
15+
- git submodule sync && git submodule update --init --recursive
1516

1617
branches:
1718
only:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# minidump - Process minidump files [![Build Status](https://travis-ci.org/atom/node-minidump.svg?branch=master)](https://travis-ci.org/atom/node-minidump)
1+
# minidump - Process minidump files [![Build Status](https://travis-ci.org/electron/node-minidump.svg?branch=master)](https://travis-ci.org/electron/node-minidump)
22

33
## Installing
44

lib/minidump.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports.walkStack = function(minidump, symbolPaths, callback) {
5151

5252
var stackwalk = searchCommand('minidump_stackwalk');
5353
if (!stackwalk) {
54-
callback('Unable to find the "minidump_stackwalk"');
54+
callback(new Error('Unable to find "minidump_stackwalk"'));
5555
return;
5656
}
5757

@@ -62,7 +62,7 @@ module.exports.walkStack = function(minidump, symbolPaths, callback) {
6262
module.exports.dumpSymbol = function(binary, callback) {
6363
var dumpsyms = searchCommand('dump_syms');
6464
if (!dumpsyms) {
65-
callback('Unable to find the "dump_syms"');
65+
callback(new Error('Unable to find "dump_syms"'));
6666
return;
6767
}
6868

package.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@
66
"bin": {
77
"minidump_stackwalk": "bin/minidump_stackwalk"
88
},
9-
"licenses": [
10-
{
11-
"type": "MIT",
12-
"url": "http://github.com/atom/node-minidump/raw/master/LICENSE.md"
13-
}
14-
],
9+
"license": "MIT",
1510
"repository": {
1611
"type": "git",
17-
"url": "https://github.com/atom/node-minidump.git"
12+
"url": "https://github.com/electron/node-minidump.git"
1813
},
1914
"bugs": {
20-
"url": "https://github.com/atom/node-minidump/issues"
15+
"url": "https://github.com/electron/node-minidump/issues"
16+
},
17+
"scripts": {
18+
"test": "mocha test"
19+
},
20+
"devDependencies": {
21+
"electron-download": "^3.0.1",
22+
"extract-zip": "^1.5.0",
23+
"mocha": "^3.1.2",
24+
"temp": "^0.8.3"
2125
}
2226
}

test/fixtures/mac.dmp

259 KB
Binary file not shown.

test/fixtures/windows.dmp

233 KB
Binary file not shown.

test/minidump-test.js

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
var assert = require('assert')
2+
var path = require('path')
3+
4+
var minidump = require('..')
5+
var electronDownload = require('electron-download')
6+
var extractZip = require('extract-zip')
7+
var temp = require('temp').track()
8+
9+
describe('minidump', function () {
10+
this.timeout(60000)
11+
12+
describe('walkStack()', function () {
13+
describe('macOS dump', function () {
14+
it('calls back with a report', function (done) {
15+
downloadElectronSymbols('darwin', function (error, symbolsPath) {
16+
if (error) return done(error)
17+
18+
var dumpPath = path.join(__dirname, 'fixtures', 'mac.dmp')
19+
minidump.walkStack(dumpPath, symbolsPath, function (error, report) {
20+
if (error) return done(error)
21+
22+
assert.equal(Buffer.isBuffer(report), true)
23+
assert.notEqual(report.length, 0)
24+
25+
report = report.toString()
26+
assert.notEqual(report.indexOf('Electron Framework!atom::(anonymous namespace)::Crash() [atom_bindings.cc : 27 + 0x0]'), -1)
27+
done()
28+
})
29+
})
30+
})
31+
})
32+
33+
describe('Windows dump', function () {
34+
it('calls back with a report', function (done) {
35+
downloadElectronSymbols('win32', function (error, symbolsPath) {
36+
if (error) return done(error)
37+
38+
var dumpPath = path.join(__dirname, 'fixtures', 'windows.dmp')
39+
minidump.walkStack(dumpPath, symbolsPath, function (error, report) {
40+
if (error) return done(error)
41+
42+
assert.equal(Buffer.isBuffer(report), true)
43+
assert.notEqual(report.length, 0)
44+
45+
report = report.toString()
46+
assert.notEqual(report.indexOf('electron.exe!atom::`anonymous namespace\'::Crash [atom_bindings.cc : 27 + 0x0]'), -1)
47+
done()
48+
})
49+
})
50+
})
51+
})
52+
})
53+
54+
describe('dumpSymbol()', function () {
55+
it('calls back with a minidump', function (done) {
56+
if (process.platform !== 'darwin') return this.skip()
57+
58+
downloadElectron(function (error, binaryPath) {
59+
if (error) return done(error)
60+
minidump.dumpSymbol(binaryPath, function (error, minidump) {
61+
if (error) return done(error)
62+
63+
assert.equal(Buffer.isBuffer(minidump), true)
64+
assert.notEqual(minidump.length, 0)
65+
done()
66+
})
67+
})
68+
})
69+
})
70+
})
71+
72+
var downloadElectron = function (callback) {
73+
electronDownload({
74+
version: '1.4.3',
75+
arch: 'x64',
76+
platform: 'darwin',
77+
quiet: true
78+
}, function (error, zipPath) {
79+
if (error) return callback(error)
80+
81+
var electronPath = temp.mkdirSync('node-minidump-')
82+
extractZip(zipPath, {dir: electronPath}, function (error) {
83+
if (error) return callback(error)
84+
callback(null, path.join(electronPath, 'Electron.app', 'Contents', 'MacOS', 'Electron'))
85+
})
86+
})
87+
}
88+
89+
var downloadElectronSymbols = function (platform, callback) {
90+
electronDownload({
91+
version: '1.4.3', // Dumps were generated with Electron 1.4.3 x64
92+
arch: 'x64',
93+
platform: platform,
94+
symbols: true,
95+
quiet: true
96+
}, function (error, zipPath) {
97+
if (error) return callback(error)
98+
99+
var symbolsPath = temp.mkdirSync('node-minidump-')
100+
extractZip(zipPath, {dir: symbolsPath}, function (error) {
101+
if (error) return callback(error)
102+
callback(null, path.join(symbolsPath, 'electron.breakpad.syms'))
103+
})
104+
})
105+
}

0 commit comments

Comments
 (0)