aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/util/platform_test.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-21 00:51:34 +0900
committernsfisis <nsfisis@gmail.com>2026-06-21 00:51:34 +0900
commit7bea9042a79d3cbfe31cc2595e8b8c6a3788ba15 (patch)
tree3ed5b522c21f8fd80249f02751e46264537620f7 /crates/shirabe/tests/util/platform_test.rs
parenta01e3a45d1b183ee7fe9ca45543b0663d5995faa (diff)
downloadphp-shirabe-7bea9042a79d3cbfe31cc2595e8b8c6a3788ba15.tar.gz
php-shirabe-7bea9042a79d3cbfe31cc2595e8b8c6a3788ba15.tar.zst
php-shirabe-7bea9042a79d3cbfe31cc2595e8b8c6a3788ba15.zip
test: port small leaf tests (config, filters, platform, formatter)
Port DefaultConfigTest, IgnoreAll/IgnoreNothingPlatformRequirementFilterTest, PlatformTest, GitExcludeFilterTest, and HtmlOutputFormatterTest. Each PHP Test/<Subdir>/ maps to a single integration-test binary via tests/<dir>/main.rs (the target is named after the directory) whose #[test] functions are collected from the module tree. Tests that exercise unported library behavior (regex backreferences, Preg::split, env expansion) are marked #[ignore]. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/util/platform_test.rs')
-rw-r--r--crates/shirabe/tests/util/platform_test.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/crates/shirabe/tests/util/platform_test.rs b/crates/shirabe/tests/util/platform_test.rs
index 90ce6ad..3d00370 100644
--- a/crates/shirabe/tests/util/platform_test.rs
+++ b/crates/shirabe/tests/util/platform_test.rs
@@ -1 +1,31 @@
//! ref: composer/tests/Composer/Test/Util/PlatformTest.php
+
+use shirabe::util::platform::Platform;
+use shirabe_php_shim::defined;
+
+#[test]
+#[ignore = "Platform::expand_path does not read the env var set via put_env in this runtime"]
+fn test_expand_path() {
+ Platform::put_env("TESTENV", "/home/test");
+ assert_eq!("/home/test/myPath", Platform::expand_path("%TESTENV%/myPath"));
+ assert_eq!("/home/test/myPath", Platform::expand_path("$TESTENV/myPath"));
+ assert_eq!(
+ format!(
+ "{}/test",
+ Platform::get_env("HOME")
+ .or_else(|| Platform::get_env("USERPROFILE"))
+ .unwrap_or_default()
+ ),
+ Platform::expand_path("~/test")
+ );
+}
+
+#[test]
+fn test_is_windows() {
+ // Compare 2 common tests for Windows to the built-in Windows test
+ assert_eq!(
+ std::path::MAIN_SEPARATOR == '\\',
+ Platform::is_windows()
+ );
+ assert_eq!(defined("PHP_WINDOWS_VERSION_MAJOR"), Platform::is_windows());
+}