Skip to content

Commit

Permalink
Include libyaml-test and libyaml-parser-emitter
Browse files Browse the repository at this point in the history
Before the `make test-suite` command would clone yaml/libyaml-test which
would in tuen clone yaml/libyaml-parser-emitter. Now they are part of
the repository since they are not really useful outside the repository.

They still clone the data branch of yaml/yaml-test-suite. That is where
all the actual test data resides. That belongs outside the repo because
it is intended for all yaml frameworks.
  • Loading branch information
ingydotnet committed Dec 30, 2016
1 parent 52b6634 commit a672b07
Show file tree
Hide file tree
Showing 19 changed files with 876 additions and 54 deletions.
98 changes: 58 additions & 40 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,44 +1,62 @@
CMakeCache.txt
CMakeFiles/
CTestTestfile.cmake
Makefile
Makefile.in
Testing/
aclocal.m4
autom4te.cache
cmake_install.cmake
configure
config
config.h
config.h.in
config.h.in~
config.log
config.status
example-deconstructor
example-deconstructor-alt
example-reformatter
example-reformatter-alt
libtool
libyaml.a
libyaml-test/
run-dumper
run-emitter
run-loader
run-parser
run-scanner
stamp-h1
test-reader
test-version
tests/test-reader
tests/test-reader.log
tests/test-reader.trs
tests/test-suite.log
tests/test-version
tests/test-version.log
tests/test-version.trs
.deps
.libs
.deps/
.libs/
*~
*.BAK
*.la
*.lo
*.o
*.pc
/CMakeCache.txt
/CMakeFiles/
/CTestTestfile.cmake
/Makefile
Makefile.in
/Testing/
/aclocal.m4
/autom4te.cache
/cmake_install.cmake
/config
/config.h
/config.h.in
/config.h.in~
/config.log
/config.status
/configure
/example-deconstructor
/example-deconstructor-alt
/example-reformatter
/example-reformatter-alt
/include/Makefile
/libtool
/libyaml.a
/run-dumper
/run-emitter
/run-loader
/run-parser
/run-scanner
/src/Makefile
/stamp-h1
/test-reader
/test-version
/tests/Makefile
/tests/example-deconstructor
/tests/example-deconstructor-alt
/tests/example-reformatter
/tests/example-reformatter-alt
/tests/run-dumper
/tests/run-emitter
/tests/run-loader
/tests/run-parser
/tests/run-scanner
/tests/run-test-suite/data
tests/run-test-suite/src/libyaml/
tests/run-test-suite/src/libyaml-emitter
tests/run-test-suite/src/libyaml-parser
/tests/test-reader
/tests/test-reader.log
/tests/test-reader.trs
/tests/test-suite.log
/tests/test-version
/tests/test-version.log
/tests/test-version.trs
/win32/Makefile
1 change: 1 addition & 0 deletions .indent.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-kr -nut -nce -l250
11 changes: 5 additions & 6 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ maintainer-clean-local:
-find ${builddir} -name Makefile.in -exec rm -f '{}' ';'

distclean-local:
-rm -fr libyaml-test
-make -C tests/run-test-suite clean

.PHONY: bootstrap
bootstrap: maintainer-clean
./bootstrap
./configure
make

test: all
make -C tests check-TESTS

test-suite: libyaml-test
(export LIBYAML_DIR=$$PWD; make -C $< test)

libyaml-test:
git clone https://github.com/yaml/$@
test-suite:
(export LIBYAML_DIR=$$PWD; make -C tests/run-test-suite test)

test-all: test test-suite
29 changes: 29 additions & 0 deletions tests/run-test-suite/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.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

help:
@echo 'test - Run the tests'
@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)

clean:
rm -fr data

data:
git clone $(TEST_SUITE_URL) $@ --branch=$@

%/libyaml-parser %/libyaml-emitter: %
(cd $<; make build)

libyaml-parser-emitter:
git clone $(GITHUB_ORG_URI)/$@ $@
17 changes: 17 additions & 0 deletions tests/run-test-suite/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
LibYAML Test Runner
===================

Run libyaml-parser and libyaml-emitter against yaml-test-suite

# Synopsis

```
make test
```

# Overview

See:

* https://github.com/yaml/libyaml
* https://github.com/yaml/yaml-test-suite
54 changes: 54 additions & 0 deletions tests/run-test-suite/src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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
34 changes: 34 additions & 0 deletions tests/run-test-suite/src/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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
```
Loading

0 comments on commit a672b07

Please sign in to comment.