Skip to content

Commit 09f959c

Browse files
Leon WeidauerConnor Clark
authored andcommitted
Fix Stats and BinTestCases after adding "Built at"
In order to pass the tests, a similar test replacement as with the millisecond values needs to happen. For the "Built at" stat all dates are replaces with Thu Jan 01 1970 00:00:00 GMT. Related to issue webpack#5305
1 parent 795a8ed commit 09f959c

45 files changed

Lines changed: 74 additions & 5 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/Stats.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,9 +612,6 @@ class Stats {
612612
newline();
613613
}
614614
if(typeof obj.time === "number") {
615-
colors.normal("Built at: ");
616-
colors.bold(new Date(obj.builtAt));
617-
newline();
618615
colors.normal("Time: ");
619616
colors.bold(obj.time);
620617
colors.normal("ms");
@@ -623,6 +620,14 @@ class Stats {
623620
if(obj.env) {
624621
colors.normal("Environment (--env): ");
625622
colors.bold(JSON.stringify(obj.env, null, 2));
623+
newline()
624+
}
625+
if(typeof obj.builtAt === "number") {
626+
const now = (new Date()).toString().split(" ");
627+
colors.normal("Built at: ");
628+
colors.normal(`${now[0]} ${now[1]} ${now[2]} ${now[3]} `);
629+
colors.bold(now[4]);
630+
colors.normal(now[6] ? ` ${now[5]} ${now[6]}` : ` ${now[5]}`);
626631
newline();
627632
}
628633
if(obj.publicPath) {

test/StatsTestCases.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,16 @@ describe("StatsTestCases", () => {
8888
if(!hasColorSetting) {
8989
actual = actual
9090
.replace(/\u001b\[[0-9;]*m/g, "")
91-
.replace(/[0-9]+(\s?ms)/g, "X$1");
91+
.replace(/[0-9]+(\s?ms)/g, "X$1")
92+
.replace(/^(\s*Built at:) (.*)$/gm, "$1 Thu Jan 01 1970 00:00:00 GMT");
9293
} else {
9394
actual = actual
9495
.replace(/\u001b\[1m\u001b\[([0-9;]*)m/g, "<CLR=$1,BOLD>")
9596
.replace(/\u001b\[1m/g, "<CLR=BOLD>")
9697
.replace(/\u001b\[39m\u001b\[22m/g, "</CLR>")
9798
.replace(/\u001b\[([0-9;]*)m/g, "<CLR=$1>")
98-
.replace(/[0-9]+(<\/CLR>)?(\s?ms)/g, "X$1$2");
99+
.replace(/[0-9]+(<\/CLR>)?(\s?ms)/g, "X$1$2")
100+
.replace(/^(\s*Built at:) (.*)$/gm, "$1 Thu Jan 01 1970 <CLR=BOLD>00:00:00<\/CLR> GMT");
99101
}
100102

101103
actual = actual

test/statsCases/aggressive-splitting-entry/expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Hash: 1d3bfcee111df03fa6251d3bfcee111df03fa625
22
Child fitting:
33
Hash: 1d3bfcee111df03fa625
44
Time: Xms
5+
Built at: Thu Jan 01 1970 00:00:00 GMT
56
Asset Size Chunks Chunk Names
67
706f97eb6a2b8fb1a17e.js 1.05 KiB 0 [emitted]
78
a65f8652fd07c12d0049.js 9.92 KiB 1 [emitted]
@@ -27,6 +28,7 @@ Child fitting:
2728
Child content-change:
2829
Hash: 1d3bfcee111df03fa625
2930
Time: Xms
31+
Built at: Thu Jan 01 1970 00:00:00 GMT
3032
Asset Size Chunks Chunk Names
3133
706f97eb6a2b8fb1a17e.js 1.05 KiB 0 [emitted]
3234
a65f8652fd07c12d0049.js 9.92 KiB 1 [emitted]

test/statsCases/aggressive-splitting-on-demand/expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Hash: af168fd06ab994207f62
22
Time: Xms
3+
Built at: Thu Jan 01 1970 00:00:00 GMT
34
Asset Size Chunks Chunk Names
45
031881c6ced2f576ff79.js 1.94 KiB 5 [emitted]
56
ba1a8dd27d611254d495.js 1.93 KiB 0 [emitted]

test/statsCases/chunks-development/expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Hash: 5ce1f032cffdff8368b5
22
Time: Xms
3+
Built at: Thu Jan 01 1970 00:00:00 GMT
34
Asset Size Chunks Chunk Names
45
0.bundle.js 530 bytes 0 [emitted]
56
1.bundle.js 394 bytes 1 [emitted]

test/statsCases/chunks/expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Hash: 7870601bc1a1a4f9c4c1
22
Time: Xms
3+
Built at: Thu Jan 01 1970 00:00:00 GMT
34
Asset Size Chunks Chunk Names
45
0.bundle.js 152 bytes 0 [emitted]
56
1.bundle.js 289 bytes 1 [emitted]

test/statsCases/color-disabled/expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Hash: 5ebdffcace96139575ac
22
Time: Xms
3+
Built at: Thu Jan 01 1970 <CLR=BOLD>00:00:00</CLR> GMT
34
Asset Size Chunks Chunk Names
45
main.js 2.61 KiB 0 [emitted] main
56
Entrypoint main = main.js

test/statsCases/color-enabled-custom/expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Hash: <CLR=BOLD>5ebdffcace96139575ac</CLR>
22
Time: <CLR=BOLD>X</CLR>ms
3+
Built at: Thu Jan 01 1970 <CLR=BOLD>00:00:00</CLR> GMT
34
<CLR=BOLD>Asset</CLR> <CLR=BOLD>Size</CLR> <CLR=BOLD>Chunks</CLR> <CLR=39,BOLD><CLR=22> <CLR=39,BOLD><CLR=22><CLR=BOLD>Chunk Names</CLR>
45
<CLR=32>main.js</CLR> 2.61 KiB <CLR=BOLD>0</CLR> <CLR=32>[emitted]</CLR> main
56
Entrypoint <CLR=BOLD>main</CLR> = <CLR=32>main.js</CLR>

test/statsCases/color-enabled/expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Hash: <CLR=BOLD>5ebdffcace96139575ac</CLR>
22
Time: <CLR=BOLD>X</CLR>ms
3+
Built at: Thu Jan 01 1970 <CLR=BOLD>00:00:00</CLR> GMT
34
<CLR=BOLD>Asset</CLR> <CLR=BOLD>Size</CLR> <CLR=BOLD>Chunks</CLR> <CLR=39,BOLD><CLR=22> <CLR=39,BOLD><CLR=22><CLR=BOLD>Chunk Names</CLR>
45
<CLR=32,BOLD>main.js</CLR> 2.61 KiB <CLR=BOLD>0</CLR> <CLR=32,BOLD>[emitted]</CLR> main
56
Entrypoint <CLR=BOLD>main</CLR> = <CLR=32,BOLD>main.js</CLR>

test/statsCases/commons-chunk-min-size-0/expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Hash: 2a374ac6d98475951384
22
Time: Xms
3+
Built at: Thu Jan 01 1970 00:00:00 GMT
34
Asset Size Chunks Chunk Names
45
entry-1.js 5.49 KiB 0 [emitted] entry-1
56
vendor-1~entry-1.js 314 bytes 1 [emitted] vendor-1~entry-1

0 commit comments

Comments
 (0)