forked from meteor/meteor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource-maps.js
More file actions
107 lines (91 loc) · 2.87 KB
/
source-maps.js
File metadata and controls
107 lines (91 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
var selftest = require('../tool-testing/selftest.js');
var Sandbox = selftest.Sandbox;
var files = require('../fs/files.js');
var catalog = require('../packaging/catalog/catalog.js');
function matchPath (text, doubleBS) {
if (process.platform === 'win32')
return text.replace(/\//g, doubleBS ? '\\\\' : '\\');
return text;
}
function matchPathRegexp (regexp) {
return new RegExp(matchPath(regexp, true));
}
selftest.define("source maps from checkout", ['checkout'], function () {
try {
throw new Error();
} catch (e) {
var index = (process.platform === 'win32') ? 2 : 1;
selftest.expectEqual(e.stack.split(":")[index], "17");
}
});
selftest.define("source maps from an app", ['checkout'], function () {
var s = new Sandbox({
warehouse: {
v1: { recommended: true }
}
});
// If run not in an app dir, runs the latest version ...
var run = s.run("--version");
run.read('Meteor v1\n');
run.expectEnd();
run.expectExit(0);
// Starting a run
s.createApp("myapp", "app-throws-error", {
release: "v1"
});
s.cd("myapp");
s.set("METEOR_TEST_TMP", files.convertToOSPath(files.mkdtemp())); // XXX why?
run = s.run("run");
run.waitSecs(10);
run.match(matchPathRegexp('at throw\\.js:3\\b'));
run.stop();
s.set('THROW_FROM_PACKAGE', 't');
run = s.run('run');
run.waitSecs(10);
run.match(matchPathRegexp('packages/throwing-package/thrower\\.js:2\\b'));
run.stop();
});
selftest.define("source maps from built meteor tool", ['checkout'], function () {
var s = new Sandbox({
warehouse: {
v1: { recommended: true }
}
});
// Find the line number that is supposed to throw an error
var commandsJs = files.readFile(files.pathJoin(
files.convertToStandardPath(__dirname), '../cli/commands.js'), "utf8");
var lineNumber = 0;
commandsJs.split("\n").some((line, index) => {
if (line.indexOf("#StackTraceTest") != -1) {
// Lines aren't zero-indexed
lineNumber = index + 1;
// Short-circuit the some
return true;
}
});
if (lineNumber === 0) {
throw new Error("Couldn't find the right line. This test is broken.");
}
var run = s.run("throw-error");
run.matchErr(matchPathRegexp('\\(/tools/cli/commands\\.js:' + lineNumber));
run.expectExit(8);
});
selftest.define("source maps from a build plugin implementation", ['checkout'], function () {
var s = new Sandbox({
warehouse: {
v1: { recommended: true }
}
});
// Starting a run
s.createApp("myapp", "build-plugin-throws-error", {
release: "v1"
});
s.cd("myapp");
var run = s.run("run");
run.waitSecs(10);
// XXX This is wrong! The path on disk is
// packages/build-plugin/build-plugin.js, but at some point we switched to the
// servePath which is based on the *plugin*'s "package" name.
run.match(matchPathRegexp('packages/build-plugin-itself/build-plugin\\.js:2:1\\b'));
run.stop();
});