Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/mixin-cargo-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,28 @@ jobs:
- name: Run unit tests with coverage
run: cargo llvm-cov nextest --lib --workspace --codecov --output-path codecov-unittests.json

- name: Run regression tests with coverage
env:
CI: true
run: cargo llvm-cov nextest --test 'regression' --codecov --output-path codecov-regression.json

- name: Run doctests
run: cargo test --workspace --doc

- name: Upload coverage to Codecov
- name: Upload unit coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: BraneFramework/brane
flags: tests,unit-tests
files: codecov-unittests.json
fail_ci_if_error: true

- name: Upload regression coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: BraneFramework/brane
flags: tests,regression-tests
files: codecov-regression.json
fail_ci_if_error: true
27 changes: 27 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions brane-dsl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ serde = "1.0.204"
brane-shr = { path = "../brane-shr" }
specifications = { path = "../specifications" }

[dev-dependencies]
insta = { version = "1.42.2", features=["yaml"] }

[lints]
workspace = true
65 changes: 0 additions & 65 deletions brane-dsl/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,71 +26,6 @@ use crate::scanner::{self, Span, Token, Tokens};
use crate::spec::Language;


/***** TESTS *****/
#[cfg(test)]
pub mod tests {
use brane_shr::utilities::{create_package_index, test_on_dsl_files};

use super::*;


/// Tests BraneScript files.
#[test]
fn test_bscript() {
// Simply pass to the compiler
test_on_dsl_files("BraneScript", |path, code| {
// Print the header always
println!("{}", (0..80).map(|_| '-').collect::<String>());
println!("File '{}' gave us:", path.display());

// Read the package index
let pindex: PackageIndex = create_package_index();

// Create a compiler and compile it;
let res: Program = match parse(code, &pindex, &ParserOptions::bscript()) {
Ok(res) => res,
Err(err) => {
panic!("Failed to parse BraneScript file '{}': {}", path.display(), err);
},
};

// Print it for good measure
println!("{res:#?}");
println!("{}\n\n", (0..80).map(|_| '-').collect::<String>());
});
}

/// Tests Bakery files.
#[test]
fn test_bakery() {
// Simply pass to the compiler
test_on_dsl_files("Bakery", |path, code| {
// Print the header always
println!("{}", (0..80).map(|_| '-').collect::<String>());
println!("File '{}' gave us:", path.display());

// Read the package index
let pindex: PackageIndex = create_package_index();

// Create a compiler and compile it;
let res: Program = match parse(code, &pindex, &ParserOptions::bakery()) {
Ok(res) => res,
Err(err) => {
panic!("Failed to parse Bakery file '{}': {}", path.display(), err);
},
};

// Print it for good measure
println!("{res:#?}");
println!("{}\n\n", (0..80).map(|_| '-').collect::<String>());
});
}
}





/***** AUXILLARY STRUCTS *****/
/// Defines options that configure the compiler before we use it.
#[derive(Clone, Debug)]
Expand Down
44 changes: 44 additions & 0 deletions brane-dsl/tests/regression.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use brane_dsl::{ParserOptions, parse};
use brane_shr::utilities::{create_package_index, test_on_dsl_files};


/// Tests BraneScript files.
#[test]
fn test_bscript() {
// Simply pass to the compiler
test_on_dsl_files("BraneScript", |path, code| {
// Read the package index
let pindex = create_package_index();

// Create a compiler and compile it;
let res = match parse(code, &pindex, &ParserOptions::bscript()) {
Ok(res) => res,
Err(err) => {
panic!("Failed to parse BraneScript file '{}': {}", path.display(), err);
},
};

insta::assert_debug_snapshot!(path.as_os_str().to_str().expect("Invalid test name"), res);
});
}


/// Tests Bakery files.
#[test]
fn test_bakery() {
// Simply pass to the compiler
test_on_dsl_files("Bakery", |path, code| {
// Read the package index
let pindex = create_package_index();

// Create a compiler and compile it;
let res = match parse(code, &pindex, &ParserOptions::bakery()) {
Ok(res) => res,
Err(err) => {
panic!("Failed to parse Bakery file '{}': {}", path.display(), err);
},
};

insta::assert_debug_snapshot!(path.as_os_str().to_str().expect("Invalid test name"), res);
});
}
Loading
Loading