From 66d4a72d1d662b19d8d2e6c165c4de50afbed88d Mon Sep 17 00:00:00 2001 From: styczynski Date: Sun, 29 Oct 2017 16:36:00 +0100 Subject: [PATCH] Fix zip/downloading bugs experimental feature :) --- README.md | 2 +- package.json | 2 +- test/utest.yaml | 0 utest.sh | 33 +++++++++++++++++++++++++++++++-- 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 test/utest.yaml diff --git a/README.md b/README.md index 87113ca..ec11b39 100644 --- a/README.md +++ b/README.md @@ -405,4 +405,4 @@ Simple enough, right? [screenshot 1]: https://raw.githubusercontent.com/styczynski/bash-universal-tester/master/static/screenshots/screenshot1.png -[link download latest]: https://github.com/styczynski/bash-universal-tester/archive/1.8.0.zip +[link download latest]: https://github.com/styczynski/bash-universal-tester/archive/1.9.0.zip diff --git a/package.json b/package.json index 5dd524f..befd4d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bash-universal-tester", - "version": "1.8.0", + "version": "1.9.0", "description": "Universal testing script for bash", "keywords": "bash, testing, tester, utest, bash-test, testing, script", "homepage": "https://github.com/styczynski/bash-universal-tester", diff --git a/test/utest.yaml b/test/utest.yaml new file mode 100644 index 0000000..e69de29 diff --git a/utest.sh b/utest.sh index 08ff19b..bdf96e8 100644 --- a/utest.sh +++ b/utest.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERSION="1.8.0" +VERSION="1.9.0" IFS=$'\n' # Dependencies @@ -421,8 +421,17 @@ function update_loc { function prepare_input { - regex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]' + if [[ ! "${param_prog}" = "" ]]; then + if [[ "${param_dir}" = "" ]]; then + if [[ $param_prog =~ $regex ]] + then + param_dir="$param_prog" + param_prog="" + fi + fi + fi + if [[ $param_dir =~ $regex ]] then # Link is valid URL so try to download file @@ -460,6 +469,15 @@ function prepare_input { stdout "${B_INFO}This may take a while...${E_INFO}\n" mkdir "$folder_loc" unzip -q "$param_dir" -d "$folder_loc" + unpackage_status=$? + if [[ ! "$unpackage_status" = "0" ]]; then + unrar "$param_dir" "$folder_loc" + unpackage_status=$? + fi + if [[ ! "$unpackage_status" = "0" ]]; then + unp "$param_dir" "$folder_loc" + unpackage_status=$? + fi fi update_loc "$folder_loc" @@ -475,6 +493,17 @@ function prepare_input { fi fi + + # Look for utest.yaml inside test directory + if [[ -f "${param_dir}/utest.yaml" ]]; then + if [[ -f "./utest.yaml" ]]; then + stdout "${B_DEBUG}Found utest.yaml inside tests folder. But yaml file is already present.${E_DEBUG}\n" + else + stdout "${B_DEBUG}Found utest.yaml inside tests folder. Copy it.${E_DEBUG}\n" + cp -n "${param_dir}/utest.yaml" "./utest.yaml" + load_global_configuration_file + fi + fi } function autofind_tests {