feat: Migrate SAL to Cargo workspace
- Migrate individual modules to independent crates - Refactor dependencies for improved modularity - Update build system and testing infrastructure - Update documentation to reflect new structure
This commit is contained in:
@@ -5,7 +5,7 @@ fn test_platform_detection_consistency() {
|
||||
// Test that platform detection functions return consistent results
|
||||
let is_osx = platform::is_osx();
|
||||
let is_linux = platform::is_linux();
|
||||
|
||||
|
||||
// On any given system, only one of these should be true
|
||||
// (or both false if running on Windows or other OS)
|
||||
if is_osx {
|
||||
@@ -21,7 +21,7 @@ fn test_architecture_detection_consistency() {
|
||||
// Test that architecture detection functions return consistent results
|
||||
let is_arm = platform::is_arm();
|
||||
let is_x86 = platform::is_x86();
|
||||
|
||||
|
||||
// On any given system, only one of these should be true
|
||||
// (or both false if running on other architectures)
|
||||
if is_arm {
|
||||
@@ -76,55 +76,61 @@ fn test_x86_detection() {
|
||||
#[test]
|
||||
fn test_check_linux_x86() {
|
||||
let result = platform::check_linux_x86();
|
||||
|
||||
|
||||
// The result should depend on the current platform
|
||||
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
|
||||
{
|
||||
assert!(result.is_ok(), "Should succeed on Linux x86_64");
|
||||
}
|
||||
|
||||
|
||||
#[cfg(not(all(target_os = "linux", target_arch = "x86_64")))]
|
||||
{
|
||||
assert!(result.is_err(), "Should fail on non-Linux x86_64 platforms");
|
||||
|
||||
|
||||
// Check that the error message is meaningful
|
||||
let error = result.unwrap_err();
|
||||
let error_string = error.to_string();
|
||||
assert!(error_string.contains("Linux x86_64"),
|
||||
"Error message should mention Linux x86_64: {}", error_string);
|
||||
assert!(
|
||||
error_string.contains("Linux x86_64"),
|
||||
"Error message should mention Linux x86_64: {}",
|
||||
error_string
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_check_macos_arm() {
|
||||
let result = platform::check_macos_arm();
|
||||
|
||||
|
||||
// The result should depend on the current platform
|
||||
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
|
||||
{
|
||||
assert!(result.is_ok(), "Should succeed on macOS ARM");
|
||||
}
|
||||
|
||||
|
||||
#[cfg(not(all(target_os = "macos", target_arch = "aarch64")))]
|
||||
{
|
||||
assert!(result.is_err(), "Should fail on non-macOS ARM platforms");
|
||||
|
||||
|
||||
// Check that the error message is meaningful
|
||||
let error = result.unwrap_err();
|
||||
let error_string = error.to_string();
|
||||
assert!(error_string.contains("macOS ARM"),
|
||||
"Error message should mention macOS ARM: {}", error_string);
|
||||
assert!(
|
||||
error_string.contains("macOS ARM"),
|
||||
"Error message should mention macOS ARM: {}",
|
||||
error_string
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_platform_error_creation() {
|
||||
use sal_os::platform::PlatformError;
|
||||
|
||||
|
||||
// Test that we can create platform errors
|
||||
let error = PlatformError::new("Test Error", "This is a test error message");
|
||||
let error_string = error.to_string();
|
||||
|
||||
|
||||
assert!(error_string.contains("Test Error"));
|
||||
assert!(error_string.contains("This is a test error message"));
|
||||
}
|
||||
@@ -132,11 +138,11 @@ fn test_platform_error_creation() {
|
||||
#[test]
|
||||
fn test_platform_error_display() {
|
||||
use sal_os::platform::PlatformError;
|
||||
|
||||
|
||||
// Test error display formatting
|
||||
let error = PlatformError::Generic("Category".to_string(), "Message".to_string());
|
||||
let error_string = format!("{}", error);
|
||||
|
||||
|
||||
assert!(error_string.contains("Category"));
|
||||
assert!(error_string.contains("Message"));
|
||||
}
|
||||
@@ -144,11 +150,11 @@ fn test_platform_error_display() {
|
||||
#[test]
|
||||
fn test_platform_error_debug() {
|
||||
use sal_os::platform::PlatformError;
|
||||
|
||||
|
||||
// Test error debug formatting
|
||||
let error = PlatformError::Generic("Category".to_string(), "Message".to_string());
|
||||
let debug_string = format!("{:?}", error);
|
||||
|
||||
|
||||
assert!(debug_string.contains("Generic"));
|
||||
assert!(debug_string.contains("Category"));
|
||||
assert!(debug_string.contains("Message"));
|
||||
@@ -160,15 +166,15 @@ fn test_platform_functions_are_deterministic() {
|
||||
let osx1 = platform::is_osx();
|
||||
let osx2 = platform::is_osx();
|
||||
assert_eq!(osx1, osx2);
|
||||
|
||||
|
||||
let linux1 = platform::is_linux();
|
||||
let linux2 = platform::is_linux();
|
||||
assert_eq!(linux1, linux2);
|
||||
|
||||
|
||||
let arm1 = platform::is_arm();
|
||||
let arm2 = platform::is_arm();
|
||||
assert_eq!(arm1, arm2);
|
||||
|
||||
|
||||
let x86_1 = platform::is_x86();
|
||||
let x86_2 = platform::is_x86();
|
||||
assert_eq!(x86_1, x86_2);
|
||||
@@ -180,7 +186,7 @@ fn test_platform_check_functions_consistency() {
|
||||
let is_linux_x86 = platform::is_linux() && platform::is_x86();
|
||||
let check_linux_x86_result = platform::check_linux_x86().is_ok();
|
||||
assert_eq!(is_linux_x86, check_linux_x86_result);
|
||||
|
||||
|
||||
let is_macos_arm = platform::is_osx() && platform::is_arm();
|
||||
let check_macos_arm_result = platform::check_macos_arm().is_ok();
|
||||
assert_eq!(is_macos_arm, check_macos_arm_result);
|
||||
|
Reference in New Issue
Block a user