diff --git a/ci/all_tests.sh b/ci/all_tests.sh index 3457a34..dff7faa 100755 --- a/ci/all_tests.sh +++ b/ci/all_tests.sh @@ -67,26 +67,6 @@ find . -type d -name "roc_nightly" -prune -o -type f -name "*.roc" -print | whil done for script in ci/expect_scripts/*.exp; do - - # skip file-upload-form.exp - # + expect ci/expect_scripts/file-upload-form.exp - # spawn examples/file-upload-form - # Listening on - # WARNING: The convert command is deprecated in IMv7, use "magick" instead of "convert" or "magick convert" - - # while executing - # "exec convert -size 100x100 xc:red red_test_image.png" - # invoked from within - # "expect "Listening on \r\n" { - - # exec convert -size 100x100 xc:red red_test_image.png - - # set script_dir [file dirname [info ..." - # (file "ci/expect_scripts/file-upload-form.exp" line 10) - if [ $script == "ci/expect_scripts/file-upload-form.exp" ]; then - continue - fi - expect "$script" done diff --git a/ci/expect_scripts/file-upload-form.exp b/ci/expect_scripts/file-upload-form.exp index d4b27d9..7f2fbb5 100644 --- a/ci/expect_scripts/file-upload-form.exp +++ b/ci/expect_scripts/file-upload-form.exp @@ -9,7 +9,7 @@ spawn $env(EXAMPLES_DIR)file-upload-form expect "Listening on \r\n" { - exec convert -size 100x100 xc:red red_test_image.png + exec magick -size 100x100 xc:red red_test_image.png set script_dir [file dirname [info script]] diff --git a/crates/roc_host/src/http_server.rs b/crates/roc_host/src/http_server.rs index e0df254..6400368 100644 --- a/crates/roc_host/src/http_server.rs +++ b/crates/roc_host/src/http_server.rs @@ -1,4 +1,4 @@ -use crate::roc::{self, to_const_seamless_roc_str}; +use crate::roc::{self}; use bytes::Bytes; use futures::{Future, FutureExt}; use hyper::header::{HeaderName, HeaderValue}; @@ -44,23 +44,29 @@ fn call_roc<'a>( ) -> hyper::Response { let headers: RocList = headers .map(|(key, value)| roc_http::Header { - name: unsafe { to_const_seamless_roc_str(key.as_str()) }, - value: unsafe { - to_const_seamless_roc_str(value.to_str().expect("valid header value from hyper")) - }, + // NOTE: we should be able to make this a seamless slice somehow + // we tried but it was causing some issues, so removing just land the PI upgrade with + // for now with something we know works ok. + // TODO use to_const_seamless_roc_str() + name: key.as_str().into(), + value: value + .to_str() + .expect("valid header value from hyper") + .into(), }) .collect(); // NOTE: we should be able to make this a seamless slice somehow - // and possible avoid making this a rust String + // and possible avoid making this a rust String or Vev first let uri: RocStr = url.to_string().as_str().into(); + let body: RocList = body.to_vec().as_slice().into(); let roc_request = roc_http::RequestToAndFromHost { headers, uri, timeout_ms: 0, method_ext: RocStr::empty(), - body: unsafe { roc::to_const_seamless_roc_list(&body) }, + body, method: roc_http::RequestToAndFromHost::from_hyper_method(&method), }; diff --git a/crates/roc_host/src/roc.rs b/crates/roc_host/src/roc.rs index 45e676e..ec44e3b 100644 --- a/crates/roc_host/src/roc.rs +++ b/crates/roc_host/src/roc.rs @@ -482,10 +482,15 @@ pub fn call_roc_respond( } } +// TODO use these functions to create seamless slices and avoid unnecessary allocations + +#[allow(dead_code)] const REFCOUNT_CONSTANT: u64 = 0; +#[allow(dead_code)] const SEAMLESS_SLICE_BIT: usize = isize::MIN as usize; // This is only safe to call if the underlying data is guaranteed to be alive for the lifetime of the roc list. +#[allow(dead_code)] pub unsafe fn to_const_seamless_roc_list(data: &[u8]) -> RocList { let const_refcount_allocation = (&REFCOUNT_CONSTANT as *const u64) as usize + size_of_val(&REFCOUNT_CONSTANT); @@ -493,8 +498,8 @@ pub unsafe fn to_const_seamless_roc_list(data: &[u8]) -> RocList { RocList::from_raw_parts(data.as_ptr() as *mut u8, data.len(), const_seamless_slice) } - // This is only safe to call if the underlying data is guaranteed to be alive for the lifetime of the roc list. +#[allow(dead_code)] pub unsafe fn to_const_seamless_roc_str(data: &str) -> RocStr { // TODO: consider still generating small strings here if the str is small enough. let const_refcount_allocation =