Исправлен makefile и тесты.
All checks were successful
drawio-export/pipeline/head This commit looks good
All checks were successful
drawio-export/pipeline/head This commit looks good
This commit is contained in:
parent
3890a96812
commit
e81e76c611
21
makefile
21
makefile
@ -51,6 +51,7 @@ WHITE := $(shell tput -Txterm setaf 7)
|
|||||||
CYAN := $(shell tput -Txterm setaf 6)
|
CYAN := $(shell tput -Txterm setaf 6)
|
||||||
RESET := $(shell tput -Txterm sgr0)
|
RESET := $(shell tput -Txterm sgr0)
|
||||||
|
|
||||||
|
.DEFAULT_GOAL := all
|
||||||
.PHONY: all version version-number test build dist vendor package pkg-deb
|
.PHONY: all version version-number test build dist vendor package pkg-deb
|
||||||
|
|
||||||
version: ## Version of the project to be built
|
version: ## Version of the project to be built
|
||||||
@ -81,7 +82,7 @@ dist: ## Create all distro packages
|
|||||||
|
|
||||||
vendor: ## Copy of all packages needed to support builds and tests in the vendor directory
|
vendor: ## Copy of all packages needed to support builds and tests in the vendor directory
|
||||||
$(GOCMD) mod vendor
|
$(GOCMD) mod vendor
|
||||||
@echo "Vendor\t\t${GREEN}[OK]${RESET}"
|
@$(ECHO_CMD) "Vendor\t\t${GREEN}[OK]${RESET}"
|
||||||
|
|
||||||
clean: ## Remove build related files
|
clean: ## Remove build related files
|
||||||
@rm -fr $(TMPDIR)
|
@rm -fr $(TMPDIR)
|
||||||
@ -145,7 +146,7 @@ ifeq ($(EXPORT_RESULT), true)
|
|||||||
$(eval OUTPUT_OPTIONS = | go-junit-report -set-exit-code > $(OUTDIR)/junit-report.xml)
|
$(eval OUTPUT_OPTIONS = | go-junit-report -set-exit-code > $(OUTDIR)/junit-report.xml)
|
||||||
endif
|
endif
|
||||||
$(GOTEST) -v $(GO_OPT) ./... $(OUTPUT_OPTIONS)
|
$(GOTEST) -v $(GO_OPT) ./... $(OUTPUT_OPTIONS)
|
||||||
@echo "Test\t\t${GREEN}[OK]${RESET}"
|
@$(ECHO_CMD) "Test\t\t${GREEN}[OK]${RESET}"
|
||||||
|
|
||||||
coverage: ## Run the tests of the project and export the coverage report.
|
coverage: ## Run the tests of the project and export the coverage report.
|
||||||
@mkdir -p out
|
@mkdir -p out
|
||||||
@ -158,11 +159,11 @@ else
|
|||||||
gocov convert $(OUTDIR)/profile.cov | gocov-xml > $(OUTDIR)/coverage.xml
|
gocov convert $(OUTDIR)/profile.cov | gocov-xml > $(OUTDIR)/coverage.xml
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@echo "Coverage\t${GREEN}[OK]${RESET}"
|
@$(ECHO_CMD) "Coverage\t${GREEN}[OK]${RESET}"
|
||||||
|
|
||||||
## Lint:
|
## Lint:
|
||||||
lint: lint-go ## Run all available linters.
|
lint: lint-go ## Run all available linters.
|
||||||
@echo "Lint\t\t${GREEN}[OK]${RESET}"
|
@$(ECHO_CMD) "Lint\t\t${GREEN}[OK]${RESET}"
|
||||||
|
|
||||||
lint-go:
|
lint-go:
|
||||||
go fmt ./...
|
go fmt ./...
|
||||||
@ -170,7 +171,7 @@ lint-go:
|
|||||||
|
|
||||||
## Documentation:
|
## Documentation:
|
||||||
doc: doc-golds ## Generate all documents.
|
doc: doc-golds ## Generate all documents.
|
||||||
@echo "Doc\t\t${GREEN}[OK]${RESET}"
|
@$(ECHO_CMD) "Doc\t\t${GREEN}[OK]${RESET}"
|
||||||
|
|
||||||
doc-common:
|
doc-common:
|
||||||
@mkdir -p $(DOC_DIR)
|
@mkdir -p $(DOC_DIR)
|
||||||
@ -182,11 +183,11 @@ doc-golds: doc-common ## Generate HTML documentation with Golds.
|
|||||||
|
|
||||||
## Help:
|
## Help:
|
||||||
help: ## Show this help.
|
help: ## Show this help.
|
||||||
@echo ''
|
@$(ECHO_CMD) ''
|
||||||
@echo 'Usage:'
|
@$(ECHO_CMD) 'Usage:'
|
||||||
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
|
@$(ECHO_CMD) ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
|
||||||
@echo ''
|
@$(ECHO_CMD) ''
|
||||||
@echo 'Targets:'
|
@$(ECHO_CMD) 'Targets:'
|
||||||
@awk 'BEGIN {FS = ":.*?## "} { \
|
@awk 'BEGIN {FS = ":.*?## "} { \
|
||||||
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
|
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
|
||||||
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
|
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
|
||||||
|
@ -137,7 +137,7 @@ var testData = []exportTest{
|
|||||||
diagrams: []string{"1", "2", "3"},
|
diagrams: []string{"1", "2", "3"},
|
||||||
commands: []command{
|
commands: []command{
|
||||||
{
|
{
|
||||||
cmd: "/usr/bin/drawio",
|
cmd: "drawio",
|
||||||
args: []string{
|
args: []string{
|
||||||
"drawio", "--page-index", "0",
|
"drawio", "--page-index", "0",
|
||||||
"--output", "export/diagrams-1.pdf",
|
"--output", "export/diagrams-1.pdf",
|
||||||
@ -145,7 +145,7 @@ var testData = []exportTest{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cmd: "/usr/bin/drawio",
|
cmd: "drawio",
|
||||||
args: []string{
|
args: []string{
|
||||||
"drawio", "--page-index", "1",
|
"drawio", "--page-index", "1",
|
||||||
"--output", "export/diagrams-2.pdf",
|
"--output", "export/diagrams-2.pdf",
|
||||||
@ -153,7 +153,7 @@ var testData = []exportTest{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cmd: "/usr/bin/drawio",
|
cmd: "drawio",
|
||||||
args: []string{
|
args: []string{
|
||||||
"drawio", "--page-index", "2",
|
"drawio", "--page-index", "2",
|
||||||
"--output", "export/diagrams-3.pdf",
|
"--output", "export/diagrams-3.pdf",
|
||||||
@ -222,7 +222,7 @@ var testData = []exportTest{
|
|||||||
diagrams: []string{"1", "2", "3"},
|
diagrams: []string{"1", "2", "3"},
|
||||||
commands: []command{
|
commands: []command{
|
||||||
{
|
{
|
||||||
cmd: "/usr/bin/drawio",
|
cmd: "drawio",
|
||||||
args: []string{
|
args: []string{
|
||||||
"drawio", "--page-index", "0",
|
"drawio", "--page-index", "0",
|
||||||
"--output", "export/diagrams-1.pdf",
|
"--output", "export/diagrams-1.pdf",
|
||||||
@ -230,7 +230,7 @@ var testData = []exportTest{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cmd: "/usr/bin/drawio",
|
cmd: "drawio",
|
||||||
args: []string{
|
args: []string{
|
||||||
"drawio", "--page-index", "1",
|
"drawio", "--page-index", "1",
|
||||||
"--output", "export/diagrams-2.pdf",
|
"--output", "export/diagrams-2.pdf",
|
||||||
@ -238,7 +238,7 @@ var testData = []exportTest{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cmd: "/usr/bin/drawio",
|
cmd: "drawio",
|
||||||
args: []string{
|
args: []string{
|
||||||
"drawio", "--page-index", "2",
|
"drawio", "--page-index", "2",
|
||||||
"--output", "export/diagrams-3.pdf",
|
"--output", "export/diagrams-3.pdf",
|
||||||
@ -261,7 +261,7 @@ var testData = []exportTest{
|
|||||||
diagrams: []string{"Один", "Два"},
|
diagrams: []string{"Один", "Два"},
|
||||||
commands: []command{
|
commands: []command{
|
||||||
{
|
{
|
||||||
cmd: "/usr/bin/drawio",
|
cmd: "drawio",
|
||||||
args: []string{
|
args: []string{
|
||||||
"drawio", "--page-index", "0",
|
"drawio", "--page-index", "0",
|
||||||
"--output", "export/additional-Один.pdf",
|
"--output", "export/additional-Один.pdf",
|
||||||
@ -269,7 +269,7 @@ var testData = []exportTest{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cmd: "/usr/bin/drawio",
|
cmd: "drawio",
|
||||||
args: []string{
|
args: []string{
|
||||||
"drawio", "--page-index", "1",
|
"drawio", "--page-index", "1",
|
||||||
"--output", "export/additional-Два.pdf",
|
"--output", "export/additional-Два.pdf",
|
||||||
@ -293,7 +293,7 @@ var testData = []exportTest{
|
|||||||
diagrams: []string{"Первая диаграмма", "Вторая диаграмма"},
|
diagrams: []string{"Первая диаграмма", "Вторая диаграмма"},
|
||||||
commands: []command{
|
commands: []command{
|
||||||
{
|
{
|
||||||
cmd: "/usr/bin/drawio",
|
cmd: "drawio",
|
||||||
args: []string{
|
args: []string{
|
||||||
"drawio", "--page-index", "0",
|
"drawio", "--page-index", "0",
|
||||||
"--output", "export/subdir/Вложенные диаграммы-Первая диаграмма.pdf",
|
"--output", "export/subdir/Вложенные диаграммы-Первая диаграмма.pdf",
|
||||||
@ -301,7 +301,7 @@ var testData = []exportTest{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cmd: "/usr/bin/drawio",
|
cmd: "drawio",
|
||||||
args: []string{
|
args: []string{
|
||||||
"drawio", "--page-index", "1",
|
"drawio", "--page-index", "1",
|
||||||
"--output", "export/subdir/Вложенные диаграммы-Вторая диаграмма.pdf",
|
"--output", "export/subdir/Вложенные диаграммы-Вторая диаграмма.pdf",
|
||||||
@ -314,6 +314,18 @@ var testData = []exportTest{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Инициализация тестовых данных
|
||||||
|
func init() {
|
||||||
|
for _, test := range testData {
|
||||||
|
for _, src := range test.files {
|
||||||
|
for i := range src.commands {
|
||||||
|
cmd := exec.Command("drawio")
|
||||||
|
src.commands[i].cmd = cmd.Path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestDiagrams(t *testing.T) {
|
func TestDiagrams(t *testing.T) {
|
||||||
for _, test := range testData {
|
for _, test := range testData {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
@ -108,11 +108,10 @@ func (opts Options) App() string {
|
|||||||
if opts.EnableXvfb {
|
if opts.EnableXvfb {
|
||||||
return "xvfb-run"
|
return "xvfb-run"
|
||||||
}
|
}
|
||||||
app := opts.Application
|
if len(opts.Application) == 0 {
|
||||||
if len(app) == 0 {
|
|
||||||
return "drawio"
|
return "drawio"
|
||||||
}
|
}
|
||||||
return app
|
return opts.Application
|
||||||
}
|
}
|
||||||
|
|
||||||
// Путь к папке с экспортированными файлами
|
// Путь к папке с экспортированными файлами
|
||||||
@ -137,8 +136,10 @@ func (opts Options) OutExt() string {
|
|||||||
func (opts Options) Args() []string {
|
func (opts Options) Args() []string {
|
||||||
args := []string{}
|
args := []string{}
|
||||||
if opts.EnableXvfb {
|
if opts.EnableXvfb {
|
||||||
app := "drawio"
|
var app string
|
||||||
if len(opts.Application) > 0 {
|
if len(opts.Application) == 0 {
|
||||||
|
app = "drawio"
|
||||||
|
} else {
|
||||||
app = opts.Application
|
app = opts.Application
|
||||||
}
|
}
|
||||||
args = append(args, "-a", "-l", app)
|
args = append(args, "-a", "-l", app)
|
||||||
|
Loading…
Reference in New Issue
Block a user