@@ -11,7 +11,15 @@ import * as testAntlrFormat from "./test-antlr-format.js";
1111import * as testVariantCoverage from "./test-variant-coverage.js" ;
1212import { shouldThrowOnFormat } from "./utilities.js" ;
1313
14- async function testFixture ( fixture ) {
14+ /**
15+ @import {Fixture} from "./get-fixtures.js"
16+ @typedef {ReturnType<getTestCase> } TestCase
17+ */
18+
19+ /**
20+ @param {Fixture } fixture
21+ */
22+ function testFixture ( fixture ) {
1523 const { name, context } = fixture ;
1624 const { stringifiedOptions, parsers } = context ;
1725
@@ -40,94 +48,109 @@ async function testFixture(fixture) {
4048 return name ;
4149 } ,
4250 test : {
43- run : ( testCase ) => testFormat . run ( testCase , testCaseForSnapshot ) ,
51+ run : ( testCase , name ) =>
52+ testFormat . run ( testCase , name , testCaseForSnapshot ) ,
4453 } ,
4554 } ,
4655 {
4756 name : "ast compare" ,
48- test : { run : testAstCompare . run } ,
57+ test : { run : testAstCompare . run , skip : testAstCompare . skip } ,
4958 skip : ( ) => ! FULL_TEST ,
5059 } ,
5160 // The following cases only need run on main parser
5261 {
5362 name : "second format" ,
54- test : { run : testSecondFormat . run } ,
63+ test : { run : testSecondFormat . run , skip : testSecondFormat . skip } ,
5564 skip : ( testCase ) => ! FULL_TEST || testCase !== testCaseForSnapshot ,
5665 } ,
5766 {
5867 name : "end of line (CRLF)" ,
59- test : { run : ( testCase ) => testEndOfLine . run ( testCase , "\r\n" ) } ,
68+ test : {
69+ run : ( testCase , name ) => testEndOfLine . run ( testCase , name , "\r\n" ) ,
70+ skip : testEndOfLine . skip ,
71+ } ,
6072 skip : ( testCase ) => ! FULL_TEST || testCase !== testCaseForSnapshot ,
6173 } ,
6274 {
6375 name : "end of line (CR)" ,
64- test : { run : ( testCase ) => testEndOfLine . run ( testCase , "\r" ) } ,
76+ test : {
77+ run : ( testCase , name ) => testEndOfLine . run ( testCase , name , "\r" ) ,
78+ skip : testEndOfLine . skip ,
79+ } ,
6580 skip : ( testCase ) => ! FULL_TEST || testCase !== testCaseForSnapshot ,
6681 } ,
6782 {
6883 name : "BOM" ,
69- test : { run : testBom . run } ,
84+ test : { run : testBom . run , skip : testBom . skip } ,
7085 skip : ( testCase ) => ! FULL_TEST || testCase !== testCaseForSnapshot ,
7186 } ,
7287 // The following cases only need run if the parser is Slang
7388 {
7489 name : "ANTLR format" ,
75- test : { run : testAntlrFormat . run } ,
90+ test : { run : testAntlrFormat . run , skip : testAntlrFormat . skip } ,
7691 skip : ( testCase ) =>
7792 ! FULL_TEST ||
7893 testCase !== testCaseForSnapshot ||
7994 testCase . parser !== "slang" ,
8095 } ,
8196 {
8297 name : "bytecode comparison" ,
83- test : { run : testBytecodeCompare . run } ,
98+ test : { run : testBytecodeCompare . run , skip : testBytecodeCompare . skip } ,
8499 skip : ( testCase ) =>
85100 ! FULL_TEST ||
86101 testCase !== testCaseForSnapshot ||
87102 testCase . parser !== "slang" ,
88103 } ,
89104 {
90105 name : "variant coverage" ,
91- test : { run : testVariantCoverage . run } ,
106+ test : { run : testVariantCoverage . run , skip : testVariantCoverage . skip } ,
92107 skip : ( testCase ) =>
93108 ! FULL_TEST ||
94109 testCase !== testCaseForSnapshot ||
95110 testCase . parser !== "slang" ,
96111 } ,
97112 ] ) {
98113 for ( const testCase of testCases ) {
99- if ( functionality . skip ?. ( testCase ) ) {
114+ if (
115+ functionality . skip ?. ( testCase ) ||
116+ functionality . test . skip ?. ( testCase )
117+ ) {
100118 continue ;
101119 }
120+
102121 let { name } = functionality ;
103122 if ( typeof name === "function" ) {
104123 name = name ( testCase ) ;
105124 } else if ( hasMultipleParsers ) {
106125 name += ` [${ testCase . parser } ]` ;
107126 }
108- test ( name , async ( ) => {
109- await functionality . test . run ( testCase ) ;
110- } ) ;
127+
128+ functionality . test . run ( testCase , name ) ;
111129 }
112130 }
113131 } ) ;
114132}
115133
134+ /**
135+ @param {Fixture } fixture
136+ @param {string } parser
137+ */
116138function getTestCase ( fixture , parser ) {
117139 const { code : originalText , context, filepath } = fixture ;
118140
119141 const { text : code , options : formatOptions } = replacePlaceholders (
120142 originalText ,
121143 {
122144 printWidth : 80 ,
123- ...context . options ,
124145 filepath,
146+ ...context . options ,
125147 parser,
126148 } ,
127149 ) ;
128150
129151 const expectFail = shouldThrowOnFormat ( fixture , formatOptions ) ;
130152
153+ /** @type {ReturnType<format> | undefined } */
131154 let promise ;
132155
133156 return {
0 commit comments