From e5aadc734909797f25057a795be0053669c80f1b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tina=20M=C3=BCller?= Date: Sat, 2 Dec 2017 01:06:12 +0100 Subject: [PATCH] Rewrite make test-suite No recursive make anymore Remove MY_LD_LIBRARY_PATH and friends This is now done by the wrapper script Remove LIBYAML_DIR variable not needed anymore Merge ReadMe.md files to one --- .gitignore | 4 ++ Makefile.am | 2 +- tests/CMakeLists.txt | 2 + tests/Makefile.am | 3 +- ...aml-emitter.c => run-emitter-test-suite.c} | 0 ...byaml-parser.c => run-parser-test-suite.c} | 0 tests/run-test-suite/Makefile | 14 +---- tests/run-test-suite/ReadMe.md | 22 +++++++- tests/run-test-suite/src/Makefile | 54 ------------------- tests/run-test-suite/src/ReadMe.md | 34 ------------ tests/run-test-suite/test/libyaml-emitter.t | 7 +-- tests/run-test-suite/test/libyaml-parser.t | 2 +- 12 files changed, 33 insertions(+), 111 deletions(-) rename tests/{run-test-suite/src/libyaml-emitter.c => run-emitter-test-suite.c} (100%) rename tests/{run-test-suite/src/libyaml-parser.c => run-parser-test-suite.c} (100%) delete mode 100644 tests/run-test-suite/src/Makefile delete mode 100644 tests/run-test-suite/src/ReadMe.md diff --git a/.gitignore b/.gitignore index 2bda964..74165f5 100644 --- a/.gitignore +++ b/.gitignore @@ -32,8 +32,10 @@ Makefile.in /libyaml.a /run-dumper /run-emitter +/run-emitter-test-suite /run-loader /run-parser +/run-parser-test-suite /run-scanner /src/Makefile /stamp-h1 @@ -46,8 +48,10 @@ Makefile.in /tests/example-reformatter-alt /tests/run-dumper /tests/run-emitter +/tests/run-emitter-test-suite /tests/run-loader /tests/run-parser +/tests/run-parser-test-suite /tests/run-scanner /tests/run-test-suite/data tests/run-test-suite/src/libyaml/ diff --git a/Makefile.am b/Makefile.am index d682892..c63b274 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,6 +25,6 @@ test: all make -C tests check-TESTS test-suite: - (export LIBYAML_DIR=$$PWD; make -C tests/run-test-suite test) + make -C tests/run-test-suite test test-all: test test-suite diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d10b424..be2ce39 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -11,8 +11,10 @@ foreach(name IN ITEMS example-reformatter-alt run-dumper run-emitter + run-emitter-test-suite run-loader run-parser + run-parser-test-suite run-scanner test-reader test-version diff --git a/tests/Makefile.am b/tests/Makefile.am index 81decb4..9597b7f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -5,4 +5,5 @@ TESTS = test-version test-reader check_PROGRAMS = test-version test-reader noinst_PROGRAMS = run-scanner run-parser run-loader run-emitter run-dumper \ example-reformatter example-reformatter-alt \ - example-deconstructor example-deconstructor-alt + example-deconstructor example-deconstructor-alt \ + run-parser-test-suite run-emitter-test-suite diff --git a/tests/run-test-suite/src/libyaml-emitter.c b/tests/run-emitter-test-suite.c similarity index 100% rename from tests/run-test-suite/src/libyaml-emitter.c rename to tests/run-emitter-test-suite.c diff --git a/tests/run-test-suite/src/libyaml-parser.c b/tests/run-parser-test-suite.c similarity index 100% rename from tests/run-test-suite/src/libyaml-parser.c rename to tests/run-parser-test-suite.c diff --git a/tests/run-test-suite/Makefile b/tests/run-test-suite/Makefile index 3d39edc..4b9570e 100644 --- a/tests/run-test-suite/Makefile +++ b/tests/run-test-suite/Makefile @@ -1,7 +1,6 @@ .PHONY: test GITHUB_ORG_URI := https://github.com/yaml TEST_SUITE_URL := $(GITHUB_ORG_URI)/yaml-test-suite -LIBYAML_DIR ?= $(PWD)/libyaml-parser-emitter/libyaml default: help @@ -10,11 +9,8 @@ help: @echo 'clean - Remove generated files' @echo 'help - Show help' -# Depends on parser and emitter but, building parser will also build emitter. -# Building twice makes things fail. Note: Some environments like on OS X, the -# shell resets the {DY,}LD_LIBRARY_PATH vars, so we work around it like so: -test: data src/libyaml-parser - (export MY_LD_LIBRARY_PATH=$(LIBYAML_DIR)/src/.libs; prove -lv test) +test: data + prove -lv test clean: rm -fr data @@ -22,9 +18,3 @@ clean: data: git clone $(TEST_SUITE_URL) $@ --branch=$@ -%/libyaml-parser %/libyaml-emitter: % - (cd $<; make clean build) - (cd $<; make clean build) - -libyaml-parser-emitter: - git clone $(GITHUB_ORG_URI)/$@ $@ diff --git a/tests/run-test-suite/ReadMe.md b/tests/run-test-suite/ReadMe.md index c1ef208..f991b37 100644 --- a/tests/run-test-suite/ReadMe.md +++ b/tests/run-test-suite/ReadMe.md @@ -1,17 +1,35 @@ LibYAML Test Runner =================== -Run libyaml-parser and libyaml-emitter against yaml-test-suite +Run run-parser-test-suite and run-emitter-test-suite against yaml-test-suite # Synopsis ``` make test +# Run tests from yaml-test-suite +make test-suite ``` # Overview See: -* https://github.com/yaml/libyaml * https://github.com/yaml/yaml-test-suite + +# Usage + +Print parse events for a YAML file (or stdin): +``` +../run-parser-test-suite file.yaml +../run-parser-test-suite < file.yaml +cat file.yaml | ../run-parser-test-suite +``` + +Print the YAML for a libyaml-parser events file (or stdin): +``` +../run-emitter-test-suite file.events +../run-emitter-test-suite < file.events +cat file.events | ../libyaml-run-test-suite +``` + diff --git a/tests/run-test-suite/src/Makefile b/tests/run-test-suite/src/Makefile deleted file mode 100644 index de0d49a..0000000 --- a/tests/run-test-suite/src/Makefile +++ /dev/null @@ -1,54 +0,0 @@ -LIBYAML_DIR ?= libyaml -LIBYAML_REPO ?= https://github.com/yaml/libyaml -LIBYAML_BRANCH ?= master -define HELP -This Makefile supports the following targets: - - build - Build ./libyaml-parser and ./libyaml-emitter - test - Run tests - -endef -export HELP - -help: - @echo "$$HELP" - -build: touch libyaml-parser libyaml-emitter - -touch: -ifneq ($(LIBYAML_DIR),libyaml) - touch *.c -endif - -libyaml-%: $(LIBYAML_DIR)/tests/.libs/run-% - cp $< $@ - -$(LIBYAML_DIR)/tests/.libs/%: $(LIBYAML_DIR)/tests/%.c $(LIBYAML_DIR)/Makefile - make -C $(LIBYAML_DIR) -ifneq ($(LIBYAML_DIR),libyaml) - (cd $(LIBYAML_DIR) && git checkout tests/run-parser.c tests/run-emitter.c) -endif - -$(LIBYAML_DIR)/tests/run-%: libyaml-% $(LIBYAML_DIR) - cp $< $@ -.SECONDARY: \ - $(LIBYAML_DIR)/tests/run-parser.c \ - $(LIBYAML_DIR)/tests/run-emitter.c \ - $(LIBYAML_DIR)/tests/.libs/run-parser \ - $(LIBYAML_DIR)/tests/.libs/run-emitter - -$(LIBYAML_DIR)/Makefile: $(LIBYAML_DIR) - ( cd $< && ./bootstrap && ./configure ) - touch $@ - -$(LIBYAML_DIR): - git clone $(LIBYAML_REPO) $@ - sleep 1 - touch *.c - -.PHONY: test -test: build - prove -lv test/ - -clean: - rm -fr libyaml libyaml-parser libyaml-emitter diff --git a/tests/run-test-suite/src/ReadMe.md b/tests/run-test-suite/src/ReadMe.md deleted file mode 100644 index ced29cb..0000000 --- a/tests/run-test-suite/src/ReadMe.md +++ /dev/null @@ -1,34 +0,0 @@ -libyaml-parser-emitter -====================== - -Parser and Emitter CLI tools for libyaml - -# Synopsis - -``` -make build -make test -``` - -# Usage - -Print parse events for a YAML file (or stdin): -``` -./libyaml-parser file.yaml -./libyaml-parser < file.yaml -cat file.yaml | ./libyaml-parser -``` - -Print the YAML for a libyaml-parser events file (or stdin): -``` -./libyaml-emitter file.events -./libyaml-emitter < file.events -cat file.events | ./libyaml-emitter -``` - -# Build - -``` -export LIBYAML_DIR=/path/to/libyaml # Optional -make build -``` diff --git a/tests/run-test-suite/test/libyaml-emitter.t b/tests/run-test-suite/test/libyaml-emitter.t index 2b12b3a..b092c6f 100755 --- a/tests/run-test-suite/test/libyaml-emitter.t +++ b/tests/run-test-suite/test/libyaml-emitter.t @@ -8,11 +8,6 @@ else ids=($(cut -d: -f1 < test/libyaml-emitter.list)) fi -# Some environments like on OS X, the shell resets the following vars, so we -# work around it like so: -export LD_LIBRARY_PATH="${MY_LD_LIBRARY_PATH:?}" -export DYLD_LIBRARY_PATH="${MY_LD_LIBRARY_PATH:?}" - count=0 for id in "${ids[@]}"; do dir="data/$id" @@ -20,7 +15,7 @@ for id in "${ids[@]}"; do [[ -e "$dir/in.yaml" ]] || continue want="$dir/out.yaml" [[ -e $want ]] || want="$dir/in.yaml" - ./src/libyaml-emitter "$dir/test.event" > /tmp/test.out || { + ../../tests/run-emitter-test-suite "$dir/test.event" > /tmp/test.out || { ( cat "$dir/test.event" cat "$want" diff --git a/tests/run-test-suite/test/libyaml-parser.t b/tests/run-test-suite/test/libyaml-parser.t index 1c3d0c4..6be2395 100755 --- a/tests/run-test-suite/test/libyaml-parser.t +++ b/tests/run-test-suite/test/libyaml-parser.t @@ -13,7 +13,7 @@ for id in "${ids[@]}"; do dir="data/$id" label="$id: $(< $dir/===)" [[ -e "$dir/in.yaml" ]] || continue - ./src/libyaml-parser "$dir/in.yaml" > /tmp/test.out || { + ../../tests/run-parser-test-suite "$dir/in.yaml" > /tmp/test.out || { ( cat "$dir/in.yaml" cat "$dir/test.event" -- 2.45.0