@@ -54,7 +54,7 @@ const runComparator = async (name, base, head) => {
5454 return stdout ;
5555} ;
5656
57- test ( 'comparePerformance formats benchmark differences' , async t => {
57+ test ( 'comparePerformance summarizes benchmark differences' , async t => {
5858 const { base, head } = await createDirectories ( t ) ;
5959
6060 await Promise . all ( [
@@ -71,16 +71,14 @@ test('comparePerformance formats benchmark differences', async t => {
7171
7272 assert . match (
7373 result ,
74- / E l a p s e d t i m e \| 2 \. 0 0 s \| 3 \. 0 0 s \| \+ 1 \ .0 0 s \( \+ 5 0 \. 0 0 % \) /
74+ / \* \* G e n e r a t i o n t i m e : \* \* 5 0 \. 0 % s l o w e r \( 2 \. 0 0 s → 3 \ .0 0 s \) /
7575 ) ;
7676 assert . match (
7777 result ,
78- / U s e r C P U t i m e \| 1 \. 0 0 s \| 7 5 0 \. 0 0 m s \| - 2 5 0 \. 0 0 m s \( - 2 5 \. 0 0 % \) /
79- ) ;
80- assert . match (
81- result ,
82- / P e a k r e s i d e n t m e m o r y \| 1 \. 0 0 M B \| 1 \. 5 0 M B \| \+ 5 1 2 \. 0 0 K B \( \+ 5 0 \. 0 0 % \) /
78+ / \* \* P e a k m e m o r y : \* \* 5 0 \. 0 % h i g h e r \( 1 \. 0 0 M B → 1 \. 5 0 M B \) /
8379 ) ;
80+ assert . match ( result , / s i n g l e C I r u n / ) ;
81+ assert . doesNotMatch ( result , / C P U t i m e / ) ;
8482} ) ;
8583
8684test ( 'comparePerformance omits results when an artifact has no benchmark' , async t => {
@@ -101,7 +99,7 @@ test('comparePerformance rejects invalid benchmark values', async t => {
10199
102100 await assert . rejects (
103101 comparePerformance ( base , head ) ,
104- / I n v a l i d p e a k r e s i d e n t m e m o r y b e n c h m a r k v a l u e /
102+ / I n v a l i d p e a k m e m o r y b e n c h m a r k v a l u e /
105103 ) ;
106104} ) ;
107105
@@ -118,9 +116,14 @@ test('file-size comparator combines output and performance results', async t =>
118116 const result = await runComparator ( 'file-size' , base , head ) ;
119117
120118 assert . equal ( result . match ( / # # ` t e s t ` G e n e r a t o r / g) ?. length , 1 ) ;
121- assert . match ( result , / # # # O u t p u t s i z e / ) ;
119+ assert . match ( result , / O u t p u t s i z e : .* 1 f i l e c h a n g e d · n e t \+ 1 1 \. 0 0 B / ) ;
120+ assert . match ( result , / < s u m m a r y > F i l e s i z e d e t a i l s < \/ s u m m a r y > / ) ;
121+ assert . match (
122+ result ,
123+ / \| F i l e \| M a i n \| P R \| C h a n g e \| \n \| - - - \| - - - : \| - - - : \| - - - : \| /
124+ ) ;
122125 assert . match ( result , / ` r e s u l t \. t x t ` / ) ;
123- assert . match ( result , / # # # P e r f o r m a n c e / ) ;
126+ assert . match ( result , / P e r f o r m a n c e e s t i m a t e / ) ;
124127 assert . doesNotMatch ( result , / b e n c h m a r k \. j s o n / ) ;
125128} ) ;
126129
@@ -137,7 +140,33 @@ test('object comparator treats benchmark data as metadata', async t => {
137140 const result = await runComparator ( 'object-assertion' , base , head ) ;
138141
139142 assert . equal ( result . match ( / # # ` t e s t ` G e n e r a t o r / g) ?. length , 1 ) ;
140- assert . doesNotMatch ( result , / # # # O u t p u t \n / ) ;
141- assert . match ( result , / # # # P e r f o r m a n c e / ) ;
143+ assert . doesNotMatch ( result , / \* \* O u t p u t : / ) ;
144+ assert . match ( result , / P e r f o r m a n c e e s t i m a t e / ) ;
142145 assert . doesNotMatch ( result , / b e n c h m a r k \. j s o n / ) ;
143146} ) ;
147+
148+ test ( 'comparators report added and removed output files' , async t => {
149+ const { base, head } = await createDirectories ( t ) ;
150+ const baseOutput = path . join ( base , 'generator' ) ;
151+ const headOutput = path . join ( head , 'generator' ) ;
152+
153+ await Promise . all ( [ mkdir ( baseOutput ) , mkdir ( headOutput ) ] ) ;
154+ await Promise . all ( [
155+ writeFile ( path . join ( baseOutput , 'removed.json' ) , '{"old":true}' , 'utf8' ) ,
156+ writeFile ( path . join ( headOutput , 'added.json' ) , '{"new":true}' , 'utf8' ) ,
157+ writeFile ( path . join ( head , 'comparison.txt' ) , '' , 'utf8' ) ,
158+ ] ) ;
159+
160+ const [ sizes , objects ] = await Promise . all ( [
161+ runComparator ( 'file-size' , base , head ) ,
162+ runComparator ( 'object-assertion' , base , head ) ,
163+ ] ) ;
164+
165+ assert . match ( sizes , / 2 f i l e s c h a n g e d / ) ;
166+ assert . match ( sizes , / ` g e n e r a t o r \/ a d d e d \. j s o n ` \| — \| 1 2 \. 0 0 B / ) ;
167+ assert . match ( sizes , / ` g e n e r a t o r \/ r e m o v e d \. j s o n ` \| 1 2 \. 0 0 B \| — / ) ;
168+ assert . match ( objects , / ` g e n e r a t o r \/ a d d e d \. j s o n ` a d d e d / ) ;
169+ assert . match ( objects , / ` g e n e r a t o r \/ r e m o v e d \. j s o n ` r e m o v e d / ) ;
170+ assert . doesNotMatch ( sizes , / c o m p a r i s o n \. t x t | 4 \. 0 0 K B / ) ;
171+ assert . doesNotMatch ( objects , / c o m p a r i s o n \. t x t / ) ;
172+ } ) ;
0 commit comments