Files
css/Makefile
T
waozi 3a90196f28 Check that formatting keeps form feeds and vertical tabs inside quotes
The fuzz check now ignores vertical tab and form feed as the lexer
does, so it cannot see them vanish from quoted text. This test formats
a sheet with both inside a quoted value and requires the formatter to
copy them through.
2026-09-29 21:35:11 -03:00

66 lines
2.7 KiB
Makefile

.DEFAULT_GOAL := check
ZIRAN ?= ziran
CC ?= cc
BUILD := build
FUZZ_SEED ?= 1
FUZZ_COUNT ?= 2000
STYLE_PACKS := classic
STYLE_PACK_TOOL := $(BUILD)/tools/style_pack_module
.PHONY: check test style-packs style-pack-check fuzz clean
check: test style-pack-check fuzz
test:
$(ZIRAN) check --project
$(ZIRAN) bundle --project --entry style_parse_behavior:Answer \
-o $(BUILD)/style-parse.zib tests/style_parse_behavior.zi
test "$$($(ZIRAN) run --project $(BUILD)/style-parse.zib)" = 42
# The fuzz check ignores whitespace the lexer skips; quoted text keeps it.
$(ZIRAN) bundle --project --entry format_quoted_whitespace:main \
-o $(BUILD)/format-quoted-whitespace.zib tests/format_quoted_whitespace.zi
test "$$($(ZIRAN) run --project $(BUILD)/format-quoted-whitespace.zib)" = 0
rm -rf $(BUILD)/style-parse-c
$(ZIRAN) build --project --target=c --entry style_parse_behavior:Answer \
-o $(BUILD)/style-parse-c tests/style_parse_behavior.zi
printf '#include "style_parse_behavior.h"\nint main(void) { return Answer() == 42 ? 0 : 1; }\n' \
> $(BUILD)/style-parse-c/main.c
$(CC) -std=c11 -I$$($(ZIRAN) pkg path ziran)/include -I$(BUILD)/style-parse-c \
$(BUILD)/style-parse-c/*.c -o $(BUILD)/style-parse
$(BUILD)/style-parse
# The whole classic pack is more than the portable runner's step
# budget, so the system style test runs as native code.
rm -rf $(BUILD)/system-style-c
$(ZIRAN) build --project --target=c --entry system_style_behavior:main \
-o $(BUILD)/system-style-c tests/system_style_behavior.zi
$(CC) -std=c11 -I$$($(ZIRAN) pkg path ziran)/include -I$(BUILD)/system-style-c \
$(BUILD)/system-style-c/*.c -o $(BUILD)/system-style
$(BUILD)/system-style
# Style packs apps can install without the .kss file. Their modules are
# committed, because apps import KSS as a package without running this
# Makefile; style-pack-check fails when a module no longer matches its pack.
$(STYLE_PACK_TOOL): tools/style_pack_module.zi
rm -rf $@-c
mkdir -p $(dir $@)
$(ZIRAN) build --project --target=c --entry style_pack_module:main \
-o $@-c tools/style_pack_module.zi
$(CC) -std=c11 -O2 -I$$($(ZIRAN) pkg path ziran)/include -I$@-c $@-c/*.c -o $@
style-packs: $(STYLE_PACK_TOOL)
@for pack in $(STYLE_PACKS); do $(STYLE_PACK_TOOL) write $$pack || exit 1; done
style-pack-check: $(STYLE_PACK_TOOL)
@for pack in $(STYLE_PACKS); do $(STYLE_PACK_TOOL) check $$pack || exit 1; done
@echo "Style pack modules match: $(STYLE_PACKS)"
# Generated and damaged style sheets through the parser, the rule table,
# and the formatter, built with AddressSanitizer and UndefinedBehaviorSanitizer.
# The same seed makes the same sheets; see tests/kss_fuzz.zi.
fuzz:
@ZIRAN=$(ZIRAN) sh tests/kss_fuzz.sh $(FUZZ_SEED) $(FUZZ_COUNT)
clean:
rm -rf $(BUILD)