Skip to content

Commit

Permalink
Remove the ir_to_asm unit tests. (FuelLabs#3074)
Browse files Browse the repository at this point in the history
Remove the `ir_to_asm` unit tests, replace them with equivalent `sway/test/src/ir_generation` tests (when necessary).
  • Loading branch information
otrho authored Oct 20, 2022
1 parent dd2104e commit a6cd2b5
Show file tree
Hide file tree
Showing 67 changed files with 110 additions and 2,551 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion sway-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ im = "15.0"
itertools = "0.10"
lazy_static = "1.4"
petgraph = "0.6"
prettydiff = "0.5"
serde = { version = "1.0", features = ["derive"] }
sha2 = "0.9"
smallvec = "1.7"
Expand Down
64 changes: 0 additions & 64 deletions sway-core/src/asm_generation/from_ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,67 +237,3 @@ pub(crate) fn aggregate_idcs_to_field_layout(
_otherwise => panic!("Attempt to access field in non-aggregate."),
})
}

// -------------------------------------------------------------------------------------------------

#[cfg(test)]
mod tests {
use super::*;
use sway_ir::parser::parse;

use std::path::PathBuf;

#[test]
fn ir_to_asm_tests() {
let manifest_dir = env!("CARGO_MANIFEST_DIR");
let dir: PathBuf = format!("{}/tests/ir_to_asm", manifest_dir).into();
for entry in std::fs::read_dir(dir).unwrap() {
// We're only interested in the `.sw` files here.
let path = entry.unwrap().path();
match path.extension().unwrap().to_str() {
Some("ir") => {
//
// Run the tests!
//
println!("---- IR To ASM: {:?} ----", path);
test_ir_to_asm(path);
}
Some("asm") | Some("disabled") => (),
_ => panic!(
"File with invalid extension in tests dir: {:?}",
path.file_name().unwrap_or(path.as_os_str())
),
}
}
}

fn test_ir_to_asm(mut path: PathBuf) {
let input_bytes = std::fs::read(&path).unwrap();
let input = String::from_utf8_lossy(&input_bytes);

path.set_extension("asm");

let expected_bytes = std::fs::read(&path).unwrap();
let expected = String::from_utf8_lossy(&expected_bytes);

let ir = parse(&input).expect("parsed ir");
let asm_result = compile_ir_to_asm(&ir, None);

let mut warnings = Vec::new();
let mut errors = Vec::new();
let asm = asm_result.unwrap(&mut warnings, &mut errors);
assert!(warnings.is_empty() && errors.is_empty());

let asm_script = format!("{}", asm);
if asm_script != expected {
print!(
"{}\n{}",
path.display(),
prettydiff::diff_lines(&expected, &asm_script)
);
panic!();
}
}
}

// =================================================================================================
23 changes: 0 additions & 23 deletions sway-core/tests/ir_to_asm/bigger_asm_block.asm

This file was deleted.

22 changes: 0 additions & 22 deletions sway-core/tests/ir_to_asm/bigger_asm_block.ir

This file was deleted.

46 changes: 0 additions & 46 deletions sway-core/tests/ir_to_asm/binops.asm

This file was deleted.

66 changes: 0 additions & 66 deletions sway-core/tests/ir_to_asm/binops.ir

This file was deleted.

87 changes: 0 additions & 87 deletions sway-core/tests/ir_to_asm/enum_in_storage_read.asm

This file was deleted.

54 changes: 0 additions & 54 deletions sway-core/tests/ir_to_asm/enum_in_storage_read.ir

This file was deleted.

Loading

0 comments on commit a6cd2b5

Please sign in to comment.