forked from exyte/SVGView
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (42 loc) · 2.02 KB
/
Makefile
File metadata and controls
48 lines (42 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Derived values (DO NOT TOUCH).
CURRENT_MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
CURRENT_MAKEFILE_DIR := $(patsubst %/,%,$(dir $(CURRENT_MAKEFILE_PATH)))
# If no target is specified, display help
.DEFAULT_GOAL := help
help: # Display this help.
@-+echo "Run make with one of the following targets:"
@-+echo
@-+grep -Eh "^[a-z-]+:.*#" $(CURRENT_MAKEFILE_PATH) | sed -E 's/^(.*:)(.*#+)(.*)/ \1 @@@ \3 /' | column -t -s "@@@"
test: # Run tests
swift test
generate-test-cases: # Generate test cases from w3c reference files
@cd Tests/SVGViewTests && \
generateTest() { \
local dir=$$1; \
local class=$$2; \
printf "// Generated by make generate-test-cases\n\n" > ../SVGViewTests/$$class.swift; \
printf "import XCTest\n" >> ../SVGViewTests/$$class.swift; \
printf "@testable import SVGView\n\n" >> ../SVGViewTests/$$class.swift; \
printf "class $$class: BaseTestCase {\n\n" >> ../SVGViewTests/$$class.swift; \
printf " override var dir: String {\n" >> ../SVGViewTests/$$class.swift; \
printf " return \"$$dir\"\n" >> ../SVGViewTests/$$class.swift; \
printf " }\n\n" >> ../SVGViewTests/$$class.swift; \
find "w3c/$$dir/refs/" -type f -regex '.*\.ref$$' | sort | while read ref_file; do \
name=$$(basename "$${ref_file%.*}"); \
test_name=""; \
IFS='-' read -ra arr <<< "$$name"; \
for part in "$${arr[@]}"; do \
test_name+=$$(printf "%s" "$${part:0:1}" | tr '[:lower:]' '[:upper:]')$${part:1}; \
done; \
printf " func test$$test_name() {\n" >> ../SVGViewTests/$$class.swift; \
printf " compareToReference(\"$$name\")\n" >> ../SVGViewTests/$$class.swift; \
printf " }\n\n" >> ../SVGViewTests/$$class.swift; \
done; \
printf "}" >> ../SVGViewTests/$$class.swift; \
}; \
generateTest "1.1F2" "SVG11Tests"; \
generateTest "1.2T" "SVG12Tests"; \
generateTest "Custom" "SVGCustomTests"
update-references-snapshots: # Update .ref from .svg files
swift run GenerateReferencesCLI Tests/SVGViewTests/w3c/
.PHONY: help test generate-test-cases update-references-snapshots