Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
add dove test call to test native functions to CI (#215)
Browse files Browse the repository at this point in the history
* add move-stdlib submodule and run dove build/test directly

* correct test name
  • Loading branch information
mkurnikov authored Feb 15, 2022
1 parent 0415b86 commit 25711b9
Show file tree
Hide file tree
Showing 22 changed files with 76 additions and 184 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: recursive

- name: Restore from cache and run vcpkg
if: ${{ matrix.platform == 'win' }}
Expand Down Expand Up @@ -98,6 +100,24 @@ jobs:
command: test
args: --no-fail-fast --all --all-features

- name: dove build --path ./dove/resources/for_tests/move-stdlib
uses: actions-rs/cargo@v1
with:
command: run
args: -- build --path ./dove/resources/for_tests/move-stdlib

- name: dove build --doc --path ./dove/resources/for_tests/move-stdlib
uses: actions-rs/cargo@v1
with:
command: run
args: -- build --doc --path ./dove/resources/for_tests/move-stdlib

- name: dove test --path ./dove/resources/for_tests/move-stdlib
uses: actions-rs/cargo@v1
with:
command: run
args: -- test --path ./dove/resources/for_tests/move-stdlib

install:
name: install (${{ matrix.name }})
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ test.sh
# Direnv cache
.direnv

.idea
.idea
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "dove/resources/for_tests/move-stdlib"]
path = dove/resources/for_tests/move-stdlib
url = https://github.com/pontem-network/move-stdlib.git
2 changes: 2 additions & 0 deletions dove/resources/for_tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
move-stdlib/build
5 changes: 2 additions & 3 deletions dove/resources/for_tests/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ version = "0.1.0"
Std = "0x1"
Demo = "0x2"

