Make the wasm test binary async.
This commit is contained in:
parent
65abaa332f
commit
9a13cb72c6
@ -75,7 +75,7 @@ foreign_document_test = ["compare", "dep:futures", "tokio/sync", "dep:walkdir",
|
|||||||
tracing = ["dep:opentelemetry", "dep:opentelemetry-otlp", "dep:opentelemetry-semantic-conventions", "dep:tokio", "dep:tracing", "dep:tracing-opentelemetry", "dep:tracing-subscriber"]
|
tracing = ["dep:opentelemetry", "dep:opentelemetry-otlp", "dep:opentelemetry-semantic-conventions", "dep:tokio", "dep:tracing", "dep:tracing-opentelemetry", "dep:tracing-subscriber"]
|
||||||
event_count = []
|
event_count = []
|
||||||
wasm = ["dep:serde", "dep:wasm-bindgen", "dep:serde-wasm-bindgen"]
|
wasm = ["dep:serde", "dep:wasm-bindgen", "dep:serde-wasm-bindgen"]
|
||||||
wasm_test = ["wasm", "dep:serde_json"]
|
wasm_test = ["wasm", "dep:serde_json", "tokio/process", "tokio/macros"]
|
||||||
|
|
||||||
# Optimized build for any sort of release.
|
# Optimized build for any sort of release.
|
||||||
[profile.release-lto]
|
[profile.release-lto]
|
||||||
|
@ -1,12 +1,66 @@
|
|||||||
|
#![feature(exact_size_is_empty)]
|
||||||
|
use std::io::Read;
|
||||||
|
|
||||||
use wasm::wasm_parse_org;
|
use wasm::wasm_parse_org;
|
||||||
|
|
||||||
mod error;
|
mod error;
|
||||||
mod wasm;
|
mod wasm;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
#[cfg(feature = "tracing")]
|
||||||
let body = include_str!("/tmp/test.org");
|
use crate::init_tracing::init_telemetry;
|
||||||
let result = wasm_parse_org(body);
|
#[cfg(feature = "tracing")]
|
||||||
|
use crate::init_tracing::shutdown_telemetry;
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
|
mod init_tracing;
|
||||||
|
|
||||||
println!("{}", serde_json::to_string(&result)?);
|
#[cfg(not(feature = "tracing"))]
|
||||||
Ok(())
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let rt = tokio::runtime::Runtime::new()?;
|
||||||
|
rt.block_on(async {
|
||||||
|
let main_body_result = main_body().await;
|
||||||
|
main_body_result
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let rt = tokio::runtime::Runtime::new()?;
|
||||||
|
rt.block_on(async {
|
||||||
|
init_telemetry()?;
|
||||||
|
let main_body_result = main_body().await;
|
||||||
|
shutdown_telemetry()?;
|
||||||
|
main_body_result
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
|
async fn main_body() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let args = std::env::args().skip(1);
|
||||||
|
if args.is_empty() {
|
||||||
|
let org_contents = read_stdin_to_string()?;
|
||||||
|
let wasm_result = wasm_parse_org(org_contents.as_str());
|
||||||
|
println!("{}", serde_json::to_string(&wasm_result)?);
|
||||||
|
// if run_anonymous_compare(org_contents).await? {
|
||||||
|
// } else {
|
||||||
|
// Err("Diff results do not match.")?;
|
||||||
|
// }
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
todo!()
|
||||||
|
// for arg in args {
|
||||||
|
// if run_compare_on_file(arg).await? {
|
||||||
|
// } else {
|
||||||
|
// Err("Diff results do not match.")?;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_stdin_to_string() -> Result<String, Box<dyn std::error::Error>> {
|
||||||
|
let mut stdin_contents = String::new();
|
||||||
|
std::io::stdin()
|
||||||
|
.lock()
|
||||||
|
.read_to_string(&mut stdin_contents)?;
|
||||||
|
Ok(stdin_contents)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user