Skip to content

Commit

Permalink
add integration test temp dir in subprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
maminrayej committed May 31, 2024
1 parent c358f73 commit 13a8e8e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import tempfile
import sys

temp_dir = tempfile.mkdtemp(prefix='pip-a-')
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import subprocess

result = subprocess.run(["/bin/python", '/code/child.py'], capture_output=True, text=True)

print(f"{result.returncode}", end="")
6 changes: 5 additions & 1 deletion tests/integration/cli/src/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ use std::path::{Path, PathBuf};

use crate::{asset_path, c_asset_path};

pub fn resources() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR")).join("resources")
}

pub fn php() -> (PathBuf, PathBuf, PathBuf) {
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
let resources = root.join("resources").join("php");
let resources = resources().join("php");
(
root.join("tests").join("wasm").join("php.wasm"),
resources.clone(),
Expand Down
19 changes: 18 additions & 1 deletion tests/integration/cli/tests/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use reqwest::{blocking::Client, IntoUrl};
use tempfile::TempDir;
use wasmer_integration_tests_cli::{
asset_path,
fixtures::{self, php},
fixtures::{self, php, resources},
get_wasmer_path,
};

Expand Down Expand Up @@ -47,6 +47,23 @@ static CACHE_RUST_LOG: Lazy<String> = Lazy::new(|| {
.join(",")
});

#[test]
fn run_python_create_temp_dir_in_subprocess() {
let resources = resources().join("python").join("temp-dir-in-child");

let output = Command::new(get_wasmer_path())
.arg("run")
.arg("python/python")
.arg("--mapdir")
.arg(format!("/code:{}", resources.display()))
.arg("--")
.arg("/code/main.py")
.output()
.unwrap();

assert_eq!(output.stdout, "0".as_bytes().to_vec());
}

#[test]
fn run_php_with_sqlite() {
let (php_wasm, app_dir, db) = php();
Expand Down

0 comments on commit 13a8e8e

Please sign in to comment.