aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/tests')
-rw-r--r--crates/shirabe/tests/command/init_command_test.rs14
-rw-r--r--crates/shirabe/tests/config_test.rs6
-rw-r--r--crates/shirabe/tests/util/ini_helper_test.rs10
3 files changed, 19 insertions, 11 deletions
diff --git a/crates/shirabe/tests/command/init_command_test.rs b/crates/shirabe/tests/command/init_command_test.rs
index 1c2fca6..0c38bf4 100644
--- a/crates/shirabe/tests/command/init_command_test.rs
+++ b/crates/shirabe/tests/command/init_command_test.rs
@@ -4,12 +4,13 @@ use crate::test_case::{RunOptions, get_application_tester, init_temp_composer};
use serial_test::serial;
use shirabe::command::init_command::InitCommand;
use shirabe::json::JsonFile;
-use shirabe_php_shim::{PhpMixed, server_set, server_unset};
+use shirabe_php_shim::{PHP_SERVER, PhpMixed};
use tempfile::TempDir;
fn set_up() {
- server_set("COMPOSER_DEFAULT_AUTHOR", "John Smith".to_string());
- server_set("COMPOSER_DEFAULT_EMAIL", "john@example.com".to_string());
+ let mut server = PHP_SERVER.lock().unwrap();
+ server.put("COMPOSER_DEFAULT_AUTHOR".into(), "John Smith".into());
+ server.put("COMPOSER_DEFAULT_EMAIL".into(), "john@example.com".into());
}
/// const DEFAULT_AUTHORS in PHP.
@@ -497,12 +498,15 @@ fn test_run_guess_name_from_dir_sanitizes_dir() {
std::fs::create_dir(dir_name).unwrap();
std::env::set_current_dir(dir_name).unwrap();
- server_set("COMPOSER_DEFAULT_VENDOR", ".vendorName".to_string());
+ PHP_SERVER
+ .lock()
+ .unwrap()
+ .put("COMPOSER_DEFAULT_VENDOR".into(), ".vendorName".into());
let mut app_tester = get_application_tester();
let result = app_tester.run(non_interactive_input(vec![]), RunOptions::default());
- server_unset("COMPOSER_DEFAULT_VENDOR");
+ PHP_SERVER.lock().unwrap().clear("COMPOSER_DEFAULT_VENDOR");
result.unwrap();
assert_eq!(0, app_tester.get_status_code());
diff --git a/crates/shirabe/tests/config_test.rs b/crates/shirabe/tests/config_test.rs
index 9c2f80b..df29281 100644
--- a/crates/shirabe/tests/config_test.rs
+++ b/crates/shirabe/tests/config_test.rs
@@ -1,6 +1,7 @@
//! ref: composer/tests/Composer/Test/ConfigTest.php
use indexmap::IndexMap;
+use serial_test::serial;
use shirabe::advisory::Auditor;
use shirabe::config::Config;
use shirabe::util::Platform;
@@ -509,6 +510,7 @@ fn test_disable_tls_can_be_overridden() {
}
#[test]
+#[serial]
fn test_process_timeout() {
Platform::put_env("COMPOSER_PROCESS_TIMEOUT", "0");
let config = Config::new(true, None);
@@ -520,6 +522,7 @@ fn test_process_timeout() {
#[ignore]
#[test]
+#[serial]
fn test_htaccess_protect() {
Platform::put_env("COMPOSER_HTACCESS_PROTECT", "0");
let config = Config::new(true, None);
@@ -530,6 +533,7 @@ fn test_htaccess_protect() {
}
#[test]
+#[serial]
fn test_get_source_of_value() {
Platform::clear_env("COMPOSER_PROCESS_TIMEOUT");
@@ -552,6 +556,7 @@ fn test_get_source_of_value() {
}
#[test]
+#[serial]
fn test_get_source_of_value_env_variables() {
Platform::put_env("COMPOSER_HTACCESS_PROTECT", "0");
let mut config = Config::new(true, None);
@@ -562,6 +567,7 @@ fn test_get_source_of_value_env_variables() {
}
#[test]
+#[serial]
fn test_audit() {
let mut config = Config::new(true, None);
let result = config.get("audit");
diff --git a/crates/shirabe/tests/util/ini_helper_test.rs b/crates/shirabe/tests/util/ini_helper_test.rs
index f511d76..d1e2071 100644
--- a/crates/shirabe/tests/util/ini_helper_test.rs
+++ b/crates/shirabe/tests/util/ini_helper_test.rs
@@ -12,7 +12,8 @@ fn set_up() -> TearDown {
// XdebugHandler is a unit struct with no name-registration API, so this
// step is a no-op here.
// Save current state
- let env_original = getenv("COMPOSER_ORIGINAL_INIS");
+ let env_original =
+ getenv("COMPOSER_ORIGINAL_INIS").map(|value| value.to_string_lossy().into_owned());
TearDown { env_original }
}
@@ -20,7 +21,7 @@ fn set_up() -> TearDown {
fn tear_down(env_original: &Option<String>) {
// Restore original state
if let Some(env_original) = env_original {
- putenv(&format!("COMPOSER_ORIGINAL_INIS={env_original}"));
+ unsafe { putenv("COMPOSER_ORIGINAL_INIS", env_original) };
} else {
Platform::clear_env("COMPOSER_ORIGINAL_INIS");
}
@@ -38,10 +39,7 @@ impl Drop for TearDown {
}
fn set_env(paths: &[&str]) {
- putenv(&format!(
- "COMPOSER_ORIGINAL_INIS={}",
- paths.join(PATH_SEPARATOR)
- ));
+ unsafe { putenv("COMPOSER_ORIGINAL_INIS", paths.join(PATH_SEPARATOR)) };
}
#[test]