@@ -27,7 +27,7 @@ addMediaTypePlugin("application/schema+yaml", {
27
27
fileMatcher : ( path ) => path . endsWith ( ".yaml" )
28
28
} ) ;
29
29
30
- /** @type (testDirectory: string) => AsyncGenerator<Json> */
30
+ /** @type (testDirectory: string) => AsyncGenerator<[string, Json] > */
31
31
const tests = async function * ( testDirectory ) {
32
32
for ( const file of await readdir ( testDirectory , { recursive : true , withFileTypes : true } ) ) {
33
33
if ( ! file . isFile ( ) || ! file . name . endsWith ( ".yaml" ) ) {
@@ -36,18 +36,21 @@ const tests = async function* (testDirectory) {
36
36
37
37
const testPath = join ( file . parentPath , file . name ) ;
38
38
const testJson = await readFile ( testPath , "utf8" ) ;
39
- yield YAML . parse ( testJson ) ;
39
+
40
+ yield [ testPath , YAML . parse ( testJson ) ] ;
40
41
}
41
42
} ;
42
43
43
44
/** @type (testDirectory: string) => Promise<void> */
44
45
const runTests = async ( testDirectory ) => {
45
- for await ( const test of tests ( testDirectory ) ) {
46
+ for await ( const [ name , test ] of tests ( testDirectory ) ) {
46
47
const instance = Instance . fromJs ( test ) ;
47
48
48
49
const result = interpret ( compiled , instance , BASIC ) ;
49
- //TODO: now result has errors array if valid is false
50
- // if (!result.valid) console.log(result)
50
+
51
+ if ( ! result . valid ) {
52
+ console . log ( "Failed:" , name , result . errors ) ;
53
+ }
51
54
}
52
55
} ;
53
56
@@ -100,7 +103,7 @@ const allKeywords = keywordLocations(compiled.ast);
100
103
const notCovered = allKeywords . filter ( ( location ) => ! visitedLocations . has ( location ) ) ;
101
104
console . log ( "NOT Covered:" , notCovered . length , "of" , allKeywords . length , ) ;
102
105
103
- const maxNotCovered = 10 ;
106
+ const maxNotCovered = 20 ;
104
107
const firstNotCovered = notCovered . slice ( 0 , maxNotCovered ) ;
105
108
if ( notCovered . length > maxNotCovered ) firstNotCovered . push ( "..." ) ;
106
109
console . log ( firstNotCovered ) ;
0 commit comments