Skip to content

Commit 15456b9

Browse files
committed
Bump version no to 0.3.0
- Do proper test cleanup
1 parent 1dc16a8 commit 15456b9

4 files changed

Lines changed: 27 additions & 16 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "mamba"
3-
version = "0.2.2"
4-
authors = ["Joel Abrahams <abrahamsjo@gmail.com>"]
5-
description = "A transpiler which translates Mamba to Python 3 files"
3+
version = "0.3.0"
4+
authors = ["Joël Abrahams <abrahamsjo@gmail.com>"]
5+
description = "A transpiler which converts Mamba files to Python 3 files"
66
edition = "2018"
77
license-file = "LICENSE"
88

tests/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::path::PathBuf;
99
use python_parser::ast::Statement;
1010
use tempfile::tempdir_in;
1111

12-
pub fn resource_content_path(path: &String) -> String {
12+
pub fn resource_content_path(path: &str) -> String {
1313
match File::open(path) {
1414
Ok(mut path) => {
1515
let mut content = String::new();

tests/output/mod.rs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use mamba::pipeline::transpile_directory;
66
use crate::common::{delete_dir, python_src_to_stmts, resource_content, resource_content_path,
77
resource_content_randomize, resource_path};
88
use crate::output::common::PYTHON;
9+
use python_parser::ast::Statement;
910

1011
mod common;
1112

@@ -17,21 +18,32 @@ fn test_directory(
1718
_output: &[&str],
1819
file_name: &str
1920
) -> Result<(), Vec<String>> {
20-
let current_dir_string = resource_path(valid, input, "");
21-
let current_dir = Path::new(&current_dir_string);
2221
let (output_path, output_file) =
2322
resource_content_randomize(true, input, &format!("{}.py", file_name));
2423

24+
let res = fallable(valid, input, &output_path, &output_file, file_name);
25+
delete_dir(&output_path).map_err(|_| vec![])?;
26+
let (check_ast, out_ast) = res?;
27+
assert_eq!(check_ast, out_ast);
28+
Ok(())
29+
}
30+
31+
fn fallable(
32+
valid: bool,
33+
input: &[&str],
34+
output_path: &str,
35+
output_file: &str,
36+
file_name: &str
37+
) -> Result<(Vec<Statement>, Vec<Statement>), Vec<String>> {
38+
let current_dir_string = resource_path(valid, input, "");
39+
let current_dir = Path::new(&current_dir_string);
40+
2541
let map_err = |(ty, msg): &(String, String)| {
2642
eprintln!("[error | {}] {}", ty, msg);
2743
format!("[error | {}] {}", ty, msg)
2844
};
29-
transpile_directory(
30-
&current_dir,
31-
Some(&format!("{}.mamba", file_name)),
32-
Some(output_path.as_str())
33-
)
34-
.map_err(|errs| errs.iter().map(&map_err).collect::<Vec<String>>())?;
45+
transpile_directory(&current_dir, Some(&format!("{}.mamba", file_name)), Some(output_path))
46+
.map_err(|errs| errs.iter().map(&map_err).collect::<Vec<String>>())?;
3547

3648
let cmd = Command::new(PYTHON).arg("-m").arg("py_compile").arg(&output_file).output().unwrap();
3749
if cmd.status.code().unwrap() != 0 {
@@ -40,8 +52,7 @@ fn test_directory(
4052

4153
let check_src = resource_content(true, input, &format!("{}_check.py", file_name));
4254
let check_ast = python_src_to_stmts(&check_src);
43-
let out_ast = python_src_to_stmts(&resource_content_path(&output_file));
55+
let out_ast = python_src_to_stmts(&resource_content_path(output_file));
4456

45-
assert_eq!(out_ast, check_ast);
46-
delete_dir(&output_path).map_err(|_| vec![])
57+
Ok((check_ast, out_ast))
4758
}

0 commit comments

Comments
 (0)