Skip to content

Commit

Permalink
Added an integration test with a rune containing a hyphen in its name
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-F-Bryan committed May 12, 2021
1 parent ee67de7 commit e60859f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
2 changes: 1 addition & 1 deletion codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn generate(c: Compilation) -> Result<Vec<u8>, Error> {
.join("target")
.join("wasm32-unknown-unknown")
.join(build_dir)
.join(&generator.name)
.join(generator.name.replace("-", "_"))
.with_extension("wasm");

std::fs::read(&wasm)
Expand Down
42 changes: 36 additions & 6 deletions codegen/tests/smoke_test.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
use std::path::{Path, PathBuf};

use rune_codegen::{Compilation, RuneProject};
use rune_syntax::Diagnostics;
use rune_syntax::{Diagnostics, hir::Rune};
use tempfile::TempDir;

#[test]
fn we_can_compile_the_sine_example() {
let runefile = include_str!("../../examples/sine/Runefile");
let parsed = rune_syntax::parse(runefile).unwrap();
fn load_runefile(src: &str) -> Rune {
let parsed = rune_syntax::parse(src).unwrap();

let mut diags = Diagnostics::new();
let rune = rune_syntax::analyse(&parsed, &mut diags);
assert!(!diags.has_errors(), "{:?}", diags);

rune
}

#[test]
fn we_can_compile_the_sine_example() {
let rune = load_runefile(include_str!("../../examples/sine/Runefile"));

let temp = TempDir::new().unwrap();
let sine_dir = project_root().join("examples").join("sine");

Expand All @@ -36,6 +40,32 @@ fn we_can_compile_the_sine_example() {
}
}

#[test]
fn paths_can_contain_hyphens() {
let rune = load_runefile("FROM runicos/base\n");

let temp = TempDir::new().unwrap();

let compilation = Compilation {
name: String::from("hyphen-ated"),
rune,
current_directory: temp.path().join("path-with-hyphens"),
working_directory: temp.path().join("build"),
optimized: false,
rune_project: RuneProject::Disk(
Path::new(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap()
.to_path_buf(),
),
};

if let Err(e) = rune_codegen::generate(compilation) {
let path = temp.into_path();
panic!("Unable to compile in \"{}\": {}", path.display(), e);
}
}

fn project_root() -> PathBuf {
let path = Path::new(env!("CARGO_MANIFEST_DIR"));

Expand Down

0 comments on commit e60859f

Please sign in to comment.