pub fn run_move_prover(
    mut config: BuildConfig,
    path: &Path,
    target_filter: &Option<String>,
    for_test: bool,
    options: &[String],
) -> anyhow::Result<()> {
    // Always run the prover in dev mode, so addresses get default assignments
    config.dev_mode = true;

    let mut args = vec!["package".to_string()];
    let prover_toml = Path::new(&path).join("Prover.toml");
    if prover_toml.exists() {
        args.push(format!("--config={}", prover_toml.to_string_lossy()));
    }
    args.extend(options.iter().cloned());
    let mut options = move_prover::cli::Options::create_from_args(&args)?;
    if !options.move_sources.is_empty() {
        bail!(
            "move prover options must not specify sources as those are given \
                     by the package system. Did you meant to prefix `{}` with `-t`?",
            &options.move_sources[0]
        );
    }
    if !options.move_deps.is_empty() {
        bail!(
            "move prover options must not specify dependencies as those are given \
                     by the package system"
        );
    }
    if !options.move_named_address_values.is_empty() {
        bail!(
            "move prover options must not specify named addresses as those are given \
                     by the package system"
        );
    }

    let mut message_writer = StandardStream::stdout(ColorChoice::Auto);
    let mut error_writer = StandardStream::stderr(ColorChoice::Auto);
    if for_test {
        options.set_quiet();
        options.setup_logging_for_test();
    } else {
        options.setup_logging();
    }
    let now = Instant::now();
    let model = config.move_model_for_package(
        path,
        ModelConfig {
            all_files_as_targets: false,
            target_filter: target_filter.clone(),
        },
    )?;
    let _temp_dir_holder = if for_test {
        // Need to ensure a distinct output.bpl file for concurrent execution. In non-test
        // mode, we actually want to use the static output.bpl for debugging purposes
        let temp_dir = TempDir::new()?;
        std::fs::create_dir_all(temp_dir.path())?;
        options.output_path = temp_dir
            .path()
            .join("output.bpl")
            .to_string_lossy()
            .to_string();
        Some(temp_dir)
    } else {
        None
    };
    let res = run_move_prover_with_model(&model, &mut error_writer, options, Some(now));
    if for_test {
        let basedir = path
            .file_name()
            .map(|s| s.to_string_lossy().to_string())
            .unwrap_or_else(String::new);
        writeln!(
            message_writer,
            "{} proving {} modules from package `{}` in {:.3}s",
            if res.is_ok() {
                "SUCCESS".bold().green()
            } else {
                "FAILURE".bold().red()
            },
            model.get_target_modules().len(),
            basedir,
            now.elapsed().as_secs_f64()
        )?;
    }
    res
}
// =================================================================================================
// Running the prover as a package command
Running the prover as a package command
Running the prover as a package command
pub fn run_move_prover(
    mut config: BuildConfig,
    path: &Path,
    target_filter: &Option<String>,
    for_test: bool,
    options: &[String],
) -> anyhow::Result<()> {
    // Always run the prover in dev mode, so addresses get default assignments
    config.dev_mode = true;
    let mut args = vec!["package".to_string()];
    let prover_toml = Path::new(&path).join("Prover.toml");
    if prover_toml.exists() {
        args.push(format!("--config={}", prover_toml.to_string_lossy()));
    }
    args.extend(options.iter().cloned());
    let mut options = move_prover::cli::Options::create_from_args(&args)?;
    if !options.move_sources.is_empty() {
        bail!(
            "move prover options must not specify sources as those are given \
                     by the package system. Did you meant to prefix `{}` with `-t`?",
            &options.move_sources[0]
        );
    }
    if !options.move_deps.is_empty() {
        bail!(
            "move prover options must not specify dependencies as those are given \
                     by the package system"
        );
    }
    if !options.move_named_address_values.is_empty() {
        bail!(
            "move prover options must not specify named addresses as those are given \
                     by the package system"
        );
    }
    let mut message_writer = StandardStream::stdout(ColorChoice::Auto);
    let mut error_writer = StandardStream::stderr(ColorChoice::Auto);
    if for_test {
        options.set_quiet();
        options.setup_logging_for_test();
    } else {
        options.setup_logging();
    }
    let now = Instant::now();
    let model = config.move_model_for_package(
        path,
        ModelConfig {
            all_files_as_targets: false,
            target_filter: target_filter.clone(),
        },
    )?;
    let _temp_dir_holder = if for_test {
        // Need to ensure a distinct output.bpl file for concurrent execution. In non-test
        // mode, we actually want to use the static output.bpl for debugging purposes
        let temp_dir = TempDir::new()?;
        std::fs::create_dir_all(temp_dir.path())?;
        options.output_path = temp_dir
            .path()
            .join("output.bpl")
            .to_string_lossy()
            .to_string();
        Some(temp_dir)
    } else {
        None
    };
    let res = run_move_prover_with_model(&model, &mut error_writer, options, Some(now));
    if for_test {
        let basedir = path
            .file_name()
            .map(|s| s.to_string_lossy().to_string())
            .unwrap_or_else(String::new);
        writeln!(
            message_writer,
            "{} proving {} modules from package `{}` in {:.3}s",
            if res.is_ok() {
                "SUCCESS".bold().green()
            } else {
                "FAILURE".bold().red()
            },
            model.get_target_modules().len(),
            basedir,
            now.elapsed().as_secs_f64()
        )?;
    }
    res
}
pub fn run_move_prover ( mut config : BuildConfig , path : & Path , target_filter : & Option < String > , for_test : bool , options : & [ String ] , ) -> anyhow :: Result < ( ) > { // Always run the prover in dev mode, so addresses get default assignments config . dev_mode = true ; let mut args = vec ! [ " " to_string ( ) ] ; let prover_toml = Path :: new ( & path ) . join ( " " ) ; if prover_toml . exists ( ) { args . push ( format ! ( " " prover_toml to_string_lossy ( ) ) ) ; } args . extend ( options . iter ( ) . cloned ( ) ) ; let mut options = move_prover :: cli :: Options :: create_from_args ( & args ) ? ; if ! options . move_sources . is_empty ( ) { bail ! ( " \
 " options move_sources [ 0 ] ) ; } if ! options . move_deps . is_empty ( ) { bail ! ( " \
 " ) ; } if ! options . move_named_address_values . is_empty ( ) { bail ! ( " \
 " ) ; } let mut message_writer = StandardStream :: stdout ( ColorChoice :: Auto ) ; let mut error_writer = StandardStream :: stderr ( ColorChoice :: Auto ) ; if for_test { options . set_quiet ( ) ; options . setup_logging_for_test ( ) ; } else { options . setup_logging ( ) ; } let now = Instant :: now ( ) ; let model = config . move_model_for_package ( path , ModelConfig { all_files_as_targets : false , target_filter : target_filter . clone ( ) , } , ) ? ; let _temp_dir_holder = if for_test { // Need to ensure a distinct output.bpl file for concurrent execution. In non-test // mode, we actually want to use the static output.bpl for debugging purposes let temp_dir = TempDir :: new ( ) ? ; std :: fs :: create_dir_all ( temp_dir . path ( ) ) ? ; options . output_path = temp_dir . path ( ) . join ( " " ) . to_string_lossy ( ) . to_string ( ) ; Some ( temp_dir ) } else { None } ; let res = run_move_prover_with_model ( & model , & mut error_writer , options , Some ( now ) ) ; if for_test { let basedir = path . file_name ( ) . map ( | s | s . to_string_lossy ( ) . to_string ( ) ) . unwrap_or_else ( String :: new ) ; writeln ! ( message_writer " " if res is_ok ( ) { " " bold ( ) green ( ) } else { " " bold ( ) red ( ) } model get_target_modules ( ) len ( ) basedir now elapsed ( ) as_secs_f64 ( ) ) ? ; } res }
Running the prover as a package command
Running the prover as a package command
config
BuildConfig
path
&Path
target_filter
&Option<String>
for_test
bool
options
&[String]