Skip to content

Commit

Permalink
Updated plume policy
Browse files Browse the repository at this point in the history
  • Loading branch information
JustusAdam committed Mar 17, 2024
1 parent 45f30a4 commit 7710385
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
3 changes: 0 additions & 3 deletions crates/paralegal-flow/src/ana/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,9 +902,6 @@ fn map_either<A, B, C, D>(
/// Checks the invariant that [`SPDGGenerator::collect_type_info`] should
/// produce a map that is a superset of the types found in all the `types` maps
/// on [`SPDG`].
///
/// Additionally this also inserts missing types into the map *only* for
/// generators created by async functions.
fn type_info_sanity_check(controllers: &ControllerMap, types: &TypeInfoMap) {
controllers
.values()
Expand Down
29 changes: 27 additions & 2 deletions props/plume/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::Result;
use clap::{Parser, ValueEnum};
use std::sync::Arc;

use paralegal_policy::{paralegal_spdg::traverse::EdgeSelection, Context, Diagnostics, Marker};
Expand All @@ -25,7 +26,7 @@ fn check(ctx: Arc<Context>) -> Result<()> {
{
let mut note = ctx.struct_note(format!(
"The type {} is not being deleted in {}",
ctx.desc().def_info[&t].name,
ctx.desc().type_info[&t].rendering,
ctrl.name
));
for src in sources {
Expand Down Expand Up @@ -56,17 +57,31 @@ fn check(ctx: Arc<Context>) -> Result<()> {
Ok(())
}

#[derive(Clone, Copy, ValueEnum, PartialOrd, Ord, PartialEq, Eq)]
#[clap(rename_all = "kebab-case")]
enum PlumeVersion {
/// Original, Deletes no comments
V0,
/// Deleted comments
V1,
/// What the policy should be: requires media deletion
V2,
/// If the media deletion was fixed
V3,
}

#[derive(clap::Parser)]
struct Args {
plume_dir: std::path::PathBuf,
#[clap(long, short = 'p', default_value_t = PlumeVersion::V0, value_enum)]
plume_version: PlumeVersion,
/// Additional arguments to pass to cargo, this is intended to be used to
/// enable the features that toggle the bugs, like `delete-comments`.
#[clap(last = true)]
cargo_args: Vec<String>,
}

fn main() -> Result<()> {
use clap::Parser;
let args = Args::try_parse()?;

let mut cmd = paralegal_policy::SPDGGenCommand::global();
Expand All @@ -81,6 +96,16 @@ fn main() -> Result<()> {
"--features",
"postgres",
]);
for (version_bound, feature) in [
(PlumeVersion::V1, "delete-comments"),
(PlumeVersion::V2, "require-delete-media"),
(PlumeVersion::V3, "delete-media"),
] {
if args.plume_version >= version_bound {
cmd.get_command()
.args(["--features", &format!("plume-models/{feature}")]);
}
}
cmd.get_command().args(args.cargo_args);
let result = cmd.run(args.plume_dir)?.with_context(check)?;
println!(
Expand Down

0 comments on commit 7710385

Please sign in to comment.