[dependencies.MoveStdlib]
git = "https://github.com/pontem-network/move-stdlib"
rev = "v1.5.2"
[dependencies]
MoveStdlib = { local = "./move-stdlib" }
1 change: 1 addition & 0 deletions dove/resources/for_tests/move-stdlib
Submodule move-stdlib added at 9ecc68
7 changes: 3 additions & 4 deletions dove/resources/for_tests/scripts/multiple_scripts.move
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
script {
fun script_1(a:bool){
fun script_1(a: bool) {
assert!(a, 1);

}
}
script {
fun script_2(a:u8, b:u8){
assert!(a==b,2);
fun script_2(a: u8, b: u8) {
assert!(a == b, 2);
}
}
6 changes: 3 additions & 3 deletions dove/resources/for_tests/scripts/one_param.move
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
script {
fun one_param(a:bool){
assert!(a,2);
fun one_param(a: bool) {
assert!(a, 2);
}
}
}
4 changes: 2 additions & 2 deletions dove/resources/for_tests/scripts/two_params.move
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
script {
fun two_params(a:u8, b:u8){
assert!(a==b,2);
fun two_params(a: u8, b: u8) {
assert!(a == b, 2);
}
}
2 changes: 1 addition & 1 deletion dove/resources/for_tests/scripts/with_type.move
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
script {
fun with_type<T>(_a:u8){
fun with_type<T>(_a: u8) {
assert!(true, 3);
}
}
6 changes: 3 additions & 3 deletions dove/resources/for_tests/sources/demo1v.move
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Demo::Demo1v{
fun run(){ }
}
module Demo::Demo1v {
fun run() {}
}
6 changes: 3 additions & 3 deletions dove/resources/for_tests/sources/demo2v.move
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Demo::Demo2v{
fun run(){ }
}
module Demo::Demo2v {
fun run() {}
}
8 changes: 4 additions & 4 deletions dove/resources/for_tests/tests/test1.move
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[test_only]
module Demo::Test1{
module Demo::Test1 {
#[test]
fun success(){
assert!(true,1);
fun success() {
assert!(true, 1);
}
}
}
8 changes: 4 additions & 4 deletions dove/resources/for_tests/tests/test2.move
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[test_only]
module Demo::Test2{
module Demo::Test2 {
#[test]
fun success(){
assert!(true,2);
fun success() {
assert!(true, 2);
}
}
}
8 changes: 4 additions & 4 deletions dove/resources/for_tests/tests/test3.move
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[test_only]
module Demo::Test3{
module Demo::Test3 {
#[test]
fun error(){
assert!(false,3);
fun error() {
assert!(false, 3);
}
}
}
4 changes: 2 additions & 2 deletions dove/tests/helper.rs → dove/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn delete_project(project_path: &Path) -> Result<()> {
}

/// run bin dove
pub fn execute_dove_at(args: &[&str], project_path: &Path) -> Result<String> {
pub fn dove(args: &[&str], project_path: &Path) -> Result<String> {
ensure!(
project_path.exists(),
"Project folder {:?} does not exist",
Expand Down Expand Up @@ -102,7 +102,7 @@ pub fn new_demo_project(project_name: &str) -> Result<PathBuf> {

/// Build a project
pub fn build(project_dir: &Path) -> Result<String> {
execute_dove_at(&["build"], project_dir)
dove(&["build"], project_dir)
}

fn copy_folder(from: &Path, to: &Path) -> Result<()> {
Expand Down
86 changes: 0 additions & 86 deletions dove/tests/test_cmd_dove_build.rs

This file was deleted.

13 changes: 6 additions & 7 deletions dove/tests/test_cmd_dove_call.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod helper;
mod helpers;

use helper::{new_demo_project, execute_dove_at, delete_project};
use helpers::{new_demo_project, dove, delete_project};

/// $ dove call 'main()'
/// $ dove call 'one_param(true)'
Expand All @@ -11,12 +11,11 @@ fn test_cmd_dove_call() {
let project_folder = new_demo_project(project_name).unwrap();

for call in ["main()", "one_param(true)", "two_params(1,1)"] {
execute_dove_at(&["call", call], &project_folder).unwrap();
dove(&["call", call], &project_folder).unwrap();
}
delete_project(&project_folder).unwrap();
}

/// $ dove call 'main()'
/// $ dove call 'one_param' -a true
/// $ dove call 'two_params' --args 1 1
#[test]
Expand All @@ -28,7 +27,7 @@ fn test_cmd_dove_call_with_params() {
vec!["call", "one_param", "-a", "true"],
vec!["call", "two_params", "--args", "1", "1"],
] {
execute_dove_at(&call, &project_folder).unwrap();
dove(&call, &project_folder).unwrap();
}

delete_project(&project_folder).unwrap();
Expand All @@ -48,7 +47,7 @@ fn test_cmd_dove_call_with_type() {
vec!["call", "with_type(1)", "-t", "u8"],
vec!["call", "with_type", "-a", "1", "-t", "u8"],
] {
execute_dove_at(&call, &project_folder).unwrap();
dove(&call, &project_folder).unwrap();
}

delete_project(&project_folder).unwrap();
Expand All @@ -65,7 +64,7 @@ fn test_cmd_dove_call_output() {
("main", vec!["call", "main()"]),
("tmpname", vec!["call", "main()", "-o", "tmpname"]),
] {
execute_dove_at(&args, &project_folder).unwrap();
dove(&args, &project_folder).unwrap();
let tx_path = project_folder
.join("build")
.join("for_tests")
Expand Down
6 changes: 3 additions & 3 deletions dove/tests/test_cmd_dove_clean.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod helper;
mod helpers;

use crate::helper::{new_demo_project, delete_project, build, execute_dove_at};
use crate::helpers::{new_demo_project, delete_project, build, dove};

/// $ dove clean
#[test]
Expand All @@ -10,7 +10,7 @@ fn test_cmd_dove_clean() {
build(&project_dir).unwrap();

assert!(project_dir.join("build").exists());
execute_dove_at(&["clean"], &project_dir).unwrap();
dove(&["clean"], &project_dir).unwrap();
assert!(!project_dir.join("build").exists());

delete_project(&project_dir).unwrap();
Expand Down
6 changes: 3 additions & 3 deletions dove/tests/test_cmd_dove_init.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod helper;
mod helpers;

use std::fs;
use crate::helper::{execute_dove_at, delete_project, get_project_name_from_toml, new_demo_project};
use crate::helpers::{dove, delete_project, get_project_name_from_toml, new_demo_project};

/// Creating a project in an existing folder
/// $ dove init NAME_PROJECT
Expand All @@ -13,7 +13,7 @@ fn test_cmd_dove_init() {

fs::remove_file(project_path.join("Move.toml")).unwrap();

execute_dove_at(&["init", project_name], &project_path).unwrap();
dove(&["init", project_name], &project_path).unwrap();

assert_eq!(
get_project_name_from_toml(&project_path),
Expand Down
14 changes: 6 additions & 8 deletions dove/tests/test_cmd_dove_run.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod helper;
mod helpers;

use helper::{new_demo_project, execute_dove_at, delete_project};
use helpers::{new_demo_project, dove, delete_project};

/// $ dove run 'main()'
/// $ dove run 'one_param(true)'
Expand All @@ -11,14 +11,12 @@ fn test_cmd_dove_run_with_call() {
let project_folder = new_demo_project(project_name).unwrap();

for call in ["main()", "one_param(true)", "two_params(1,1)"] {
execute_dove_at(&["run", call], &project_folder).unwrap();
dove(&["run", call], &project_folder).unwrap();
}

delete_project(&project_folder).unwrap();
}

/// $ dove run 'one_param' -a true
/// $ dove run 'two_params' --args 1 1
#[test]
fn test_cmd_dove_run_with_params() {
let project_name = "project_run_with_params";
Expand All @@ -28,7 +26,7 @@ fn test_cmd_dove_run_with_params() {
vec!["run", "one_param", "-a", "true"],
vec!["run", "two_params", "--args", "1", "1"],
] {
execute_dove_at(&call, &project_folder).unwrap();
dove(&call, &project_folder).unwrap();
}

delete_project(&project_folder).unwrap();
Expand All @@ -48,7 +46,7 @@ fn test_cmd_dove_run_with_type() {
vec!["run", "with_type(1)", "-t", "u8"],
vec!["run", "with_type", "-a", "1", "-t", "u8"],
] {
execute_dove_at(&call, &project_folder).unwrap();
dove(&call, &project_folder).unwrap();
}

delete_project(&project_folder).unwrap();
Expand All @@ -64,7 +62,7 @@ fn test_cmd_dove_run_multiple() {
let project_folder = new_demo_project(project_name).unwrap();

for call in ["script_1(true)", "script_2(1,1)"] {
execute_dove_at(&["run", call], &project_folder).unwrap();
dove(&["run", call], &project_folder).unwrap();
}

delete_project(&project_folder).unwrap();
Expand Down
Loading

0 comments on commit 25711b9

Please sign in to comment.