-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Description
🐛 Bug
Unit tests initiated in aptos-core/aptos-move/framework/tests/move_unit_test.rs are not running compiler extended_checks. This means that:
- these extended_checks are not exercised on much code in testing.
- any added functionality needed to process aptos-specific move code needs a different code path.
Tests run here are as follows:
aptos-move/framework/tests/move_unit_test.rs
15: fn run_tests_for_pkg(path_to_pkg: impl Into<String>) {
53: run_tests_for_pkg("aptos-framework");
58: run_tests_for_pkg("aptos-stdlib");
63: run_tests_for_pkg("move-stdlib");
68: run_tests_for_pkg("aptos-token");
73: run_tests_for_pkg("aptos-token-objects");
The implementation of run_tests_for_pkg leverages third_party 's method here:
move_cli::base::test::run_move_unit_tests which doesn't have access to extended_checks, which lives outside of third_party
The aptos-framework tests need something done to call extended_checks::run_extended_checks() on the built model. Note that code implementing aptos move TestPackage uses the same test runner but first "[builds] the Move model for extended checks".
Perhaps these tests should do something similar to better test the extended_checks code.
Ideally, Aptos Move-specific code would be better integrated with Third-Party Move code through less hacky dialect plugins, unless the code were merged and specialized for Aptos's Move dialect.
A bit more info with code pointers.
You can see here:
| use move_cli::base::test::{run_move_unit_tests, UnitTestResult}; |
and here:
| let ok = run_move_unit_tests( |
that framework unit tests tests are run using
As the run_move_unit_tests method is in third_party/, takes no function impl Trait or dyn<T> parameters, it must use third-party code to build the code, and is thus not able to run aptos_framework::extended_checks.
Interestingly, run_move_unit_tests creates a compiler parameter impl of type FnMut(Compiler,) -> anyhow::Result<(FilesSourceText, Vec<AnnotatedCompiledUnit>)> ,which exposes the single-file compilation step here, but it's too late.
The actual compilation happens using
BuildPlan::compile_with_driver(), defined in third_party/move/tools/move-package/src/compilation/build_plan.rs,
which calls CompiledPackage::build_all, defined in third_party/move/tools/move-package/src/compilation/compiled_package.rs,
which calls Compiler::from_package_paths(), defined in third_party/move/move-compiler/src/command_line/compiler.rs
Metadata
Metadata
Assignees
Labels
Type
Projects
Status