mirror of
https://github.com/fluencelabs/marine.git
synced 2025-03-15 05:50:49 +00:00
wip code for sharing
This commit is contained in:
parent
f97a4f7eba
commit
2824de6150
@ -15,4 +15,10 @@ path = "src/main.rs"
|
|||||||
marine-rs-sdk = "0.6.11"
|
marine-rs-sdk = "0.6.11"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
marine-rs-sdk-test = "0.2.0"
|
marine-rs-sdk-test = {path="../../../marine-rs-sdk/sdk-test"}
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
marine-test-macro-impl = {path="../../../marine-rs-sdk/crates/marine-test-macro-impl"}
|
||||||
|
quote = "1.0.9"
|
||||||
|
proc-macro2 = "1.0.26"
|
||||||
|
marine-rs-sdk-test = {path="../../../marine-rs-sdk/sdk-test"}
|
||||||
|
45
examples/greeting/build.rs
Normal file
45
examples/greeting/build.rs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// build.rs
|
||||||
|
|
||||||
|
use marine_test_macro_impl::marine_test_impl2;
|
||||||
|
|
||||||
|
use proc_macro2::TokenStream;
|
||||||
|
use quote::quote;
|
||||||
|
use quote::ToTokens;
|
||||||
|
|
||||||
|
use std::env;
|
||||||
|
use std::fs;
|
||||||
|
use std::path::Path;
|
||||||
|
use std::string::ToString;
|
||||||
|
|
||||||
|
pub fn test_marine_test_token_streams(
|
||||||
|
config_path: &str,
|
||||||
|
modules_dir: &str,
|
||||||
|
) -> Option<TokenStream> {
|
||||||
|
//let marine_item = stream_from_file(&marine_path);
|
||||||
|
//let test_token_stream = quote::quote! { #marine_item };
|
||||||
|
//let buf = marine_path.as_ref().to_path_buf();
|
||||||
|
let attrs = quote::quote! {config_path = #config_path, modules_dir = #modules_dir};
|
||||||
|
let marine_token_streams = marine_test_impl2(attrs)
|
||||||
|
.unwrap_or_else(|e| panic!("failed to apply the marine macro due {}", e));
|
||||||
|
|
||||||
|
//let expanded_item = items_from_file(&expanded_path);
|
||||||
|
Some(marine_token_streams)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let out_dir = env::var_os("OUT_DIR").unwrap();
|
||||||
|
let dest_path = Path::new(&out_dir).join("marine_test_env.rs");
|
||||||
|
let tokens = test_marine_test_token_streams("Config.toml", "artifacts").unwrap();
|
||||||
|
let tokens=tokens.to_string();
|
||||||
|
if cfg!(test) {
|
||||||
|
fs::write(
|
||||||
|
&dest_path,&tokens
|
||||||
|
).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
println!("out_dir: {}", out_dir.to_str().unwrap());
|
||||||
|
println!("code: {}", tokens);
|
||||||
|
println!("cargo:rerun-if-changed=build.rs");
|
||||||
|
println!("cargo:rerun-if-changed=src/main.rs");
|
||||||
|
}
|
@ -29,6 +29,7 @@ pub fn greeting(name: String) -> String {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use marine_rs_sdk_test::marine_test;
|
use marine_rs_sdk_test::marine_test;
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/marine_test_env.rs"));
|
||||||
|
|
||||||
#[marine_test(config_path = "../Config.toml", modules_dir = "../artifacts")]
|
#[marine_test(config_path = "../Config.toml", modules_dir = "../artifacts")]
|
||||||
fn empty_string(greeting: marine_test_env::greeting::ModuleInterface) {
|
fn empty_string(greeting: marine_test_env::greeting::ModuleInterface) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user