#[cfg(test)]
mod local_published_smoke_tests
{
use test_tools::{SmokeModuleTest, smoke_test_for_local_run, smoke_test_for_published_run, smoke_tests_run};
use std::env;
use std::sync::Mutex;
static ENV_MUTEX : Mutex< () > = Mutex::new( () );
#[test]
fn test_local_smoke_testing_path_dependencies()
{
let mut smoke_test = SmokeModuleTest::new("test_local_crate");
smoke_test.version("1.0.0");
smoke_test.code("use test_local_crate; fn main() { println!(\"Local smoke test\"); }".to_string());
let local_path = std::path::Path::new("/test/local/path");
let result = smoke_test.dependency_local_path("test_dependency", local_path);
assert!(result.is_ok(), "Should be able to configure local path dependency");
let cleanup_result = smoke_test.clean(true); assert!(cleanup_result.is_ok(), "Cleanup should succeed for local smoke test");
}
#[test]
fn test_published_smoke_testing_registry_dependencies()
{
let mut smoke_test = SmokeModuleTest::new("test_published_crate");
smoke_test.version("1.0.0");
smoke_test.code("use test_published_crate; fn main() { println!(\"Published smoke test\"); }".to_string());
let result = smoke_test.dependency_version("test_dependency", "1.2.3");
assert!(result.is_ok(), "Should be able to configure published version dependency");
let cleanup_result = smoke_test.clean(true); assert!(cleanup_result.is_ok(), "Cleanup should succeed for published smoke test");
}
#[test]
fn test_automated_dual_execution_workflow()
{
let _lock = ENV_MUTEX.lock().unwrap();
let original_with_smoke = env::var("WITH_SMOKE").ok();
env::remove_var("WITH_SMOKE");
env::set_var("WITH_SMOKE", "1");
let with_smoke_1 = env::var("WITH_SMOKE").unwrap();
assert_eq!(with_smoke_1, "1", "WITH_SMOKE should be set to '1'");
env::set_var("WITH_SMOKE", "local");
let with_smoke_local = env::var("WITH_SMOKE").unwrap();
assert_eq!(with_smoke_local, "local", "WITH_SMOKE should be set to 'local'");
env::set_var("WITH_SMOKE", "published");
let with_smoke_published = env::var("WITH_SMOKE").unwrap();
assert_eq!(with_smoke_published, "published", "WITH_SMOKE should be set to 'published'");
if let Some(value) = original_with_smoke {
env::set_var("WITH_SMOKE", value);
} else {
env::remove_var("WITH_SMOKE");
}
}
#[test]
fn test_release_validation_workflow()
{
let mut local_test = SmokeModuleTest::new("validation_crate");
local_test.version("2.0.0");
local_test.code(
"use validation_crate; \
fn main() { \
// Test basic functionality \
println!(\"Testing local version before release\"); \
// Add more comprehensive validation code here \
}".to_string()
);
let local_path = std::path::Path::new("/workspace/validation_crate");
let local_config = local_test.dependency_local_path("validation_crate", local_path);
assert!(local_config.is_ok(), "Local validation configuration should work");
let mut published_test = SmokeModuleTest::new("validation_crate_published");
published_test.version("2.0.0");
published_test.code(
"use validation_crate; \
fn main() { \
// Test that published version works identically \
println!(\"Testing published version after release\"); \
// Should have identical functionality to local version \
}".to_string()
);
let published_config = published_test.dependency_version("validation_crate", "2.0.0");
assert!(published_config.is_ok(), "Published validation configuration should work");
assert!(local_test.clean(true).is_ok(), "Local validation cleanup should work");
assert!(published_test.clean(true).is_ok(), "Published validation cleanup should work");
}
#[test]
fn test_consumer_usability_verification()
{
let mut consumer_test = SmokeModuleTest::new("consumer_example");
consumer_test.version("1.0.0");
consumer_test.code(
"use test_crate::prelude::*; \
use test_crate::{Config, Builder}; \
\
fn main() -> Result<(), Box<dyn std::error::Error>> { \
// Test common consumer patterns \
let config = Config::new(); \
let builder = Builder::default(); \
let result = builder.build()?; \
\
// Verify API works as expected from consumer perspective \
println!(\"Consumer usage successful: {:?}\", result); \
Ok(()) \
}".to_string()
);
let local_path = std::path::Path::new("/workspace/test_crate");
let local_consumer_config = consumer_test.dependency_local_path("test_crate", local_path);
assert!(local_consumer_config.is_ok(), "Local consumer testing should be configurable");
let multi_dep_result = consumer_test.dependency_version("helper_crate", "0.5.0");
assert!(multi_dep_result.is_ok(), "Multiple dependencies should be configurable");
let cleanup_result = consumer_test.clean(true);
assert!(cleanup_result.is_ok(), "Consumer smoke test cleanup should work");
}
#[test]
fn test_version_mismatch_handling()
{
let mut local_version_test = SmokeModuleTest::new("version_test_local");
local_version_test.version("3.1.0");
let mut published_version_test = SmokeModuleTest::new("version_test_published");
published_version_test.version("3.0.0");
let test_code =
"use version_test_crate; \
fn main() { \
// Test version-sensitive functionality \
let version = version_test_crate::version(); \
println!(\"Testing version: {}\", version); \
\
// Test that API is consistent across versions \
let result = version_test_crate::core_functionality(); \
assert!(result.is_ok(), \"Core functionality should work in all versions\"); \
}".to_string();
local_version_test.code(test_code.clone());
published_version_test.code(test_code);
let local_path = std::path::Path::new("/workspace/version_test_crate");
let local_config = local_version_test.dependency_local_path("version_test_crate", local_path);
assert!(local_config.is_ok(), "Local version configuration should work");
let published_config = published_version_test.dependency_version("version_test_crate", "3.0.0");
assert!(published_config.is_ok(), "Published version configuration should work");
assert!(local_version_test.clean(true).is_ok(), "Local version test cleanup should work");
assert!(published_version_test.clean(true).is_ok(), "Published version test cleanup should work");
}
#[test]
fn test_local_published_api_integration()
{
let _lock = ENV_MUTEX.lock().unwrap();
let local_fn: fn() -> Result<(), Box<dyn core::error::Error>> = smoke_test_for_local_run;
let _ = local_fn;
let published_fn: fn() -> Result<(), Box<dyn core::error::Error>> = smoke_test_for_published_run;
let _ = published_fn;
let dual_fn: fn() -> Result<(), Box<dyn core::error::Error>> = smoke_tests_run;
let _ = dual_fn;
let original_with_smoke = env::var("WITH_SMOKE").ok();
env::set_var("WITH_SMOKE", "local");
let local_should_run = matches!(env::var("WITH_SMOKE").as_ref().map(std::string::String::as_str), Ok("1" | "local"));
assert!(local_should_run, "Local smoke test should run when WITH_SMOKE=local");
env::set_var("WITH_SMOKE", "published");
let published_should_run = matches!(env::var("WITH_SMOKE").as_ref().map(std::string::String::as_str), Ok("1" | "published"));
assert!(published_should_run, "Published smoke test should run when WITH_SMOKE=published");
env::set_var("WITH_SMOKE", "1");
let both_should_run_local = matches!(env::var("WITH_SMOKE").as_ref().map(std::string::String::as_str), Ok("1" | "local"));
let both_should_run_published = matches!(env::var("WITH_SMOKE").as_ref().map(std::string::String::as_str), Ok("1" | "published"));
assert!(both_should_run_local && both_should_run_published, "Both smoke tests should run when WITH_SMOKE=1");
if let Some(value) = original_with_smoke {
env::set_var("WITH_SMOKE", value);
} else {
env::remove_var("WITH_SMOKE");
}
}
#[test]
fn test_comprehensive_release_workflow()
{
let mut pre_release_test = SmokeModuleTest::new("release_workflow_crate");
pre_release_test.version("4.0.0-beta.1");
pre_release_test.code(
"use release_workflow_crate::prelude::*; \
\
fn main() -> Result<(), Box<dyn std::error::Error>> { \
// Test comprehensive functionality before release \
let api = Api::new(); \
api.validate_all_features()?; \
\
// Test edge cases and error handling \
let edge_case_result = api.handle_edge_case(); \
assert!(edge_case_result.is_ok(), \"Edge cases should be handled\"); \
\
// Test performance characteristics \
let perf_result = api.performance_benchmark(); \
assert!(perf_result.duration_ms < 1000, \"Performance should meet requirements\"); \
\
println!(\"Pre-release validation successful\"); \
Ok(()) \
}".to_string()
);
let workspace_path = std::path::Path::new("/workspace/release_workflow_crate");
let pre_release_config = pre_release_test.dependency_local_path("release_workflow_crate", workspace_path);
assert!(pre_release_config.is_ok(), "Pre-release local testing should be configurable");
let mut post_release_test = SmokeModuleTest::new("release_workflow_crate_published");
post_release_test.version("4.0.0");
post_release_test.code(
"use release_workflow_crate::prelude::*; \
\
fn main() -> Result<(), Box<dyn std::error::Error>> { \
// Test identical functionality on published version \
let api = Api::new(); \
api.validate_all_features()?; \
\
// Verify published version matches local behavior \
let edge_case_result = api.handle_edge_case(); \
assert!(edge_case_result.is_ok(), \"Published version should handle edge cases identically\"); \
\
// Verify performance consistency \
let perf_result = api.performance_benchmark(); \
assert!(perf_result.duration_ms < 1000, \"Published version should maintain performance\"); \
\
println!(\"Post-release validation successful\"); \
Ok(()) \
}".to_string()
);
let post_release_config = post_release_test.dependency_version("release_workflow_crate", "4.0.0");
assert!(post_release_config.is_ok(), "Post-release published testing should be configurable");
let mut consumer_integration_test = SmokeModuleTest::new("consumer_integration");
consumer_integration_test.version("1.0.0");
consumer_integration_test.code(
"use release_workflow_crate as rwc; \
use other_popular_crate as opc; \
\
fn main() -> Result<(), Box<dyn std::error::Error>> { \
// Test integration with other popular crates \
let rwc_api = rwc::Api::new(); \
let opc_config = opc::Config::default(); \
\
// Test that the crate works well in realistic consumer environments \
let integration_result = rwc_api.integrate_with(opc_config)?; \
assert!(integration_result.is_successful(), \"Integration should work seamlessly\"); \
\
println!(\"Consumer integration validation successful\"); \
Ok(()) \
}".to_string()
);
let consumer_config = consumer_integration_test.dependency_version("release_workflow_crate", "4.0.0");
assert!(consumer_config.is_ok(), "Consumer integration testing should be configurable");
let other_dep_config = consumer_integration_test.dependency_version("other_popular_crate", "2.1.0");
assert!(other_dep_config.is_ok(), "Multiple consumer dependencies should be configurable");
assert!(pre_release_test.clean(true).is_ok(), "Pre-release test cleanup should work");
assert!(post_release_test.clean(true).is_ok(), "Post-release test cleanup should work");
assert!(consumer_integration_test.clean(true).is_ok(), "Consumer integration test cleanup should work");
}
}