Skip to content

Commit ee43b9d

Browse files
committed
fix e2e
1 parent 9ffb8ab commit ee43b9d

File tree

8 files changed

+1741
-6537
lines changed

8 files changed

+1741
-6537
lines changed

package-lock.json

Lines changed: 1439 additions & 6417 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@nx-advanced-perf-logging/source",
2+
"name": "@push-based/source",
33
"version": "0.0.0",
44
"license": "MIT",
55
"scripts": {},

packages/cpu-prof-e2e/test/__snapshots__/command-cpu-merged.default-options.json

Lines changed: 77 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,28 @@
1717
"name": "CrRendererMain"
1818
}
1919
},
20+
{
21+
"cat": "__metadata",
22+
"name": "process_name",
23+
"ph": "M",
24+
"pid": 10002,
25+
"tid": 0,
26+
"ts": 0,
27+
"args": {
28+
"name": "P:10002, T:0"
29+
}
30+
},
31+
{
32+
"cat": "__metadata",
33+
"name": "process_name",
34+
"ph": "M",
35+
"pid": 10002,
36+
"tid": 1,
37+
"ts": 0,
38+
"args": {
39+
"name": "P:10002, T:1"
40+
}
41+
},
2042
{
2143
"args": {
2244
"data": {
@@ -110,7 +132,9 @@
110132
"lineNumber": -1,
111133
"columnNumber": -1
112134
},
113-
"children": [2]
135+
"children": [
136+
2
137+
]
114138
},
115139
{
116140
"id": 2,
@@ -122,7 +146,9 @@
122146
"columnNumber": 0
123147
},
124148
"parent": 1,
125-
"children": [3]
149+
"children": [
150+
3
151+
]
126152
},
127153
{
128154
"id": 3,
@@ -134,7 +160,9 @@
134160
"columnNumber": 0
135161
},
136162
"parent": 2,
137-
"children": [4]
163+
"children": [
164+
4
165+
]
138166
},
139167
{
140168
"id": 4,
@@ -148,9 +176,23 @@
148176
"parent": 3
149177
}
150178
],
151-
"samples": [1, 4, 4, 4, 4, 1]
179+
"samples": [
180+
1,
181+
4,
182+
4,
183+
4,
184+
4,
185+
1
186+
]
152187
},
153-
"timeDeltas": [0, 10, 10, 10, 10, 0]
188+
"timeDeltas": [
189+
0,
190+
10,
191+
10,
192+
10,
193+
10,
194+
0
195+
]
154196
}
155197
}
156198
},
@@ -217,7 +259,9 @@
217259
"lineNumber": -1,
218260
"columnNumber": -1
219261
},
220-
"children": [2]
262+
"children": [
263+
2
264+
]
221265
},
222266
{
223267
"id": 2,
@@ -228,7 +272,9 @@
228272
"lineNumber": 10,
229273
"columnNumber": 0
230274
},
231-
"children": [3]
275+
"children": [
276+
3
277+
]
232278
},
233279
{
234280
"id": 3,
@@ -239,7 +285,9 @@
239285
"lineNumber": 20,
240286
"columnNumber": 0
241287
},
242-
"children": [4]
288+
"children": [
289+
4
290+
]
243291
},
244292
{
245293
"id": 4,
@@ -253,9 +301,27 @@
253301
"children": []
254302
}
255303
],
256-
"samples": [1, 2, 3, 4, 3, 2, 1, 1]
304+
"samples": [
305+
1,
306+
2,
307+
3,
308+
4,
309+
3,
310+
2,
311+
1,
312+
1
313+
]
257314
},
258-
"timeDeltas": [0, 10, 10, 10, 10, 10, 10, 0]
315+
"timeDeltas": [
316+
0,
317+
10,
318+
10,
319+
10,
320+
10,
321+
10,
322+
10,
323+
0
324+
]
259325
}
260326
}
261327
},
@@ -274,4 +340,4 @@
274340
}
275341
}
276342
]
277-
}
343+
}

packages/cpu-prof-e2e/test/cpu-merge-command.e2e.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('cpu-merge-command', () => {
3535
});
3636

3737
expect(stdout).toContain('✅ CPU profiles merged successfully!');
38-
expect(stdout).toContain('📊 Generated 7 trace events');
38+
expect(stdout).toContain('📊 Generated 8 trace events');
3939
expect(stdout).toContain('📄 Output file:');
4040
expect(stdout).toContain('merged-profile.json');
4141
expect(stderr).toBe('');
@@ -70,7 +70,7 @@ describe('cpu-merge-command', () => {
7070
args: [cliPath, 'merge', inputDir],
7171
});
7272

73-
expect(stdout).toContain('📊 Generated 11 trace events');
73+
expect(stdout).toContain('📊 Generated 13 trace events');
7474
expect(stderr).toBe('');
7575
expect(code).toBe(0);
7676

