use crate::descriptor::ClaimRef;
use crate::identity::{DomainTag, IdentityProfileVersion};
use crate::muterprater::{
BaselinePrecondition, KillRefusal, MutationReport, MutationRun, MutationVerdict,
OperatorFamilyRef, SourceCoordinate,
};
use crate::report::{ForeignText, TargetBinding};
#[path = "type_guard.rs"]
mod guard;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum WrappedBackend {
CargoMutants,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct BackendVersion(String);
#[must_use = "a refusal is the reason a backend version was not read"]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum BackendVersionRefusal {
EmptySpelling,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum BackendVersionPosture {
Stated(BackendVersion),
Unstated,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ReadingSource {
ConsoleStream,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GrammarVersion(u32);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ClaimCeiling {
WitnessRejection,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct AdapterProfile {
backend: WrappedBackend,
version: BackendVersionPosture,
source: ReadingSource,
grammar: GrammarVersion,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct BackendCommand {
executable: String,
arguments: Vec<String>,
}
#[must_use = "a refusal is the reason a backend command was not admitted"]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum BackendCommandRefusal {
EmptyExecutable,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MutationBackendInvocation {
backend: WrappedBackend,
version: BackendVersion,
command: BackendCommand,
target: TargetBinding,
}
pub type OwnerLookup = fn(&SourceCoordinate) -> Option<ClaimRef>;
pub type FamilyLookup = fn(&SourceCoordinate, &[u8]) -> Option<OperatorFamilyRef>;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum WrapOutcomeWord {
Caught,
Missed,
Unviable,
TimedOut,
ToolFailed,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct UnparsedLine {
ordinal: usize,
text: ForeignText,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum AnnouncedRoster {
Stated(u32),
Unstated,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct WrapReading {
profile: AdapterProfile,
run: MutationRun,
announced: AnnouncedRoster,
unparsed: Vec<UnparsedLine>,
}
#[must_use = "a refusal is the reason a wrap reading was not built"]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum WrapRefusal {
BaselineNotStated,
BaselineNotQualified(BaselinePrecondition),
KillNotLawful {
ordinal: usize,
cause: KillRefusal,
},
VerdictPastCeiling {
at: usize,
verdict: MutationVerdict,
ceiling: ClaimCeiling,
},
}
pub const BACKEND_OUTPUT_TAG: DomainTag = DomainTag::declared(
"mutation-backend-output",
IdentityProfileVersion::declared(1),
);
pub const MUTATION_SOURCE_REVISION_TAG: DomainTag = DomainTag::declared(
"mutation-source-revision",
IdentityProfileVersion::declared(1),
);
crate::identity::content_address_reference! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct BackendOutputId;
}
crate::identity::content_address_reference! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MutationSourceRevisionId;
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MutationSourceRevision {
file: String,
revision: MutationSourceRevisionId,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CompiledSuiteArtifactManifest {
invocation: MutationBackendInvocation,
output: BackendOutputId,
sources: Vec<MutationSourceRevision>,
reading: WrapReading,
}
#[must_use = "a refusal is the reason no compiled-suite artifact manifest was admitted"]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ArtifactManifestRefusal {
Reading(WrapRefusal),
MutationSiteNotReported,
DuplicateSource(String),
ReportedSourceMissing(String),
SourceNotReported(String),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CompiledSuiteArtifactCustody {
manifest: CompiledSuiteArtifactManifest,
}
#[must_use = "a refusal is the reason imported mutation evidence is not current for the supplied sources"]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ArtifactCustodyRefusal {
DuplicateCurrentSource(String),
CurrentSourceMissing(String),
CurrentSourceUnexpected(String),
CurrentSourceMoved {
file: String,
expected: MutationSourceRevisionId,
found: MutationSourceRevisionId,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CompiledSuiteArtifactStanding<'artifact> {
Reported(&'artifact CompiledSuiteArtifactCustody),
NotReported,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum GrammarStanding {
Checked(BackendVersion),
Unchecked,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct AdapterQualification {
profile: AdapterProfile,
standing: GrammarStanding,
}
#[must_use = "a refusal is the reason a reading's profile was not qualified"]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum QualificationRefusal {
GrammarUnchecked,
BackendVersionUnstated,
CheckedAgainstAnotherVersion {
stated: BackendVersion,
checked: BackendVersion,
},
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CompiledSuitePressure {
qualification: AdapterQualification,
custody: CompiledSuiteArtifactCustody,
kill: MutationReport,
}
#[must_use = "a refusal is the reason no compiled suite pressure was demonstrated"]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum SuitePressureRefusal {
ArtifactNotReported,
QualificationUnderAnotherProfile,
NoKillDemonstrated,
}