]> Repositorios git - scryer-prolog.git/commitdiff
pass scryer path through stream instead of env var
authorDanil Platonov <[email protected]>
Mon, 13 Apr 2026 02:29:39 +0000 (19:29 -0700)
committerDanil Platonov <[email protected]>
Mon, 13 Apr 2026 02:29:39 +0000 (19:29 -0700)
tests-pl/issue-http_open-hanging.pl
tests/scryer/helper.rs
tests/scryer/issues.rs

index 52018dc29baeb2b4b172755e74c5f26cdb727307..360f3b68f8d99df2e6c3da12292a0d8d577ee8fa 100644 (file)
@@ -3,8 +3,13 @@
 :- use_module(library(iso_ext)).
 :- use_module(library(os)).
 
+prolog_path(Prolog) :-
+    read(Body),
+    term_variables(Body, [Prolog]),
+    Body.
+
 server_start([Process,Out]) :-
-    getenv("PROLOG", Prolog),
+    prolog_path(Prolog),
     process_create(Prolog,
         ["tests-pl/issue-http_open-hanging_server", "-t", "server"],
         [process(Process), stdout(pipe(Out))]).
index 910c025838cb29ec48e045403eac906a8e14d690..42be0e9aa7f61023274aeb04d4413516716b1ea5 100644 (file)
@@ -52,6 +52,25 @@ pub(crate) fn load_module_test_with_tokio_runtime<T: Expectable>(file: &str, exp
     });
 }
 
+#[cfg(not(target_arch = "wasm32"))]
+pub(crate) fn load_module_test_with_tokio_runtime_and_input<T: Expectable>(
+    file: &str,
+    input: impl Into<Cow<'static, str>>,
+    expected: T
+) {
+    let runtime = tokio::runtime::Builder::new_multi_thread()
+        .enable_all()
+        .build()
+        .unwrap();
+
+    runtime.block_on(async move {
+        let mut wam = MachineBuilder::default()
+            .with_streams(StreamConfig::in_memory().with_user_input(InputStreamConfig::string(input)))
+            .build();
+        expected.assert_eq(wam.test_load_file(file).as_slice())
+    });
+}
+
 pub(crate) fn load_module_test_with_input<T: Expectable>(
     file: &str,
     input: impl Into<Cow<'static, str>>,
index d5e98cdd75fd0bb3d78e8ea4c1dd72b2ef138103..e645fe021b99677ca3bf072c4ec02a24310e32e5 100644 (file)
@@ -1,6 +1,6 @@
 use crate::helper::load_module_test;
 #[cfg(not(target_arch = "wasm32"))]
-use crate::helper::load_module_test_with_tokio_runtime;
+use crate::helper::load_module_test_with_tokio_runtime_and_input;
 use serial_test::serial;
 
 // issue #831
@@ -155,16 +155,14 @@ fn issue_rename_file() {
     load_module_test("tests-pl/issue_rename_file.pl", "file_renamed");
 }
 
-#[serial]
 #[test]
 #[cfg(feature = "http")]
 #[cfg(not(target_arch = "wasm32"))]
 #[cfg_attr(miri, ignore = "it takes too long to run")]
 fn http_open_hanging() {
-    std::env::set_var("PROLOG", env!("CARGO_BIN_EXE_scryer-prolog"));
-
-    load_module_test_with_tokio_runtime(
+    load_module_test_with_tokio_runtime_and_input(
         "tests-pl/issue-http_open-hanging.pl",
+        format!("PROLOG={:?}.", env!("CARGO_BIN_EXE_scryer-prolog")),
             "received response with status code:200\nreceived response with status code:200\nreceived response with status code:200\nreceived response with status code:200\nreceived response with status code:200\n"
     );
 }