self-host TCS compiler GIR and add portable host runtime
This commit is contained in:
parent
3959ae4270
commit
ff29e52a32
33 changed files with 3848 additions and 831 deletions
37
native-runtime/tcs-gir-runtime/tests/stage1_runtime.rs
Normal file
37
native-runtime/tcs-gir-runtime/tests/stage1_runtime.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
use serde_json::Value as JsonValue;
|
||||
use std::{fs, path::Path};
|
||||
|
||||
fn project(relative: &str) -> std::path::PathBuf {
|
||||
Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../..")
|
||||
.join(relative)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn checked_in_compiler_a_continues_with_bootstrap_feature_disabled() {
|
||||
let compiler_a: JsonValue = serde_json::from_str(
|
||||
&fs::read_to_string(project("build/self-host/compiler-A.gir.json"))
|
||||
.expect("checked-in compiler A"),
|
||||
)
|
||||
.expect("compiler A JSON");
|
||||
let compiler_source = fs::read_to_string(project("language/compiler/TCS-COMPILER-STAGE1.tcs"))
|
||||
.expect("compiler source");
|
||||
|
||||
let compiler_b = tcs_gir_runtime::compile_with_compiler_gir(&compiler_a, &compiler_source)
|
||||
.expect("runtime executes compiler A");
|
||||
assert_eq!(
|
||||
compiler_a.pointer("/identity/definition_sha256"),
|
||||
compiler_b.pointer("/identity/definition_sha256")
|
||||
);
|
||||
|
||||
let program_source =
|
||||
fs::read_to_string(project("language/examples/ECHO-MODULE.tcs")).expect("program");
|
||||
let program = tcs_gir_runtime::compile_with_compiler_gir(&compiler_b, &program_source)
|
||||
.expect("compiler B compiles program");
|
||||
let root = tempfile::tempdir().expect("runtime root");
|
||||
let receipt = tcs_gir_runtime::run_echo_gir(&program, root.path()).expect("run GIR");
|
||||
let receipt: JsonValue =
|
||||
serde_json::from_str(&fs::read_to_string(receipt).expect("receipt")).expect("JSON");
|
||||
assert_eq!(receipt["native_self_hosted"], true);
|
||||
assert_eq!(receipt["compiler_state"], "TCS_COMPILER_GIR_EXECUTED");
|
||||
}
|
||||
Loading…
Reference in a new issue