use super::capability::CapabilityState;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Dimension {
Host,
ProjectBuildContext,
TargetApiContract,
LanguageCompiler,
ApplicationFramework,
PlatformWorkload,
ExecutionContext,
}
impl Dimension {
pub const ALL: [Dimension; 7] = [
Dimension::Host,
Dimension::ProjectBuildContext,
Dimension::TargetApiContract,
Dimension::LanguageCompiler,
Dimension::ApplicationFramework,
Dimension::PlatformWorkload,
Dimension::ExecutionContext,
];
pub fn label(self) -> &'static str {
match self {
Dimension::Host => "host",
Dimension::ProjectBuildContext => "project-build-context",
Dimension::TargetApiContract => "target-api-contract",
Dimension::LanguageCompiler => "language-compiler",
Dimension::ApplicationFramework => "application-framework",
Dimension::PlatformWorkload => "platform-workload",
Dimension::ExecutionContext => "execution-context",
}
}
}
#[derive(Debug, Clone)]
pub struct Profile {
pub id: &'static str,
pub target_framework: &'static str,
pub ceiling: CapabilityState,
}
pub const REGISTERED_PROFILES: &[Profile] = &[
Profile {
id: "csharp-net8.0-sdk",
target_framework: "net8.0",
ceiling: CapabilityState::SmokeTested,
},
Profile {
id: "csharp-netcoreapp3.1-sdk",
target_framework: "netcoreapp3.1",
ceiling: CapabilityState::SmokeTested,
},
Profile {
id: "csharp-net472-framework",
target_framework: "net472",
ceiling: CapabilityState::SmokeTested,
},
Profile {
id: "csharp-netstandard2.1-library",
target_framework: "netstandard2.1",
ceiling: CapabilityState::SmokeTested,
},
Profile {
id: "csharp-net40-framework",
target_framework: "net40",
ceiling: CapabilityState::Planned,
},
Profile {
id: "csharp-net481-framework",
target_framework: "net481",
ceiling: CapabilityState::Planned,
},
Profile {
id: "csharp-net10.0-sdk",
target_framework: "net10.0",
ceiling: CapabilityState::Planned,
},
Profile {
id: "csharp-netcoreapp2.x-sdk",
target_framework: "netcoreapp2.x",
ceiling: CapabilityState::Unavailable,
},
Profile {
id: "csharp-netstandard1.0-library",
target_framework: "netstandard1.0",
ceiling: CapabilityState::Planned,
},
];
pub fn find(id: &str) -> Option<&'static Profile> {
REGISTERED_PROFILES.iter().find(|p| p.id == id)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn no_registered_profile_claims_passing_or_failing() {
for profile in REGISTERED_PROFILES {
assert!(
!matches!(
profile.ceiling,
CapabilityState::Passing(_) | CapabilityState::Failing
),
"{} claims a state this registry may not assert",
profile.id
);
}
}
#[test]
fn the_four_demonstrated_targets_are_registered_at_most_smoke_tested() {
for id in [
"csharp-net8.0-sdk",
"csharp-netcoreapp3.1-sdk",
"csharp-net472-framework",
"csharp-netstandard2.1-library",
] {
let profile = find(id).unwrap_or_else(|| panic!("{id} must be registered"));
assert_eq!(profile.ceiling, CapabilityState::SmokeTested);
}
}
#[test]
fn lookup_of_an_unregistered_id_is_none() {
assert!(find("csharp-vb-anything").is_none());
}
}