bugfix: use cross-platform module filepath to set usedConfigDir (#369)

* bugfix: use filepath to set correct configDir in Windows

* test: improve unittest rep folder creation

---------

Co-authored-by: wushuzh <wushuzh@outlook.com>
This commit is contained in:
wushuzh 2024-07-22 17:33:56 +08:00 committed by GitHub
parent d0eb132b95
commit ffcd19e748
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 5 deletions

View File

@ -31,7 +31,8 @@ daemon-codestyle:
gocritic check ./...
daemon-unittests:
mkdir -p reports
$(call delete-files,reports)
mkdir reports
go test ./... -coverprofile reports/unittests.out
go tool cover -html=reports/unittests.out -o reports/unittests.html

View File

@ -4,7 +4,7 @@ test-install:
npm install --no-fund
test-run:
./node_modules/.bin/mocha -t 10000
npx mocha -t 10000
find-flakey-tests:
echo "Running test-run infinately"

View File

@ -4,9 +4,10 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
log "github.com/sirupsen/logrus"
"os"
"path"
"path/filepath"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
@ -38,7 +39,7 @@ func Reload(cfg *Config) {
metricConfigReloadedCount.Inc()
metricConfigActionCount.Set(float64(len(cfg.Actions)))
cfg.SetDir(path.Dir(viper.ConfigFileUsed()))
cfg.SetDir(filepath.Dir(viper.ConfigFileUsed()))
cfg.Sanitize()
for _, l := range listeners {