From 098e06237d807fdfda274f0f62f8bea7ca942ec4 Mon Sep 17 00:00:00 2001 From: Nichol Yip Date: Fri, 19 Jan 2024 13:28:47 -0800 Subject: [PATCH] Fixed changes from rebase Signed-off-by: Nichol Yip --- crates/spk-schema/src/build_spec.rs | 5 +++-- crates/spk-schema/src/environ.rs | 26 -------------------------- crates/spk-schema/src/v0/spec.rs | 9 ++++++++- crates/spk-schema/src/v0/test_spec.rs | 4 ++-- 4 files changed, 13 insertions(+), 31 deletions(-) diff --git a/crates/spk-schema/src/build_spec.rs b/crates/spk-schema/src/build_spec.rs index 931ad2224..8d1c22b03 100644 --- a/crates/spk-schema/src/build_spec.rs +++ b/crates/spk-schema/src/build_spec.rs @@ -18,8 +18,8 @@ use strum::Display; use super::{v0, Opt, ValidationSpec}; use crate::name::{OptName, OptNameBuf}; -use crate::option::VarOpt; -use crate::{Lint, LintedItem, Lints, Result, UnknownKey, Variant}; +use crate::option::{PkgOpt, VarOpt}; +use crate::{Error, Lint, LintedItem, Lints, Result, UnknownKey, Variant}; #[cfg(test)] #[path = "./build_spec_test.rs"] @@ -406,6 +406,7 @@ impl<'de> Deserialize<'de> for BuildSpec { /// being deserialized must be trusted (eg it's from a repository) /// but may also not adhere to all of the (potentially new) validation /// that is done on the normal build spec +#[derive(Default)] pub(crate) struct UncheckedBuildSpec(BuildSpec); impl UncheckedBuildSpec { diff --git a/crates/spk-schema/src/environ.rs b/crates/spk-schema/src/environ.rs index 760172738..2460e4828 100644 --- a/crates/spk-schema/src/environ.rs +++ b/crates/spk-schema/src/environ.rs @@ -35,7 +35,6 @@ pub enum OpKind { Prepend, Priority, Set, - UnrecognizedKey, } /// An operation performed to the environment @@ -47,7 +46,6 @@ pub enum EnvOp { Prepend(PrependEnv), Priority(EnvPriority), Set(SetEnv), - UnrecognizedKey(UnrecognizedKey), } impl EnvOp { @@ -58,7 +56,6 @@ impl EnvOp { EnvOp::Prepend(_) => OpKind::Prepend, EnvOp::Priority(_) => OpKind::Priority, EnvOp::Set(_) => OpKind::Set, - EnvOp::UnrecognizedKey(_) => OpKind::UnrecognizedKey, } } @@ -69,7 +66,6 @@ impl EnvOp { EnvOp::Prepend(_) => "", EnvOp::Priority(_) => "", EnvOp::Set(_) => "", - EnvOp::UnrecognizedKey(e) => e.error.as_str(), } } @@ -147,7 +143,6 @@ impl EnvOp { Self::Prepend(op) => op.bash_source(), Self::Priority(op) => op.bash_source(), Self::Set(op) => op.bash_source(), - Self::UnrecognizedKey(op) => op.bash_source(), } } @@ -159,7 +154,6 @@ impl EnvOp { Self::Prepend(op) => op.tcsh_source(), Self::Priority(op) => op.tcsh_source(), Self::Set(op) => op.tcsh_source(), - Self::UnrecognizedKey(op) => op.tcsh_source(), } } @@ -231,9 +225,6 @@ impl From for EnvOp { OpKind::Priority => EnvOp::Priority(EnvPriority { priority: var.get_priority(), }), - OpKind::UnrecognizedKey => EnvOp::UnrecognizedKey(UnrecognizedKey { - error: var.get_op(), - }), } } } @@ -526,20 +517,3 @@ impl SetEnv { format!("setenv {} \"{}\"", self.set, self.value) } } - -/// Stores the error message of the unrecognized key -#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] -pub struct UnrecognizedKey { - pub error: String, -} - -impl UnrecognizedKey { - /// Empty bash source - pub fn bash_source(&self) -> String { - String::from("") - } - /// Empty tcsh source - pub fn tcsh_source(&self) -> String { - String::from("") - } -} diff --git a/crates/spk-schema/src/v0/spec.rs b/crates/spk-schema/src/v0/spec.rs index 920ba4724..76ef1d21a 100644 --- a/crates/spk-schema/src/v0/spec.rs +++ b/crates/spk-schema/src/v0/spec.rs @@ -995,7 +995,7 @@ impl SpecVisitor { build: None, tests: None, install: None, - lints: None, + lints: Vec::default(), check_build_spec, } } @@ -1068,6 +1068,13 @@ impl Lints for SpecVisitor { } } +impl Default for SpecVisitor { + #[inline] + fn default() -> Self { + Self::with_check_build_spec(true) + } +} + impl SpecVisitor { pub fn recipe() -> Self { Self::default() diff --git a/crates/spk-schema/src/v0/test_spec.rs b/crates/spk-schema/src/v0/test_spec.rs index c381ac8ea..36f1e97b4 100644 --- a/crates/spk-schema/src/v0/test_spec.rs +++ b/crates/spk-schema/src/v0/test_spec.rs @@ -40,7 +40,7 @@ impl crate::Test for TestSpec { struct TestSpecVisitor { stage: Option, script: Option