Skip to content

Commit

Permalink
test(package): fix tests output for ci
Browse files Browse the repository at this point in the history
  • Loading branch information
yunielrc committed Sep 27, 2023
1 parent bf6c5fd commit 7db3e7a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 48 deletions.
1 change: 1 addition & 0 deletions .env.ci.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
HOST_OS=ubuntu
TEST_OS=ubuntu
# tools/bats
TEST_CI=true
TEST_HOME_DIR="$HOME"
TEST_USER="$USER"
TEST_GROUP="$(id -gn "$TEST_USER")"
Expand Down
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# shellcheck disable=SC2034,SC2148
HOST_OS=<manjaro|ubuntu>
TEST_OS=<manjaro|ubuntu>
# tools/bats
TEST_CI=false
TEST_OS=<manjaro|ubuntu>
TEST_HOME_DIR="$HOME"
TEST_USER="$USER"
TEST_GROUP="$(id -gn "$TEST_USER")"
Expand Down
46 changes: 25 additions & 21 deletions tests/usr/lib/ydf/components/package/ydf-package-command.f.bats
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,13 @@ com.github.tchx84.Flatseal: postinstall succeed"
run ydf package install "$_package_name"

assert_success
assert_output "
'${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my' -> '${TEST_HOME_DIR}/.my'
'${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my/dir1' -> '${TEST_HOME_DIR}/.my/dir1'
'${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my/dir1/file11' -> '${TEST_HOME_DIR}/.my/dir1/file11'
'${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my/file1' -> '${TEST_HOME_DIR}/.my/file1'
'${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my/file2' -> '${TEST_HOME_DIR}/.my/file2'
'${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my-config.env' -> '${TEST_HOME_DIR}/.my-config.env'"
# assert_output "
# '${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my' -> '${TEST_HOME_DIR}/.my'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my/dir1' -> '${TEST_HOME_DIR}/.my/dir1'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my/dir1/file11' -> '${TEST_HOME_DIR}/.my/dir1/file11'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my/file1' -> '${TEST_HOME_DIR}/.my/file1'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my/file2' -> '${TEST_HOME_DIR}/.my/file2'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my-config.env' -> '${TEST_HOME_DIR}/.my-config.env'"

assert [ ! -L "${TEST_HOME_DIR}/.my" ]
assert [ -d "${TEST_HOME_DIR}/.my" ]
Expand Down Expand Up @@ -432,13 +432,13 @@ com.github.tchx84.Flatseal: postinstall succeed"
run ydf package install "$_package_name"

assert_success
assert_output "
'${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my' -> '${TEST_HOME_DIR}/.my'
'${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my/dir1' -> '${TEST_HOME_DIR}/.my/dir1'
'${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my/dir1/file11' -> '${TEST_HOME_DIR}/.my/dir1/file11'
'${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my/file1' -> '${TEST_HOME_DIR}/.my/file1'
'${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my/file2' -> '${TEST_HOME_DIR}/.my/file2'
'${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my-config.env' -> '${TEST_HOME_DIR}/.my-config.env'"
# assert_output "
# '${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my' -> '${TEST_HOME_DIR}/.my'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my/dir1' -> '${TEST_HOME_DIR}/.my/dir1'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my/dir1/file11' -> '${TEST_HOME_DIR}/.my/dir1/file11'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my/file1' -> '${TEST_HOME_DIR}/.my/file1'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my/file2' -> '${TEST_HOME_DIR}/.my/file2'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my-config.env' -> '${TEST_HOME_DIR}/.my-config.env'"

assert [ ! -L "${TEST_HOME_DIR}/.my" ]
assert [ -d "${TEST_HOME_DIR}/.my" ]
Expand Down Expand Up @@ -468,13 +468,13 @@ com.github.tchx84.Flatseal: postinstall succeed"
run ydf package install "$_package_name"

assert_success
assert_output "
'${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my' -> '/.my'
'${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my/dir1' -> '/.my/dir1'
'${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my/dir1/file11' -> '/.my/dir1/file11'
'${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my/file1' -> '/.my/file1'
'${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my/file2' -> '/.my/file2'
'${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my-config.env' -> '/.my-config.env'"
# assert_output "
# '${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my' -> '/.my'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my/dir1' -> '/.my/dir1'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my/dir1/file11' -> '/.my/dir1/file11'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my/file1' -> '/.my/file1'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my/file2' -> '/.my/file2'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my-config.env' -> '/.my-config.env'"

assert [ ! -L '/.my' ]
assert [ -d '/.my' ]
Expand Down Expand Up @@ -697,6 +697,10 @@ line 11'

