-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
34 lines (28 loc) · 2.96 KB
/
Makefile
File metadata and controls
34 lines (28 loc) · 2.96 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
BINARY = webview-cli
SRC = src/main.swift
FRAMEWORKS = -framework WebKit -framework AppKit
SWIFTFLAGS = -O -target arm64-apple-macos12.0
.PHONY: build clean install test
build: $(BINARY)
$(BINARY): $(SRC)
swiftc $(SWIFTFLAGS) $(FRAMEWORKS) $(SRC) -o $(BINARY)
clean:
rm -f $(BINARY)
install: $(BINARY)
mkdir -p $(HOME)/bin
cp $(BINARY) $(HOME)/bin/$(BINARY)
test: $(BINARY)
@python3 scripts/check-js-syntax.py || (echo "FAIL: embedded JS has syntax errors (see above)" && exit 1)
@node scripts/runtime-smoke.mjs || (echo "FAIL: runtime smoke (see above) — embedded JS functionally broken" && exit 1)
@./$(BINARY) --help 2>&1 >/dev/null | head -1 | grep -q Usage && echo "PASS: --help prints usage to stderr" || (echo "FAIL: --help" && exit 1)
@echo '{}' | ./$(BINARY) --a2ui --timeout 1 2>/dev/null | grep -q status && echo "PASS: a2ui smoke" || (echo "FAIL: a2ui smoke" && exit 1)
@./$(BINARY) --url "not-a-valid-url" 2>/dev/null | grep -q '"error"' && echo "PASS: invalid URL emits error JSON" || (echo "FAIL: invalid URL" && exit 1)
@./$(BINARY) --markdown --timeout 1 2>&1 | grep -q '"error"' && ! ./$(BINARY) --markdown --timeout 1 2>&1 | grep -qi "unknown" && echo "PASS: --markdown alone fails at runtime (URL required), not at parse" || (echo "FAIL: --markdown alone" && exit 1)
@./$(BINARY) --markdown --comments --edits --timeout 1 2>&1 | grep -q '"error"' && ! ./$(BINARY) --markdown --comments --edits --timeout 1 2>&1 | grep -qi "unknown" && echo "PASS: --markdown --comments --edits fail at runtime (URL required), not at parse" || (echo "FAIL: --markdown --comments --edits" && exit 1)
@./$(BINARY) --markdown --a2ui 2>&1 | grep -q "mutually exclusive" && echo "PASS: --markdown --a2ui rejects with error" || (echo "FAIL: --markdown --a2ui mutual exclusion" && exit 1)
@strings $(BINARY) | grep -q micromark && echo "PASS: micromark embedded in binary" || (echo "FAIL: micromark not found" && exit 1)
@strings $(BINARY) | grep -q renderMarkdown && echo "PASS: renderMarkdown function embedded in binary" || (echo "FAIL: renderMarkdown not found" && exit 1)
@echo '{"surfaceUpdate":{"components":[{"id":"root","component":{"Column":{"children":{"explicitList":["doc","btn"]}}}},{"id":"doc","component":{"MarkdownDoc":{"fieldName":"review","text":"# Hi\n\nHello."}}},{"id":"btn","component":{"Button":{"label":{"literalString":"OK"},"action":{"name":"ok"}}}}]}}{"beginRendering":{"root":"root"}}' | ./$(BINARY) --a2ui --timeout 1 2>&1 | grep -qv '"error"' && echo "PASS: MarkdownDoc renders without error" || (echo "FAIL: MarkdownDoc errored" && exit 1)
@echo '# Hi' | ./$(BINARY) --markdown --timeout 1 2>/dev/null | grep -qv '"error"' && echo "PASS: --markdown stdin test with heading renders" || (echo "FAIL: --markdown stdin rendering" && exit 1)
@printf '' | ./$(BINARY) --markdown --timeout 1 2>/dev/null | grep -q 'no markdown provided on stdin' && echo "PASS: empty markdown stdin yields error message" || (echo "FAIL: empty markdown stdin" && exit 1)
@echo "All smoke tests pass"