diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..dedb624 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "test/libs/bats"] + path = test/libs/bats + url = https://github.com/sstephenson/bats +[submodule "test/libs/bats-assert"] + path = test/libs/bats-assert + url = https://github.com/ztombol/bats-assert +[submodule "test/libs/bats-support"] + path = test/libs/bats-support + url = https://github.com/ztombol/bats-support diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b589ccf --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +# travis does not offer python container for OSX or Windows, not sure if we can get automated testing? +os: linux +language: python +python: + - "3.6" +dist: bionic +install: + - pip install -r requirements.txt +script: ./test.sh diff --git a/bashtop b/bashtop index ee4c6fe..2f07e3c 100755 --- a/bashtop +++ b/bashtop @@ -4822,6 +4822,10 @@ else exec 2>/dev/null fi + +#* if we have been sourced by another shell, quit. Allows sourcing only function definition. +[[ "${#BASH_SOURCE[@]}" -gt 1 ]] && { return 0; } + #* Call init function init_ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..24156d6 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +psutil==5.7.0 diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..958110a --- /dev/null +++ b/test.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +./test/libs/bats/bin/bats test/*.bats diff --git a/test/basic_test.bats b/test/basic_test.bats new file mode 100644 index 0000000..e159b6f --- /dev/null +++ b/test/basic_test.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats + +load 'libs/bats-support/load' +load 'libs/bats-assert/load' + +load test_helper + +@test "Sourcing works, by checking if \$system is set" { + run echo $system + refute_output "" +} + +@test "#get_themes populates themes" { + get_themes + assert_success + assert [ ${#themes[@]} -gt 0 ] +} diff --git a/test/libs/bats b/test/libs/bats new file mode 160000 index 0000000..0360811 --- /dev/null +++ b/test/libs/bats @@ -0,0 +1 @@ +Subproject commit 03608115df2071fff4eaaff1605768c275e5f81f diff --git a/test/libs/bats-assert b/test/libs/bats-assert new file mode 160000 index 0000000..9f88b42 --- /dev/null +++ b/test/libs/bats-assert @@ -0,0 +1 @@ +Subproject commit 9f88b4207da750093baabc4e3f41bf68f0dd3630 diff --git a/test/libs/bats-support b/test/libs/bats-support new file mode 160000 index 0000000..004e707 --- /dev/null +++ b/test/libs/bats-support @@ -0,0 +1 @@ +Subproject commit 004e707638eedd62e0481e8cdc9223ad471f12ee diff --git a/test/test_helper.bash b/test/test_helper.bash new file mode 100644 index 0000000..d173159 --- /dev/null +++ b/test/test_helper.bash @@ -0,0 +1 @@ +source bashtop