Skip to content

Commit

Permalink
fix aptos move test --coverage to not necessarily use compiler-v1
Browse files Browse the repository at this point in the history
  • Loading branch information
brmataptos committed Aug 29, 2024
1 parent 8dd61f4 commit ee8bc20
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 14 additions & 2 deletions crates/aptos/src/move_tool/coverage.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

use crate::common::types::{CliCommand, CliError, CliResult, CliTypedResult, MovePackageDir};
use crate::{
common::types::{CliCommand, CliError, CliResult, CliTypedResult, MovePackageDir},
move_tool::{experiments_from_opt_level, fix_bytecode_version},
};
use aptos_framework::extended_checks;
use async_trait::async_trait;
use clap::{Parser, Subcommand};
Expand Down Expand Up @@ -162,14 +165,23 @@ fn compile_coverage(
dev_mode: move_options.dev,
additional_named_addresses: move_options.named_addresses(),
test_mode: false,
full_model_generation: move_options.check_test_code,
install_dir: move_options.output_dir.clone(),
skip_fetch_latest_git_deps: move_options.skip_fetch_latest_git_deps,
compiler_config: CompilerConfig {
known_attributes: extended_checks::get_all_attribute_names().clone(),
skip_attribute_checks: false,
..Default::default()
bytecode_version: fix_bytecode_version(
move_options.bytecode_version,
move_options.language_version,
),
compiler_version: move_options.compiler_version,
language_version: move_options.language_version,
experiments: experiments_from_opt_level(&move_options.optimize),
},
..Default::default()
};

let path = move_options.get_package_path()?;
let coverage_map =
CoverageMap::from_binary_file(path.join(".coverage_map.mvcov")).map_err(|err| {
Expand Down
4 changes: 2 additions & 2 deletions crates/aptos/src/move_tool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ pub struct TestPackage {
pub dump_state: bool,
}

fn fix_bytecode_version(
pub(crate) fn fix_bytecode_version(
bytecode_version_in: Option<u32>,
language_version: Option<LanguageVersion>,
) -> Option<u32> {
Expand Down Expand Up @@ -814,7 +814,7 @@ impl FromStr for IncludedArtifacts {
}
}

fn experiments_from_opt_level(optlevel: &Option<OptimizationLevel>) -> Vec<String> {
pub(crate) fn experiments_from_opt_level(optlevel: &Option<OptimizationLevel>) -> Vec<String> {
match optlevel {
None | Some(OptimizationLevel::Default) => {
vec![format!("{}=on", Experiment::OPTIMIZE.to_string())]
Expand Down

0 comments on commit ee8bc20

Please sign in to comment.