anza-xyz / move

Move compiler targeting llvm supported backends
https://discord.gg/wFgfjG9J
Apache License 2.0
108 stars 34 forks source link

Cargo test for move-mv-llvm-compiler unit tests #9

Closed ksolana closed 1 year ago

ksolana commented 2 years ago

Running cargo test in move/language/tools/move-mv-llvm-compiler should do the following For each .mvir file in move/language/tools/move-mv-llvm-compiler/tests

brson commented 2 years ago

@aditya-solana I have written a move-mv-llvm-compiler test harness:

https://github.com/brson/move/blob/llvm-test-harness/language/tools/move-mv-llvm-compiler/tests/ir-tests.rs

It doesn't work exactly as you suggest though.

It is based on converting MVIR to LLVM IR and comparing the result with a reference file, similar to parts of the LLVM and Rust test suite.

It uses the datatest_stable crate, as do most of the other move tests.

It

Actual test results can be promoted to expected test results. The mechanism I wrote to do this is by setting PROMOTE_LLVM_IR, which when set will cause the test harness to copy the .actual.ll files to .expected.ll. This mechanism could be changed to better match other parts of the move test suite. I haven't looked at it closely.

The .expected.ll files are checked into git.

Let me know what you think.

brson commented 2 years ago

Run with cargo test -p move-mv-llvm-compiler --test ir-tests

brson commented 2 years ago

Hm, currently it requires running cargo build -p move-ir-compiler first. It does not automatically build it.

brson commented 1 year ago

This is done. Refinements to the ir-tests can be opened as new issues.