From cc01221c37b24338a3fdf9bedf6ca7a001711f02 Mon Sep 17 00:00:00 2001 From: Yeastplume Date: Thu, 4 Jun 2020 14:13:38 +0100 Subject: [PATCH] add integration tests --- tests/cmd_line_basic.rs | 64 +++++++++++++++++++++++++++++ tests/common/mod.rs | 44 ++++++++++++++++++++ tests/data/input/imageset-4bpp.png | Bin 0 -> 773 bytes 3 files changed, 108 insertions(+) create mode 100644 tests/cmd_line_basic.rs create mode 100644 tests/common/mod.rs create mode 100644 tests/data/input/imageset-4bpp.png diff --git a/tests/cmd_line_basic.rs b/tests/cmd_line_basic.rs new file mode 100644 index 0000000..7911186 --- /dev/null +++ b/tests/cmd_line_basic.rs @@ -0,0 +1,64 @@ +// Copyright 2020 Revcore Technologies Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Test wallet command line works as expected +#[macro_use] +extern crate clap; + +#[macro_use] +extern crate log; + +use aloevera::Error; + +mod common; +use common::{clean_output_dir, execute_command, setup}; + +#[test] +fn command_line_basic() -> Result<(), Error> { + let test_dir = "target/test_output/command_line_basic"; + setup(test_dir); + let project_file = format!("{}/testproject.av", test_dir); + load_app!(app); + + // Create Project + let arg_vec = vec!["aloevera", "create", "project", &project_file]; + execute_command(&app, arg_vec)?; + + // Import palette + let arg_vec = vec![ + "aloevera", + "-p", + &project_file, + "palette", + "import", + "tile_wall_pal", + "tests/data/input/imageset-4bpp.png", + ]; + execute_command(&app, arg_vec)?; + + // Output palette and check formats + let arg_vec = vec![ + "aloevera", + "-p", + &project_file, + "asm", + "-f", + "bin", + "tests/data/input/imageset-4bpp.png", + ]; + execute_command(&app, arg_vec)?; + + clean_output_dir(test_dir); + Ok(()) +} diff --git a/tests/common/mod.rs b/tests/common/mod.rs new file mode 100644 index 0000000..940f5aa --- /dev/null +++ b/tests/common/mod.rs @@ -0,0 +1,44 @@ +// Copyright 2020 Revcore Technologies Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Common functions for integration tests +use clap::App; +use std::fs; + +use aloevera::cmd; +use aloevera::Error; +use aloevera_util as util; + +pub fn clean_output_dir(test_dir: &str) { + let _ = fs::remove_dir_all(test_dir); +} + +pub fn setup(test_dir: &str) { + util::init_test_logger(); + clean_output_dir(test_dir); + let _ = fs::create_dir_all(test_dir); +} + +pub fn execute_command(app: &App, arg_vec: Vec<&str>) -> Result { + let args = app.clone().get_matches_from(arg_vec); + cmd::execute::execute_command(&args) +} + +#[macro_export] +macro_rules! load_app { + ($app: ident) => { + let yml = load_yaml!("../src/bin/aloevera.yml"); + let $app = clap::App::from_yaml(yml); + }; +} diff --git a/tests/data/input/imageset-4bpp.png b/tests/data/input/imageset-4bpp.png new file mode 100644 index 0000000000000000000000000000000000000000..9e7c37674db07179932aed6e6efd4bb7db5a2713 GIT binary patch literal 773 zcmV+g1N!`lP)Px#El^BUMF0Q*baZB(o{qg>Fv*~cdwHd1WSqN64Z?j{v$CN%IWl0QWHyjGAX+05 zLKW6rye$9#01tFhPE!E?|NsC0|NsC0|NsC0|K*LIrT_o}Ye_^wR9J=OnA>v0APhwD zC9NBS|NnDqaTN;+I4$l&HIqr!GH}L&v^Yv(OfKdni*%GX^ zDq#73fa@i{p9{R|12*3caJ~MuHbxhDTZSyJIvbJJn(F!d(!1Z>slIo*%<@iabC~je z0?6|{08e9#8)Lu1ZVv!-o#&l4$6?C*2>|jP0QS}p$ART`Kpr)}p8zml0F)2qG4lmc z3;kgB9;Q$?qXxkJ9X0oNrswHtL!nkJhAIH_chsW)TN70ZwQ4el(9 z0kEv7^9h!V0Ok08fQsJ_1K@reb;a*99RWfz11RtJ`XvDQd(bt%&-CQ_4$E830czuW z`#{z2v+#{4zZ3z)VL~5B_3d=s@0pIhpXXKRLn4#4~U z_yxH)hpJ(fJA8fa&zXPwdL0hH%8B`R`hQ?JK(>CxzwZMO?DIbW