Expected Behavior
make test covers the packages the CLI ships, and every test in the repository passes.
Actual Behavior
The test target runs ./pkg/... only:
test: test-deps
gotestsum --jsonfile $(TEST_OUTPUT_FILE) --format standard-quiet -- ./pkg/... $(COVERAGE_OPTS)
./utils/... is therefore never executed by CI, and three of its tests fail today on a clean checkout of master:
$ go test ./utils/
--- FAIL: TestValidateFilePaths (0.00s)
--- FAIL: TestValidateFilePaths/valid_file_path (0.00s)
--- FAIL: TestGetAbsPath (0.00s)
--- FAIL: TestGetAbsPath/absolute_path (0.00s)
--- FAIL: TestReadFile (0.00s)
--- FAIL: TestReadFile/valid_file_path (0.00s)
FAIL github.com/dapr/cli/utils
Two of the three are not platform specific. TestValidateFilePaths and TestReadFile create a temp fixture and remove it with defer, while their subtests call t.Parallel(). A parallel subtest is paused until its parent function returns, so the deferred cleanup deletes the fixture before any subtest runs, and the "valid file path" cases end up asserting an error that only proves the file is already gone. Confirmed on linux/amd64 as well:
$ ./utils.test
--- FAIL: TestValidateFilePaths (0.01s)
--- FAIL: TestReadFile (0.00s)
FAIL
TestFindFileInDir in the same file already uses t.Cleanup for this reason.
TestGetAbsPath fails on Windows only: the "absolute path" case uses /absolute/path, which has no volume name, so filepath.IsAbs reports false for it and GetAbsPath joins it with baseDir.
Steps to Reproduce the Problem
git clone https://github.com/dapr/cli && cd cli
go test ./utils/
Release Note
RELEASE NOTE: FIX Broken tests in the utils package, and run that package in CI.
Expected Behavior
make testcovers the packages the CLI ships, and every test in the repository passes.Actual Behavior
The
testtarget runs./pkg/...only:./utils/...is therefore never executed by CI, and three of its tests fail today on a clean checkout of master:Two of the three are not platform specific.
TestValidateFilePathsandTestReadFilecreate a temp fixture and remove it withdefer, while their subtests callt.Parallel(). A parallel subtest is paused until its parent function returns, so the deferred cleanup deletes the fixture before any subtest runs, and the "valid file path" cases end up asserting an error that only proves the file is already gone. Confirmed on linux/amd64 as well:TestFindFileInDirin the same file already usest.Cleanupfor this reason.TestGetAbsPathfails on Windows only: the "absolute path" case uses/absolute/path, which has no volume name, sofilepath.IsAbsreports false for it andGetAbsPathjoins it withbaseDir.Steps to Reproduce the Problem
git clone https://github.com/dapr/cli && cd cligo test ./utils/Release Note
RELEASE NOTE: FIX Broken tests in the
utilspackage, and run that package in CI.