Skip to content

Commit

Permalink
Fix serialization lint script and fix test data lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
obi1kenobi committed Jul 2, 2022
1 parent b8ed45c commit f7239ba
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 17 deletions.
22 changes: 17 additions & 5 deletions trustfall_core/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::{
use async_graphql_parser::{parse_query, parse_schema};
use itertools::Itertools;
use serde::{Deserialize, Serialize};
use trustfall_core::schema::error::InvalidSchemaError;
use trustfall_core::{interpreter::error::QueryArgumentsError, schema::error::InvalidSchemaError};

use crate::{
filesystem_interpreter::{FilesystemInterpreter, FilesystemToken},
Expand All @@ -36,7 +36,7 @@ use crate::{
Adapter,
},
nullables_interpreter::NullablesAdapter,
numbers_interpreter::NumbersAdapter,
numbers_interpreter::{NumbersAdapter, NumbersToken},
schema::Schema,
util::{
TestGraphQLQuery, TestIRQuery, TestIRQueryResult, TestInterpreterOutputTrace,
Expand Down Expand Up @@ -199,14 +199,26 @@ fn reserialize(path: &str) {
serialize_to_ron(&test_query_result)
}
Some((_, "trace")) => {
let test_trace: TestInterpreterOutputTrace<FilesystemToken> =
ron::from_str(&input_data).unwrap();
serialize_to_ron(&test_trace)
if let Ok(test_trace) =
ron::from_str::<TestInterpreterOutputTrace<NumbersToken>>(&input_data)
{
serialize_to_ron(&test_trace)
} else if let Ok(test_trace) =
ron::from_str::<TestInterpreterOutputTrace<FilesystemToken>>(&input_data)
{
serialize_to_ron(&test_trace)
} else {
unreachable!()
}
}
Some((_, "schema-error")) => {
let schema_error: InvalidSchemaError = ron::from_str(&input_data).unwrap();
serialize_to_ron(&schema_error)
}
Some((_, "exec-error")) => {
let exec_error: QueryArgumentsError = ron::from_str(&input_data).unwrap();
serialize_to_ron(&exec_error)
}
Some((_, ext)) => unreachable!("{}", ext),
None => unreachable!("{}", path),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ Ok(TestIRQuery(
},
),
arguments: {
"substr": Int64(4),
"num": String("four"),
"min": Int64(0),
"num": String("four"),
"substr": Int64(4),
},
))
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Ok(TestIRQuery(
edge_name: "successor",
recursive: Some(Recursive(
depth: 3,
coerce_to: None,
)),
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2336,7 +2336,6 @@ TestInterpreterOutputTrace(
edge_name: "successor",
recursive: Some(Recursive(
depth: 3,
coerce_to: None,
)),
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Ok(TestIRQuery(
edge_name: "successor",
recursive: Some(Recursive(
depth: 3,
coerce_to: None,
)),
),
Eid(2): IREdge(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3935,7 +3935,6 @@ TestInterpreterOutputTrace(
edge_name: "successor",
recursive: Some(Recursive(
depth: 3,
coerce_to: None,
)),
),
Eid(2): IREdge(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Ok(TestIRQuery(
edge_name: "successor",
recursive: Some(Recursive(
depth: 3,
coerce_to: None,
)),
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,6 @@ TestInterpreterOutputTrace(
edge_name: "successor",
recursive: Some(Recursive(
depth: 3,
coerce_to: None,
)),
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Ok(TestIRQuery(
edge_name: "successor",
recursive: Some(Recursive(
depth: 3,
coerce_to: None,
)),
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2064,7 +2064,6 @@ TestInterpreterOutputTrace(
edge_name: "successor",
recursive: Some(Recursive(
depth: 3,
coerce_to: None,
)),
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Ok(TestIRQuery(
edge_name: "successor",
recursive: Some(Recursive(
depth: 3,
coerce_to: None,
)),
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,6 @@ TestInterpreterOutputTrace(
edge_name: "successor",
recursive: Some(Recursive(
depth: 3,
coerce_to: None,
)),
),
},
Expand Down

0 comments on commit f7239ba

Please sign in to comment.