Parcourir la source

fix: add Makefile for easy testing

* unit test are not all covered
* only selective ones were tested now
sdsadfaf il y a 3 ans
Parent
commit
dd1ddea7e3
2 fichiers modifiés avec 69 ajouts et 0 suppressions
  1. 32 0
      Makefile
  2. 37 0
      scripts/temp-test.sh

+ 32 - 0
Makefile

@@ -0,0 +1,32 @@
+# A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
+# see https://github.com/mongodb/mongocli/blob/master/Makefile
+
+TEST_CMD?=go test
+UNIT_TAGS?=unit
+INTEGRATION_TAGS?=integration
+
+.PHONY: dltest
+dltest: ## Clone test sample files
+	@echo "==> Cloning test sample files..."
+	git clone https://github.com/wyq977/CSFTestFiles.git TestData
+
+.PHONY: test
+test: temp-test
+
+.PHONY: temp-test
+temp-test: ## [TEMP] Run simple test scripts
+	@scripts/temp-test.sh
+
+# .PHONY: unit-test
+# unit-test: ## Run unit-tests
+# 	@echo "==> Running unit tests..."
+# 	$(TEST_CMD) --tags="$(UNIT_TAGS)" -race -cover -count=1 -coverprofile $(COVERAGE) ./internal...
+
+.PHONY: list
+list: ## List all make targets
+	@${MAKE} -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | sort
+
+.PHONY: help
+.DEFAULT_GOAL := help
+help:
+	@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

+ 37 - 0
scripts/temp-test.sh

@@ -0,0 +1,37 @@
+#!/bin/sh
+
+cd "$(dirname "${BASH_SOURCE[0]}")" && cd .. 
+echo "==> Running selective tests..."
+go test ./internal/pkg/archive_helper/
+# go test ./internal/pkg/calculate_curve_correlation # fail
+# go test ./internal/pkg/config
+# go test ./internal/pkg/debug_view
+go test ./internal/pkg/decode
+go test ./internal/pkg/dtw
+# go test ./internal/pkg/emby_api # fail
+# go test ./internal/pkg/ffmpeg_helper # fail
+# go test ./internal/pkg/frechet 
+# go test ./internal/pkg/global_value
+go test ./internal/pkg/gss
+# go test ./internal/pkg/hot_fix
+go test ./internal/pkg/imdb_helper
+# go test ./internal/pkg/language
+# go test ./internal/pkg/log_helper
+go test ./internal/pkg/my_util # will produce Log dir
+# go test ./internal/pkg/proxy_helper # fail
+# go test ./internal/pkg/random_useragent
+# go test ./internal/pkg/regex_things
+# go test ./internal/pkg/rod_helper # fail
+# go test ./internal/pkg/sqlite
+# go test ./internal/pkg/sub_formatter
+# go test ./internal/pkg/sub_helper
+# go test ./internal/pkg/sub_parser_hub
+# go test ./internal/pkg/sub_timeline_fixer # fail
+go test ./internal/pkg/vad
+# go test ./internal/pkg/vosk_api
+
+# 1. emby_api_test: need emby
+# 2. ffmpeg_helper: will generate test files
+# 3. sub_timeline_change/sub_format_changer_test.go wrong other normal
+
+echo "==> Done..."