This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to tag v1.1.0
in repository osmium-tool.

commit 6690b77b641caf839e2ff1671c243ec113ee0aa5
Author: Jochen Topf <joc...@topf.org>
Date:   Fri Jun 26 11:49:25 2015 +0200

    Use cmake script instead of shell for tests (so it will run on Windows).
    
    Also add tests for the 'cat' and 'fileinfo' subcommands.
---
 CMakeLists.txt                      | 28 ++++++++++++++++++++---
 cmake/run_test_compare_output.cmake | 44 +++++++++++++++++++++++++++++++++++++
 test/cat/input1.osm                 |  6 +++++
 test/cat/input2.osm                 |  6 +++++
 test/cat/output-cat12.osm           |  9 ++++++++
 test/cat/output-cat21.osm           |  9 ++++++++
 test/fileinfo/fi1-result.txt        | 27 +++++++++++++++++++++++
 test/fileinfo/fi1.osm               |  6 +++++
 8 files changed, 132 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 84a0bc3..3678b14 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -245,12 +245,19 @@ endif()
 #-----------------------------------------------------------------------------
 
 function(check_output _name _command _output)
-    add_test(NAME ${_name} COMMAND sh -c "${_command} | cmp --quiet - 
${_output}")
+    set(_cmd "${PROJECT_BINARY_DIR}/src/osmium ${_command}")
+    add_test(
+        NAME ${_name}
+        COMMAND ${CMAKE_COMMAND}
+        -Dcmd=${_cmd}
+        -Ddir=${PROJECT_SOURCE_DIR}/test
+        -Dreference=${_output}
+        -P ${CMAKE_SOURCE_DIR}/cmake/run_test_compare_output.cmake
+    )
 endfunction()
 
 function(check_time_filter _name _type _from _to _output)
-    set(_tdir "${PROJECT_SOURCE_DIR}/test/time-filter")
-    check_output(time-filter-${_name} "osmium time-filter --generator=test -f 
${_type} ${_tdir}/input.osh ${_from} ${_to}" 
"${_tdir}/output-${_output}.${_type}")
+    check_output(time-filter-${_name} "time-filter --generator=test -f 
${_type} time-filter/input.osh ${_from} ${_to}" 
"time-filter/output-${_output}.${_type}")
 endfunction()
 
 check_time_filter(last osm ""                   "" last)
@@ -269,6 +276,21 @@ check_time_filter(range-2-3a  osh 2015-01-01T02:00:00Z 
2015-01-01T03:01:00Z rang
 check_time_filter(range-2-4   osh 2015-01-01T02:00:00Z 2015-01-01T04:00:00Z 
range-2-4)
 
 
+function(check_cat _name _in1 _in2 _output)
+    check_output(cat-${_name} "cat --generator=test -f osm cat/${_in1} 
cat/${_in2}" "cat/${_output}")
+endfunction()
+
+check_cat(cat12 input1.osm input2.osm output-cat12.osm)
+check_cat(cat21 input2.osm input1.osm output-cat21.osm)
+
+
+function(check_fileinfo _name _options _input _output)
+    check_output(fileinfo-${_name} "fileinfo ${_options} fileinfo/${_input}" 
"fileinfo/${_output}")
+endfunction()
+
+check_fileinfo(fi1 "--extended" fi1.osm fi1-result.txt)
+
+
 #-----------------------------------------------------------------------------
 
 include_directories(include)
diff --git a/cmake/run_test_compare_output.cmake 
b/cmake/run_test_compare_output.cmake
new file mode 100644
index 0000000..2f1f8ff
--- /dev/null
+++ b/cmake/run_test_compare_output.cmake
@@ -0,0 +1,44 @@
+#
+#  Runs a test command given in the variable 'cmd' in directory 'dir'.
+#  Checks that the return code is 0.
+#  Checks that there is nothing on stderr.
+#  Compares output on stdout with reference file in variable 'reference'.
+#
+
+if(NOT cmd)
+    message(FATAL_ERROR "Variable 'cmd' not defined")
+endif()
+
+if(NOT dir)
+    message(FATAL_ERROR "Variable 'dir' not defined")
+endif()
+
+if(NOT reference)
+    message(FATAL_ERROR "Variable 'reference' not defined")
+endif()
+
+separate_arguments(cmd)
+
+execute_process(
+    COMMAND ${cmd}
+    WORKING_DIRECTORY ${dir}
+    RESULT_VARIABLE result
+    OUTPUT_VARIABLE stdout
+    ERROR_VARIABLE stderr
+)
+
+if(result)
+    message(SEND_ERROR "Error when calling '${cmd}': ${result}")
+endif()
+
+if(NOT (stderr STREQUAL ""))
+    message(SEND_ERROR "Command tested wrote to stderr: ${_stderr}")
+endif()
+
+file(READ ${dir}/${reference} ref)
+
+if(NOT (ref STREQUAL stdout))
+    file(WRITE "test.stdout" ${stdout})
+    message(SEND_ERROR "Test output does not match '${reference}'. Output is 
in 'test.stdout'.")
+endif()
+
diff --git a/test/cat/input1.osm b/test/cat/input1.osm
new file mode 100644
index 0000000..8c94b0f
--- /dev/null
+++ b/test/cat/input1.osm
@@ -0,0 +1,6 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<osm version="0.6" generator="testdata" upload="false">
+  <node id="1" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="1" lon="1"/>
+  <node id="2" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="2" lon="1"/>
+  <node id="3" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="3" lon="1"/>
+</osm>
diff --git a/test/cat/input2.osm b/test/cat/input2.osm
new file mode 100644
index 0000000..1f6334b
--- /dev/null
+++ b/test/cat/input2.osm
@@ -0,0 +1,6 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<osm version="0.6" generator="testdata" upload="false">
+  <node id="4" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="4" lon="1"/>
+  <node id="5" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="5" lon="1"/>
+  <node id="6" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="6" lon="1"/>
+</osm>
diff --git a/test/cat/output-cat12.osm b/test/cat/output-cat12.osm
new file mode 100644
index 0000000..c4e62a9
--- /dev/null
+++ b/test/cat/output-cat12.osm
@@ -0,0 +1,9 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<osm version="0.6" generator="test">
+  <node id="1" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="1" lon="1"/>
+  <node id="2" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="2" lon="1"/>
+  <node id="3" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="3" lon="1"/>
+  <node id="4" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="4" lon="1"/>
+  <node id="5" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="5" lon="1"/>
+  <node id="6" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="6" lon="1"/>
+</osm>
diff --git a/test/cat/output-cat21.osm b/test/cat/output-cat21.osm
new file mode 100644
index 0000000..107f0b4
--- /dev/null
+++ b/test/cat/output-cat21.osm
@@ -0,0 +1,9 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<osm version="0.6" generator="test">
+  <node id="4" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="4" lon="1"/>
+  <node id="5" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="5" lon="1"/>
+  <node id="6" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="6" lon="1"/>
+  <node id="1" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="1" lon="1"/>
+  <node id="2" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="2" lon="1"/>
+  <node id="3" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="3" lon="1"/>
+</osm>
diff --git a/test/fileinfo/fi1-result.txt b/test/fileinfo/fi1-result.txt
new file mode 100644
index 0000000..c85c24a
--- /dev/null
+++ b/test/fileinfo/fi1-result.txt
@@ -0,0 +1,27 @@
+File:
+  Name: fileinfo/fi1.osm
+  Format: XML
+  Compression: none
+  Size: 438
+Header:
+  Bounding boxes:
+  With history: no
+  Options:
+    generator=testdata
+    version=0.6
+Data: 
+  Bounding box: (1,1,1,3)
+  Timestamps:
+    First: 2015-01-01T01:00:00Z
+    Last: 2015-01-01T04:00:00Z
+  Objects ordered (by type and id): yes
+  Multiple versions of same object: no
+  CRC32: 7cb270e8
+  Number of changesets: 0
+  Number of nodes: 3
+  Number of ways: 0
+  Number of relations: 0
+  Largest changeset ID: 0
+  Largest node ID: 4
+  Largest way ID: 0
+  Largest relation ID: 0
diff --git a/test/fileinfo/fi1.osm b/test/fileinfo/fi1.osm
new file mode 100644
index 0000000..3a74057
--- /dev/null
+++ b/test/fileinfo/fi1.osm
@@ -0,0 +1,6 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<osm version="0.6" generator="testdata" upload="false">
+  <node id="1" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" 
user="test" changeset="1" lat="1" lon="1"/>
+  <node id="2" version="1" timestamp="2015-01-01T02:00:00Z" uid="1" 
user="test" changeset="1" lat="2" lon="1"/>
+  <node id="4" version="1" timestamp="2015-01-01T04:00:00Z" uid="1" 
user="test" changeset="1" lat="3" lon="1"/>
+</osm>

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-grass/osmium-tool.git

_______________________________________________
Pkg-grass-devel mailing list
Pkg-grass-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

Reply via email to