@@ -195,7 +195,7 @@ impl Container {
195
195
} ;
196
196
197
197
let write_main = self . commander . one ( write_main) ;
198
- let modify_cargo_toml = modify_cargo_toml ( & self . commander , request. edition ) ;
198
+ let modify_cargo_toml = modify_cargo_toml ( & self . commander , & request) ;
199
199
200
200
let ( write_main, modify_cargo_toml) = join ! ( write_main, modify_cargo_toml) ;
201
201
@@ -305,30 +305,30 @@ struct Commander {
305
305
// Consider making this into a top-level message to the worker to avoid the roundtrip.
306
306
async fn modify_cargo_toml (
307
307
commander : & Commander ,
308
- edition : crate :: sandbox :: Edition ,
308
+ request : & CompileRequest ,
309
309
) -> Result < ( ) , ModifyCargoTomlError > {
310
310
use modify_cargo_toml_error:: * ;
311
311
312
312
const PATH : & str = "Cargo.toml" ;
313
313
314
- let request = ReadFileRequest {
314
+ let read_request = ReadFileRequest {
315
315
path : PATH . to_owned ( ) ,
316
316
} ;
317
- let cargo_toml = commander. one ( request ) . await . context ( CouldNotReadSnafu ) ?;
317
+ let cargo_toml = commander. one ( read_request ) . await . context ( CouldNotReadSnafu ) ?;
318
318
319
319
let cargo_toml = String :: from_utf8 ( cargo_toml. 0 ) ?;
320
320
let cargo_toml = toml:: from_str ( & cargo_toml) ?;
321
321
322
- let cargo_toml = modify_cargo_toml:: set_edition ( cargo_toml, edition . to_cargo_toml_key ( ) ) ;
322
+ let cargo_toml = request . modify_cargo_toml ( cargo_toml) ;
323
323
324
324
let cargo_toml = toml:: to_string ( & cargo_toml) ?;
325
325
let cargo_toml = cargo_toml. into_bytes ( ) ;
326
326
327
- let request = WriteFileRequest {
327
+ let write_request = WriteFileRequest {
328
328
path : PATH . to_owned ( ) ,
329
329
content : cargo_toml,
330
330
} ;
331
- commander. one ( request ) . await . context ( CouldNotWriteSnafu ) ?;
331
+ commander. one ( write_request ) . await . context ( CouldNotWriteSnafu ) ?;
332
332
333
333
Ok ( ( ) )
334
334
}
@@ -778,6 +778,10 @@ mod tests {
778
778
//Coordinator::new_docker()
779
779
}
780
780
781
+ fn new_compile_request ( ) -> CompileRequest {
782
+ new_compile_mir_request ( )
783
+ }
784
+
781
785
fn new_compile_assembly_request ( ) -> CompileRequest {
782
786
CompileRequest {
783
787
target : CompileTarget :: Assembly (
@@ -802,7 +806,7 @@ mod tests {
802
806
fn new_compile_hir_request_for ( edition : Edition ) -> CompileRequest {
803
807
CompileRequest {
804
808
target : CompileTarget :: Hir ,
805
- channel : Channel :: Beta ,
809
+ channel : Channel :: Nightly ,
806
810
crate_type : CrateType :: Library ( LibraryType :: Lib ) ,
807
811
mode : Mode :: Release ,
808
812
edition,
@@ -838,8 +842,17 @@ mod tests {
838
842
}
839
843
}
840
844
841
- fn new_compile_request ( ) -> CompileRequest {
842
- new_compile_mir_request ( )
845
+ fn new_compile_wasm_request ( ) -> CompileRequest {
846
+ CompileRequest {
847
+ target : CompileTarget :: Wasm ,
848
+ channel : Channel :: Nightly , // TODO: Can we run this on all channels now?
849
+ crate_type : CrateType :: Library ( LibraryType :: Cdylib ) ,
850
+ mode : Mode :: Release ,
851
+ edition : Edition :: Rust2021 ,
852
+ tests : false ,
853
+ backtrace : false ,
854
+ code : r#"#[export_name = "inc"] pub fn inc(a: u8) -> u8 { a + 1 }"# . to_owned ( ) ,
855
+ }
843
856
}
844
857
845
858
#[ tokio:: test]
@@ -919,7 +932,6 @@ mod tests {
919
932
Ok ( ( ) )
920
933
}
921
934
922
-
923
935
#[ tokio:: test]
924
936
#[ snafu:: report]
925
937
async fn test_compile_assembly ( ) -> Result < ( ) > {
@@ -983,6 +995,26 @@ mod tests {
983
995
Ok ( ( ) )
984
996
}
985
997
998
+ #[ tokio:: test]
999
+ #[ snafu:: report]
1000
+ async fn test_compile_wasm ( ) -> Result < ( ) > {
1001
+ // cargo-wasm only exists inside the container
1002
+ let coordinator = Coordinator :: new_docker ( ) ?;
1003
+
1004
+ let response = coordinator
1005
+ . compile ( new_compile_wasm_request ( ) )
1006
+ . with_timeout ( )
1007
+ . await
1008
+ . unwrap ( ) ;
1009
+
1010
+ assert ! ( response. success, "stderr: {}" , response. stderr) ;
1011
+ assert_contains ! ( response. code, r#"(func $inc (export "inc") (type $t0) (param $p0 i32) (result i32)"# ) ;
1012
+
1013
+ coordinator. shutdown ( ) . await ?;
1014
+
1015
+ Ok ( ( ) )
1016
+ }
1017
+
986
1018
trait TimeoutExt : Future + Sized {
987
1019
fn with_timeout (
988
1020
self ,
0 commit comments