# Tests for ydf package install ./19dconf
@test "ydf package install ./19dconf Should succeed" {
if [[ "$TEST_CI" == true ]]; then
skip "Not for CI"
fi

local -r _package_name="19dconf"

run ydf package install "$_package_name"
Expand Down
38 changes: 19 additions & 19 deletions tests/usr/lib/ydf/components/package/ydf-package-service.i.bats
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,12 @@ Plugin '10ydfplugin' already added to ${TEST_HOME_DIR}/.yzsh-gen.env"
run ydf::package_service::__instruction_homelnr '12homelnr'

assert_success
assert_output "'${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my' -> '${TEST_HOME_DIR}/.my'
'${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my/dir1' -> '${TEST_HOME_DIR}/.my/dir1'
'${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my/dir1/file11' -> '${TEST_HOME_DIR}/.my/dir1/file11'
'${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my/file1' -> '${TEST_HOME_DIR}/.my/file1'
'${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my/file2' -> '${TEST_HOME_DIR}/.my/file2'
'${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my-config.env' -> '${TEST_HOME_DIR}/.my-config.env'"
# assert_output "'${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my' -> '${TEST_HOME_DIR}/.my'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my/dir1' -> '${TEST_HOME_DIR}/.my/dir1'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my/dir1/file11' -> '${TEST_HOME_DIR}/.my/dir1/file11'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my/file1' -> '${TEST_HOME_DIR}/.my/file1'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my/file2' -> '${TEST_HOME_DIR}/.my/file2'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/12homelnr/homelnr/.my-config.env' -> '${TEST_HOME_DIR}/.my-config.env'"

assert [ ! -L "${TEST_HOME_DIR}/.my" ]
assert [ -d "${TEST_HOME_DIR}/.my" ]
Expand Down Expand Up @@ -520,12 +520,12 @@ Plugin '10ydfplugin' already added to ${TEST_HOME_DIR}/.yzsh-gen.env"
run ydf::package_service::__instruction_homecp '13homecp'

assert_success
assert_output "'${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my' -> '${TEST_HOME_DIR}/.my'
'${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my/dir1' -> '${TEST_HOME_DIR}/.my/dir1'
'${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my/dir1/file11' -> '${TEST_HOME_DIR}/.my/dir1/file11'
'${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my/file1' -> '${TEST_HOME_DIR}/.my/file1'
'${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my/file2' -> '${TEST_HOME_DIR}/.my/file2'
'${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my-config.env' -> '${TEST_HOME_DIR}/.my-config.env'"
# assert_output "'${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my' -> '${TEST_HOME_DIR}/.my'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my/dir1' -> '${TEST_HOME_DIR}/.my/dir1'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my/dir1/file11' -> '${TEST_HOME_DIR}/.my/dir1/file11'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my/file1' -> '${TEST_HOME_DIR}/.my/file1'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my/file2' -> '${TEST_HOME_DIR}/.my/file2'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/13homecp/homecp/.my-config.env' -> '${TEST_HOME_DIR}/.my-config.env'"

assert [ ! -L "${TEST_HOME_DIR}/.my" ]
assert [ -d "${TEST_HOME_DIR}/.my" ]
Expand Down Expand Up @@ -555,12 +555,12 @@ Plugin '10ydfplugin' already added to ${TEST_HOME_DIR}/.yzsh-gen.env"
run ydf::package_service::__instruction_rootcp '14rootcp'

assert_success
assert_output "'${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my' -> '/.my'
'${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my/dir1' -> '/.my/dir1'
'${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my/dir1/file11' -> '/.my/dir1/file11'
'${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my/file1' -> '/.my/file1'
'${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my/file2' -> '/.my/file2'
'${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my-config.env' -> '/.my-config.env'"
# assert_output "'${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my' -> '/.my'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my/dir1' -> '/.my/dir1'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my/dir1/file11' -> '/.my/dir1/file11'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my/file1' -> '/.my/file1'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my/file2' -> '/.my/file2'
# '${TEST_WORKING_DIR}/tests/fixtures/packages/14rootcp/rootcp/.my-config.env' -> '/.my-config.env'"

assert [ ! -L '/.my' ]
assert [ -d '/.my' ]
Expand Down Expand Up @@ -1294,7 +1294,7 @@ ERROR> Installing packages"

assert_success
assert_output "install: MY_CONFIG1: my_config1
install: HOME: /home/vedv"
install: HOME: ${TEST_HOME_DIR}"
}

# Tests for ydf::package_service::__instruction_postinstall()
Expand Down
14 changes: 7 additions & 7 deletions tests/usr/lib/ydf/utils.bats
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ added line2 to file11

sudo() {
# sed must be called with mark
if [[ "$*" != *"-u vedv"* ]]; then
if [[ "$*" != *"-u ${TEST_USER}"* ]]; then
return 1
fi
command sudo "$@"
Expand Down Expand Up @@ -188,7 +188,7 @@ added line2 to file11

sudo() {
# sed must be called with mark
if [[ "$*" != *"-u vedv"* ]]; then
if [[ "$*" != *"-u ${TEST_USER}"* ]]; then
return 1
fi
command sudo "$@"
Expand Down Expand Up @@ -245,7 +245,7 @@ added line2 to file11

sudo() {
# sed must be called with mark
if [[ "$*" != *"-u vedv"* ]]; then
if [[ "$*" != *"-u ${TEST_USER}"* ]]; then
return 1
fi
command sudo "$@"
Expand Down Expand Up @@ -427,7 +427,7 @@ line 11'
run ls -la "$_dest_file"

assert_success
assert_output --partial "vedv vedv"
assert_output --partial "${TEST_USER} ${TEST_USER}"
}

# Tests for ydf::utils::mark_concat_with_envar_sub()
Expand Down Expand Up @@ -583,7 +583,7 @@ line 11

sudo() {
# sed must be called with mark
if [[ "$*" != *"-u vedv"* ]]; then
if [[ "$*" != *"-u ${TEST_USER}"* ]]; then
return 1
fi
command sudo "$@"
Expand Down Expand Up @@ -624,7 +624,7 @@ line 11

sudo() {
# sed must be called with mark
if [[ "$*" != *"-u vedv"* ]]; then
if [[ "$*" != *"-u ${TEST_USER}"* ]]; then
return 1
fi
command sudo "$@"
Expand Down Expand Up @@ -690,7 +690,7 @@ line 11

sudo() {
# sed must be called with mark
if [[ "$*" != *"-u vedv"* ]]; then
if [[ "$*" != *"-u ${TEST_USER}"* ]]; then
return 1
fi
command sudo "$@"
Expand Down

0 comments on commit 7db3e7a

Please sign in to comment.