mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-25 11:12:48 +03:00
absolute path for parser tests
This commit is contained in:
parent
b60affc40b
commit
2a616eb13d
@ -14,7 +14,10 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use std::{fs, path::Path};
|
||||
use std::{
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use crate::SyntaxError;
|
||||
|
||||
@ -42,7 +45,9 @@ pub fn parser_pass_tests() {
|
||||
let mut pass = 0;
|
||||
let mut fail = vec![];
|
||||
let mut tests = vec![];
|
||||
find_tests("../tests/pass/parse/", &mut tests);
|
||||
let mut test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
test_dir.push("../tests/pass/parse/");
|
||||
find_tests(&test_dir, &mut tests);
|
||||
for (path, content) in tests.into_iter() {
|
||||
match crate::parse(&path, &content) {
|
||||
Ok(_) => {
|
||||
@ -73,7 +78,9 @@ pub fn parser_fail_tests() {
|
||||
let mut pass = 0;
|
||||
let mut fail = vec![];
|
||||
let mut tests = vec![];
|
||||
find_tests("../tests/fail/parse/", &mut tests);
|
||||
let mut test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
test_dir.push("../tests/fail/parse/");
|
||||
find_tests(&test_dir, &mut tests);
|
||||
for (path, content) in tests.into_iter() {
|
||||
match crate::parse(&path, &content) {
|
||||
Ok(_) => {
|
||||
|
@ -4,9 +4,9 @@
|
||||
"imports": [],
|
||||
"circuits": {},
|
||||
"functions": {
|
||||
"{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"./tests/serialization/main.leo\\\"}\"}": {
|
||||
"{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"test\\\"}\"}": {
|
||||
"annotations": [],
|
||||
"identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"./tests/serialization/main.leo\\\"}\"}",
|
||||
"identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"test\\\"}\"}",
|
||||
"input": [],
|
||||
"output": null,
|
||||
"block": {
|
||||
@ -24,7 +24,7 @@
|
||||
"line_stop": 2,
|
||||
"col_start": 12,
|
||||
"col_stop": 13,
|
||||
"path": "./tests/serialization/main.leo"
|
||||
"path": "test"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -38,7 +38,7 @@
|
||||
"line_stop": 2,
|
||||
"col_start": 16,
|
||||
"col_stop": 17,
|
||||
"path": "./tests/serialization/main.leo"
|
||||
"path": "test"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -49,7 +49,7 @@
|
||||
"line_stop": 2,
|
||||
"col_start": 12,
|
||||
"col_stop": 17,
|
||||
"path": "./tests/serialization/main.leo"
|
||||
"path": "test"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -58,7 +58,7 @@
|
||||
"line_stop": 2,
|
||||
"col_start": 5,
|
||||
"col_stop": 17,
|
||||
"path": "./tests/serialization/main.leo"
|
||||
"path": "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -68,7 +68,7 @@
|
||||
"line_stop": 3,
|
||||
"col_start": 17,
|
||||
"col_stop": 2,
|
||||
"path": "./tests/serialization/main.leo"
|
||||
"path": "test"
|
||||
}
|
||||
},
|
||||
"span": {
|
||||
@ -76,7 +76,7 @@
|
||||
"line_stop": 3,
|
||||
"col_start": 1,
|
||||
"col_stop": 2,
|
||||
"path": "./tests/serialization/main.leo"
|
||||
"path": "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ fn to_ast(program_filepath: &Path) -> Result<Ast, SyntaxError> {
|
||||
let program_string = std::fs::read_to_string(program_filepath).expect("failed to open test");
|
||||
|
||||
// Parses the Leo file and constructs a leo ast.
|
||||
leo_parser::parse_ast(&program_filepath.to_str().unwrap(), &program_string)
|
||||
leo_parser::parse_ast("test", &program_string)
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -33,7 +33,8 @@ fn to_ast(program_filepath: &Path) -> Result<Ast, SyntaxError> {
|
||||
fn test_serialize() {
|
||||
// Construct an ast from the given test file.
|
||||
let ast = {
|
||||
let program_filepath = PathBuf::from("./tests/serialization/main.leo");
|
||||
let mut program_filepath = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
program_filepath.push("tests/serialization/main.leo");
|
||||
|
||||
to_ast(&program_filepath).unwrap()
|
||||
};
|
||||
@ -52,7 +53,8 @@ fn test_serialize() {
|
||||
fn test_deserialize() {
|
||||
// Load the expected ast.
|
||||
let expected_ast = {
|
||||
let program_filepath = PathBuf::from("./tests/serialization/main.leo");
|
||||
let mut program_filepath = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
program_filepath.push("tests/serialization/main.leo");
|
||||
|
||||
to_ast(&program_filepath).unwrap()
|
||||
};
|
||||
@ -68,7 +70,8 @@ fn test_deserialize() {
|
||||
fn test_serialize_deserialize_serialize() {
|
||||
// Construct an ast from the given test file.
|
||||
let ast = {
|
||||
let program_filepath = PathBuf::from("./tests/serialization/main.leo");
|
||||
let mut program_filepath = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
program_filepath.push("tests/serialization/main.leo");
|
||||
|
||||
to_ast(&program_filepath).unwrap()
|
||||
};
|
||||
@ -88,7 +91,8 @@ fn test_serialize_deserialize_serialize() {
|
||||
#[test]
|
||||
fn test_generic_parser_error() {
|
||||
let error_result = {
|
||||
let program_filepath = PathBuf::from("./tests/serialization/parser_error.leo");
|
||||
let mut program_filepath = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
program_filepath.push("tests/serialization/parser_error.leo");
|
||||
|
||||
to_ast(&program_filepath)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user