Skip to content

Subsequent tests fail when one tests changes the directory in set_up_before_script #532

@sandr01d

Description

@sandr01d
Q A
OS Linux
Shell & version bash 5.3.8
bashunit version beta / 0.28.0

Summary

When changing the directory in set_up_before_script, subsequent tests in other files do not get executed.

How to reproduce

Create the following two files and run bashunit.

#!/usr/bin/env bash
# tests/change-dir.test.sh

function set_up_before_script() {
  cd "$(temp_dir)" || return 1
}

function test_a() {
  assert_equals a a
}
#!/bin/env bash
# tests/second-test.sh

test_b() {
  assert_equals b b
}

Expected behavior

Both tests should run and the output should look like this, like is the case when not changing directory in set_up_before_script:

bashunit - 0.28.0 | Tests: 2
Running tests/change-dir.test.sh
✓ Passed: A                                                                                                                                                                                                                                                                24 ms

Running tests/second-test.sh
✓ Passed: B                                                                                                                                                                                                                                                                25 ms

Tests:      2 passed, 2 total
Assertions: 2 passed, 2 total

Actual Behavior

Only test_a runs and the output looks like this:

bashunit - 0.28.0 | Tests: 2
Running tests/change-dir.test.sh
grep: tests/change-dir.test.sh: No such file or directory
✓ Passed: A                                                                                                                                                                                                                                                                24 ms

Tests:      1 passed, 1 total
Assertions: 1 passed, 1 total

 All tests passed
Time taken: 99 m

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions