@@ -30,16 +30,30 @@ pub enum Error {
3030 } ,
3131
3232 #[ error( "validation passed, but should have failed" ) ]
33- ExpectedValidationFail { doc : Document , mutation : String } ,
33+ SchemaExpectedValidationFail { doc : Document , mutation : String } ,
3434
3535 #[ error( "the serialized AST did not round trip to an identical AST" ) ]
3636 SerializationInconsistency { original : Document , new : Document } ,
3737
3838 #[ error( "parse error" ) ]
3939 Parse ( WithErrors < Document > ) ,
4040
41+ #[ error( "validation passed, but should have failed" ) ]
42+ ExecutableExpectedValidationFail {
43+ schema : Valid < Schema > ,
44+ doc : Document ,
45+ mutation : String
46+ } ,
47+
4148 #[ error( "reparse error" ) ]
42- Reparse {
49+ SchemaReparse {
50+ doc : Document ,
51+ errors : WithErrors < Document > ,
52+ } ,
53+
54+ #[ error( "reparse error" ) ]
55+ ExecutableReparse {
56+ schema : Valid < Schema > ,
4357 doc : Document ,
4458 errors : WithErrors < Document > ,
4559 } ,
@@ -67,12 +81,13 @@ pub fn generate_schema_document(u: &mut Unstructured) -> Result<Document, Error>
6781 continue ;
6882 }
6983
84+
7085 // Now let's validate that the schema says it's OK
7186 match ( mutation. is_valid ( ) , new_doc. to_schema_validate ( ) ) {
7287 ( true , Ok ( new_schema) ) => {
7388 // Let's reparse the document to check that it can be parsed
7489 let reparsed = Document :: parse ( new_doc. to_string ( ) , PathBuf :: from ( "synthetic" ) )
75- . map_err ( |e| Error :: Reparse {
90+ . map_err ( |e| Error :: SchemaReparse {
7691 doc : new_doc. clone ( ) ,
7792 errors : e,
7893 } ) ?;
@@ -87,7 +102,6 @@ pub fn generate_schema_document(u: &mut Unstructured) -> Result<Document, Error>
87102
88103 // Let's try and create an executable document from the schema
89104 generate_executable_document ( u, & new_schema) ?;
90-
91105 schema = new_schema. into_inner ( ) ;
92106 doc = new_doc;
93107 continue ;
@@ -99,7 +113,7 @@ pub fn generate_schema_document(u: &mut Unstructured) -> Result<Document, Error>
99113 } ) ;
100114 }
101115 ( false , Ok ( _) ) => {
102- return Err ( Error :: ExpectedValidationFail {
116+ return Err ( Error :: SchemaExpectedValidationFail {
103117 doc : new_doc,
104118 mutation : mutation. type_name ( ) . to_string ( ) ,
105119 } ) ;
@@ -119,7 +133,7 @@ pub(crate) fn generate_executable_document(
119133) -> Result < Document , Error > {
120134 let mut doc = Document :: new ( ) ;
121135 let mutations = mutations:: executable_document_mutations ( ) ;
122- for _ in 0 ..1000 {
136+ for count in 0 ..1000 {
123137 if u. len ( ) == 0 {
124138 // We ran out of data abort. This is not an error
125139 return Err ( Error :: Arbitrary ( arbitrary:: Error :: NotEnoughData ) ) ?;
@@ -133,12 +147,12 @@ pub(crate) fn generate_executable_document(
133147 }
134148
135149 // Now let's validate that the schema says it's OK
136-
137150 match ( mutation. is_valid ( ) , new_doc. to_executable_validate ( schema) ) {
138151 ( true , Ok ( _) ) => {
139152 // Let's reparse the document to check that it can be parsed
140153 let reparsed = Document :: parse ( new_doc. to_string ( ) , PathBuf :: from ( "synthetic" ) )
141- . map_err ( |e| Error :: Reparse {
154+ . map_err ( |e| Error :: ExecutableReparse {
155+ schema : schema. clone ( ) ,
142156 doc : new_doc. clone ( ) ,
143157 errors : e,
144158 } ) ?;
@@ -162,7 +176,7 @@ pub(crate) fn generate_executable_document(
162176 } ) ;
163177 }
164178 ( false , Ok ( _) ) => {
165- return Err ( Error :: ExpectedValidationFail {
179+ return Err ( Error :: SchemaExpectedValidationFail {
166180 doc : new_doc,
167181 mutation : mutation. type_name ( ) . to_string ( ) ,
168182 } ) ;
0 commit comments