Skip to content

Commit

Permalink
Add fuel test and benchmarks for empty scripts (#825)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcharles authored Nov 15, 2024
1 parent 9791864 commit 34f8dea
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
14 changes: 12 additions & 2 deletions crates/cli/benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ pub fn criterion_benchmark(c: &mut Criterion) {
let mut function_cases = vec![];
for linking in [Linking::Static, Linking::Dynamic] {
for compilation in [Compilation::JustInTime, Compilation::AheadOfTime] {
function_cases.push(
FunctionCase::new(
Path::new("benches/functions/empty"),
Path::new("index.js"),
&compilation,
linking,
)
.unwrap(),
);
function_cases.push(
FunctionCase::new(
Path::new("benches/functions/simple_discount"),
Expand Down Expand Up @@ -182,13 +191,14 @@ pub fn criterion_benchmark(c: &mut Criterion) {

fn execute_javy(index_js: &Path, wasm: &Path, linking: &Linking) -> Result<()> {
let mut args = vec![
"compile",
"build",
index_js.to_str().unwrap(),
"-o",
wasm.to_str().unwrap(),
];
if let Linking::Dynamic = linking {
args.push("-d");
args.push("-C");
args.push("dynamic");
}
let status_code = Command::new(Path::new("../../target/release/javy").to_str().unwrap())
.args(args)
Expand Down
Empty file.
Empty file.
9 changes: 9 additions & 0 deletions crates/cli/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ use wasmtime::{AsContextMut, Engine, Linker, Module, Store};

use javy_test_macros::javy_cli_test;

#[javy_cli_test]
fn test_empty(builder: &mut Builder) -> Result<()> {
let mut runner = builder.input("empty.js").build()?;

let (_, _, fuel_consumed) = run(&mut runner, &[]);
assert_fuel_consumed_within_threshold(22_590, fuel_consumed);
Ok(())
}

#[javy_cli_test]
fn test_identity(builder: &mut Builder) -> Result<()> {
let mut runner = builder.build()?;
Expand Down
Empty file.

0 comments on commit 34f8dea

Please sign in to comment.