forked from nodejs/node-core-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathamend.test.js
More file actions
170 lines (135 loc) · 6.13 KB
/
amend.test.js
File metadata and controls
170 lines (135 loc) · 6.13 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import { describe, it } from 'node:test';
import LandingSession from '../../lib/landing_session.js';
const createMockCli = () => ({
prompt: () => Promise.resolve(false),
ok: () => {},
warn: () => {},
info: () => {},
log: () => {},
separator: () => {},
startSpinner: () => ({ stop: () => {} }),
stopSpinner: () => {},
setExitCode: () => {}
});
const createSession = (overrides = undefined) => {
const options = {
owner: 'nodejs',
repo: 'node',
upstream: 'origin',
branch: 'main',
prid: 123,
oneCommitMax: false,
backport: false,
...overrides
};
const session = new LandingSession(createMockCli(), {}, '/', options);
let metadata = `${options.backport ? 'Backport-' : ''}PR-URL: http://example.com/${options.prid}\nReviewed-By: user1 <[email protected]>\n`;
if (options.metadata) {
metadata += options.metadata;
}
return Object.defineProperty(session, 'metadata', {
__proto__: null,
configurable: true,
value: metadata
});
};
describe('LandingSession.prototype.generateAmendedMessage', () => {
it('should append PR-URL when there are no trailers', async(t) => {
const session = createSession();
const result = await session.generateAmendedMessage('foo: bar');
t.assert.strictEqual(
result,
'foo: bar\n\nPR-URL: http://example.com/123\nReviewed-By: user1 <[email protected]>'
);
});
it('should not duplicate trailers that are in metadata', async(t) => {
const session = createSession({ metadata: 'Refs: http://example.com/321\nRefs: http://example.com/456' });
const result = await session.generateAmendedMessage('foo: bar\n\nRefs: http://example.com/321');
t.assert.strictEqual(
result,
'foo: bar\n\nRefs: http://example.com/321\nPR-URL: http://example.com/123\nReviewed-By: user1 <[email protected]>\nRefs: http://example.com/456'
);
});
it('should strip trailers added by NCU', async(t) => {
const session = createSession();
const result = await session.generateAmendedMessage(
'subsystem: fix bug\n\nReviewed-By: user1 <[email protected]>\nPR-URL: http://example.com/123\nBackport-PR-URL: http://example.com/321\nOther-Trailer: Value\n'
);
t.assert.strictEqual(
result,
'subsystem: fix bug\n\nOther-Trailer: Value\nPR-URL: http://example.com/123\nReviewed-By: user1 <[email protected]>'
);
});
it('should strip trailers added by NCU regardless of case', async(t) => {
const session = createSession();
const result = await session.generateAmendedMessage(
'subsystem: fix bug\n\nReViEWed-bY: user1 <[email protected]>\npr-url: http://example.com/123\nBACKPORT-PR-URL: http://example.com/321\nOther-Trailer: Value\n'
);
t.assert.strictEqual(
result,
'subsystem: fix bug\n\nOther-Trailer: Value\nPR-URL: http://example.com/123\nReviewed-By: user1 <[email protected]>'
);
});
it('should not strip PR-URL trailer when backporting', async(t) => {
const session = createSession({ backport: true, prid: 456 });
const result = await session.generateAmendedMessage(
'subsystem: foobar\n\nOther-Trailer: Value\nPR-URL: http://example.com/999\nReviewed-By: foobar <[email protected]>\n'
);
t.assert.strictEqual(
result,
'subsystem: foobar\n\nOther-Trailer: Value\nPR-URL: http://example.com/999\nBackport-PR-URL: http://example.com/456\nReviewed-By: user1 <[email protected]>'
);
});
it('should clean-up trailers with extra space', async(t) => {
const session = createSession();
const result = await session.generateAmendedMessage(
'subsystem: foobar\n\n\nTrailer: Value \n\n\n'
);
t.assert.strictEqual(result, 'subsystem: foobar\n\nTrailer: Value\nPR-URL: http://example.com/123\nReviewed-By: user1 <[email protected]>');
});
it('should handle empty message', async(t) => {
const session = createSession();
const result = await session.generateAmendedMessage('');
t.assert.strictEqual(result, '\nPR-URL: http://example.com/123\nReviewed-By: user1 <[email protected]>');
});
it('should handle cherry-pick from upstream', async(t) => {
const session = createSession({ metadata: 'Refs: https://github.com/v8/v8/commit/cf1bce40a5ef4c7c1da351754f5bf526c0c96463\n' });
const result = await session.generateAmendedMessage(`deps: V8: cherry-pick cf1bce40a5ef
Original commit message:
[wasm] Fix S128Const on big endian
Since http://crrev.com/c/2944437 globals are no longer little endian
enforced.
S128Const handling in the initializer needs to take this into account
and byte reverse values which are hard coded in little endian order.
This is currently causing failures on Node.js upstream:
https://github.com/nodejs/node/pull/59034#issuecomment-4129144461
Change-Id: Ifcc9ade93ee51565ab19b16e9dadf0ff5752f7a6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7704213
Commit-Queue: Milad Farazmand <[email protected]>
Reviewed-by: Manos Koukoutos <[email protected]>
Cr-Commit-Position: refs/heads/main@{#106082}
PR-URL: https://github.com/nodejs/node/pull/62449
Refs: https://github.com/v8/v8/commit/cf1bce40a5ef4c7c1da351754f5bf526c0c96463
Reviewed-By: Guy Bedford <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
`);
t.assert.strictEqual(result, `deps: V8: cherry-pick cf1bce40a5ef
Original commit message:
[wasm] Fix S128Const on big endian
Since http://crrev.com/c/2944437 globals are no longer little endian
enforced.
S128Const handling in the initializer needs to take this into account
and byte reverse values which are hard coded in little endian order.
This is currently causing failures on Node.js upstream:
https://github.com/nodejs/node/pull/59034#issuecomment-4129144461
Change-Id: Ifcc9ade93ee51565ab19b16e9dadf0ff5752f7a6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7704213
Commit-Queue: Milad Farazmand <[email protected]>
Reviewed-by: Manos Koukoutos <[email protected]>
Cr-Commit-Position: refs/heads/main@{#106082}
Refs: https://github.com/v8/v8/commit/cf1bce40a5ef4c7c1da351754f5bf526c0c96463
PR-URL: http://example.com/123
Reviewed-By: user1 <[email protected]>`
);
});
});