[VOL-5272] - Fixed a problem with relative paths.
app-install.sh
Makefile
--------------
o Add SPDX copyright tags.
https://spdx.github.io/spdx-spec/v2.3/file-tags.
o Create named test-* targets so 'make test' can be conditional.
o No need to invoke tests/version-check for a non-release job.
app-install.sh
--------------
o set -euo pipefail to detect shell problems.
o Added ERR signal handler, display a stack trace for ($? != 0).
o Added args --download and --install to begin weakening dependency
on global variables.
o Script now verbose when run. Display banners, paths, artifacts, etc.
o Replace cp with "rsync --checksum" everywhere for file copying.
o Display contents of app.xml when unable to parse name=.
Also display grep and sed output then fail hard.
test
test/bats/makefile
test/bats/display-help.sh
-------------------------
o Add initial support for the bats testing harness (shell scripts).
o Create a stub unit test directory to automate testing app-install.sh
Change-Id: I138fd2218a10121fbcce4fa8dbcf5776278d05ac
diff --git a/test/bats/display-help.sh b/test/bats/display-help.sh
new file mode 100755
index 0000000..4edf068
--- /dev/null
+++ b/test/bats/display-help.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bats
+# -----------------------------------------------------------------------
+# Copyright 2024 Open Networking Foundation Contributors
+#
+# 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.
+# -----------------------------------------------------------------------
+# SPDX-FileCopyrightText: 2024 Open Networking Foundation Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+# load 'libs/bats-support/load'
+# load 'libs/bats-assert/load'
+
+@test "Verify option --help" {
+ run bash ../../app-install.sh --fail
+ [ "$status" -eq 99 ] # non-zero exit status
+
+ run bash ../../app-install.sh --pass
+ [ "$status" -eq 0 ]
+
+# declare -i result="$(../../app-install.sh --pass)"
+# assert_output -p "Usage app-install.sh"
+}
+
+# [SEE ALSO]
+# * https://opensource.com/article/19/2/te
+
+# [EOF]
diff --git a/test/bats/makefile b/test/bats/makefile
new file mode 100644
index 0000000..9da1e29
--- /dev/null
+++ b/test/bats/makefile
@@ -0,0 +1,26 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2016-2024 Open Networking Foundation Contributors
+#
+# 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.
+# -----------------------------------------------------------------------
+# SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation Contributors
+# SPDX-License-Identifier: Apache-2.0
+# -----------------------------------------------------------------------
+
+all:
+
+test ::
+ $(HIDE)./display-help.sh
+
+# end file
diff --git a/test/bats/urls b/test/bats/urls
new file mode 100644
index 0000000..e010974
--- /dev/null
+++ b/test/bats/urls
@@ -0,0 +1,2 @@
+https://opensource.com/article/19/2/testing-bash-bats
+https://github.com/ztombol/bats-assert