@@ -113,7 +113,7 @@ describe('cpu-merge-command', () => {
113113

114114
expect(stderr).toBe('');
115115
expect(code).toBe(0);
116-
expect(stdout).toContain('📊 Generated 11 trace events');
116+
expect(stdout).toContain('📊 Generated 13 trace events');
117117

118118
expect(existsSync(join(outputDir, 'merged-profile.json'))).toBe(true);
119119
});
@@ -145,7 +145,7 @@ describe('cpu-merge-command', () => {
145145

146146
expect(stderr).toBe('');
147147
expect(code).toBe(0);
148-
expect(stdout).toContain('📊 Generated 11 trace events');
148+
expect(stdout).toContain('📊 Generated 13 trace events');
149149
const outputFileContent = (
150150
await readFile(join(inputDir, 'merged-profile.json'))
151151
).toString();
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Usage: cpu-prof <command> [options]
2+
3+
PushBased Profiling - Advanced CPU profiling and trace file uti
4+
lities
5+
6+
Commands:
7+
cpu-prof Run a Node.js script with CPU profiling enabled and save t
8+
he profile to disk [default]
9+
cpu-prof measure <commandToProfile...> Run a Node.js script with CPU profiling enabled and save t
10+
he profile to disk
11+
cpu-prof merge <inputDir> Merge multiple Chrome DevTools trace files or CPU profile
12+
files into a single file
13+
14+
CPU Measure Options:
15+
--cpu-prof-dir Directory to save the profile.
16+
[string] [default: "[PATH_PLACEHOLDER]"]
17+
--cpu-prof-interval Interval in milliseconds to sample the command. [number]
18+
--cpu-prof-name Name of the profile (auto-generated if not specified). [string]
19+
-h, --help Show help [boolean]
20+
21+
Options:
22+
--version Show version number [boolean]
23+
--flagMain Adds prefix and command args to the profile name of the initial process.
24+
[boolean] [default: false]
25+
26+
Examples:
27+
cpu-prof measure --cpu-prof-dir ./profiles node my Profile `node my_script.js --arg-for-script` a
28+
_script.js --arg-for-script nd save to ./profiles. Options can be anywhere
29+
.
30+
cpu-prof measure node my_app.js --cpu-prof-name bu Profile `node my_app.js`, name it `build-profi
31+
ild-profile --cpu-prof-interval 500 le` with 500ms interval. Options can be inters
32+
persed.
33+
34+
The command to profile and its arguments are explicitly parsed via the command definition.
35+
CPU Measure options (like --cpu-prof-dir) can be placed anywhere.
36+
37+
Examples:
38+
cpu-prof measure node my_script.js --arg-for-script
39+
cpu-prof measure --cpu-prof-dir ./custom-profiles node my_app.js
40+
cpu-prof measure node my_app.js --cpu-prof-interval 100

packages/cpu-prof-e2e/test/help-command.e2e.test.ts

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,50 +12,15 @@ describe('help-command', () => {
1212
args: [cliPath, 'cpu-merge', '--help'],
1313
});
1414

15-
expect(stdout).toMatchInlineSnapshot(`
16-
"Usage: cpu-prof <command> [options]
17-
18-
PushBased Profiling - Advanced CPU profiling and trace file uti
19-
lities
20-
21-
Commands:
22-
cpu-prof Run a Node.js script with CPU profiling enabled and save t
23-
he profile to disk [default]
24-
cpu-prof measure <commandToProfile...> Run a Node.js script with CPU profiling enabled and save t
25-
he profile to disk
26-
cpu-prof merge <inputDir> Merge multiple Chrome DevTools trace files or CPU profile
27-
files into a single file
28-
29-
CPU Measure Options:
30-
--cpu-prof-dir Directory to save the profile.
31-
[string] [default: "/Users/michael_hladky/WebstormProjects/nx-advanced-perf-logging/packages/cpu-p
32-
rof-e2e/profiles"]
33-
--cpu-prof-interval Interval in milliseconds to sample the command. [number]
34-
--cpu-prof-name Name of the profile (auto-generated if not specified). [string]
35-
-h, --help Show help [boolean]
36-
37-
Options:
38-
--version Show version number [boolean]
39-
--flagMain Adds prefix and command args to the profile name of the initial process.
40-
[boolean] [default: false]
41-
42-
Examples:
43-
cpu-prof measure --cpu-prof-dir ./profiles node my Profile \`node my_script.js --arg-for-script\` a
44-
_script.js --arg-for-script nd save to ./profiles. Options can be anywhere
45-
.
46-
cpu-prof measure node my_app.js --cpu-prof-name bu Profile \`node my_app.js\`, name it \`build-profi
47-
ild-profile --cpu-prof-interval 500 le\` with 500ms interval. Options can be inters
48-
persed.
49-
50-
The command to profile and its arguments are explicitly parsed via the command definition.
51-
CPU Measure options (like --cpu-prof-dir) can be placed anywhere.
52-
53-
Examples:
54-
cpu-prof measure node my_script.js --arg-for-script
55-
cpu-prof measure --cpu-prof-dir ./custom-profiles node my_app.js
56-
cpu-prof measure node my_app.js --cpu-prof-interval 100
57-
"
58-
`);
15+
// Replace the variable default path with a stable placeholder
16+
const processedStdout = stdout.replace(
17+
/(\[string\] \[default: \")([^\"]+)(\"\])/g,
18+
'$1[PATH_PLACEHOLDER]$3'
19+
);
20+
21+
await expect(processedStdout).toMatchFileSnapshot(
22+
join(__dirname, 'help-command.e2e.test.stdout.txt')
23+
);
5924
expect(stderr).toBe('');
6025
expect(code).toBe(0);
6126
});

0 commit comments

Comments
 (0)