Skip to content

Commit

Permalink
Minor annoyances with Amber tests (#612)
Browse files Browse the repository at this point in the history
* Make postprocessors optional in integration tests.

* Move import validity test files to subdirectory.

* Rename integration test function.

* Rename test file as requested.
  • Loading branch information
hdwalters authored Nov 23, 2024
1 parent 366e397 commit 82e496d
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 23 deletions.
27 changes: 9 additions & 18 deletions src/tests/postprocessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,18 @@ use crate::tests::eval_bash;
use super::compile_code;

#[test]
fn default_ok() {
let default = PostProcessor::get_default();

fn test_each_installed_postprocessor() {
let hello = "echo \"Hello world!\"";
let hello = compile_code(hello);

let mut unavailable = vec![];

for processor in &default {
if ! processor.is_available() {
unavailable.push(processor.name.clone());
let processors = PostProcessor::get_default();
for processor in processors {
if processor.is_available() {
let res = processor.execute(hello.clone());
assert!(res.is_ok(), "Postprocessor {} couldn't process hello world", processor.name);
let res = res.unwrap();
let (stdout, _) = eval_bash(res);
assert_eq!(stdout, "Hello world!");
}
}

assert!(unavailable.is_empty(), "These commands have to be in $PATH for this test to pass: {}", unavailable.join(", "));

for processor in default {
let res = processor.execute(hello.clone());
assert!(res.is_ok(), "Postprocessor {} couldn't process hello world", processor.name);
let res = res.unwrap();
let (stdout, _) = eval_bash(res);
assert_eq!(stdout, "Hello world!");
}
}
5 changes: 3 additions & 2 deletions src/tests/validity/import_existing_file.ab
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import * from "test_files/str/trim.ab"
echo trim(" Succeeded ")
import * from "src/tests/validity/test_files/str/trim.ab"

echo trim(" Succeeded ")
2 changes: 1 addition & 1 deletion src/tests/validity/import_existing_nested_file.ab
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * from "test_files/is_even.ab"
import * from "src/tests/validity/test_files/is_even.ab"

// Output
// even
Expand Down
3 changes: 3 additions & 0 deletions src/tests/validity/import_transitive_file.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * from "src/tests/validity/test_files/is_even.ab"

echo trim(" Succeeded ")
2 changes: 0 additions & 2 deletions src/tests/validity/public_import.ab

This file was deleted.

File renamed without changes.
File renamed without changes.

0 comments on commit 82e496d

Please sign in to comment.