@@ -364,10 +364,10 @@ function hasCheck(content, checkName) {
364364 return content . startsWith ( `const ${ checkName } ` ) || content . includes ( `\nconst ${ checkName } ` ) ;
365365}
366366
367- async function runChecks ( testFile , doSearch , parseQuery ) {
367+ async function runChecks ( testFile , doSearch , parseQuery , revision ) {
368368 let checkExpected = false ;
369369 let checkParsed = false ;
370- let testFileContent = readFile ( testFile ) ;
370+ let testFileContent = `const REVISION = " ${ revision } ";\n ${ readFile ( testFile ) } ` ;
371371
372372 if ( testFileContent . indexOf ( "FILTER_CRATE" ) !== - 1 ) {
373373 testFileContent += "exports.FILTER_CRATE = FILTER_CRATE;" ;
@@ -548,13 +548,15 @@ function parseOptions(args) {
548548 "doc_folder" : "" ,
549549 "test_folder" : "" ,
550550 "test_file" : [ ] ,
551+ "revision" : "" ,
551552 } ;
552553 const correspondences = {
553554 "--resource-suffix" : "resource_suffix" ,
554555 "--doc-folder" : "doc_folder" ,
555556 "--test-folder" : "test_folder" ,
556557 "--test-file" : "test_file" ,
557558 "--crate-name" : "crate_name" ,
559+ "--revision" : "revision" ,
558560 } ;
559561
560562 for ( let i = 0 ; i < args . length ; ++ i ) {
@@ -611,15 +613,15 @@ async function main(argv) {
611613 if ( opts [ "test_file" ] . length !== 0 ) {
612614 for ( const file of opts [ "test_file" ] ) {
613615 process . stdout . write ( `Testing ${ file } ... ` ) ;
614- errors += await runChecks ( file , doSearch , parseAndSearch . parseQuery ) ;
616+ errors += await runChecks ( file , doSearch , parseAndSearch . parseQuery , opts . revision ) ;
615617 }
616618 } else if ( opts [ "test_folder" ] . length !== 0 ) {
617619 for ( const file of fs . readdirSync ( opts [ "test_folder" ] ) ) {
618620 if ( ! file . endsWith ( ".js" ) ) {
619621 continue ;
620622 }
621623 process . stdout . write ( `Testing ${ file } ... ` ) ;
622- errors += await runChecks ( path . join ( opts [ "test_folder" ] , file ) , doSearch ,
624+ errors += await runChecks ( path . join ( opts [ "test_folder" ] , file , "" ) , doSearch ,
623625 parseAndSearch . parseQuery ) ;
624626 }
625627 }
0 commit comments