[Liblas-commits] hg-main-tree: improve file diff functions

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Aug 11 19:48:56 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/49ea48054001
changeset: 1051:49ea48054001
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Aug 11 15:53:52 2011 -0700
description:
improve file diff functions
Subject: hg-main-tree: add ability to diff two files, but exclude certain regions of the file

details:   http://hg.libpc.orghg-main-tree/rev/79705964aba5
changeset: 1052:79705964aba5
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Aug 11 16:22:36 2011 -0700
description:
add ability to diff two files, but exclude certain regions of the file
Subject: hg-main-tree: add special dir for unit test output files to live in

details:   http://hg.libpc.orghg-main-tree/rev/7fd10a5c1b88
changeset: 1053:7fd10a5c1b88
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Aug 11 16:41:12 2011 -0700
description:
add special dir for unit test output files to live in
Subject: hg-main-tree: use the new Support::temppath feature

details:   http://hg.libpc.orghg-main-tree/rev/ab86e0f7d54f
changeset: 1054:ab86e0f7d54f
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Aug 11 16:47:43 2011 -0700
description:
use the new Support::temppath feature
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/4f3f0edf1584
changeset: 1055:4f3f0edf1584
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Aug 11 16:47:55 2011 -0700
description:
merge

diffstat:

 src/PipelineReader.cpp               |    6 +-
 test/data/misc/data1.dat             |    1 +
 test/data/misc/data1.txt             |    3 +
 test/data/misc/data2.dat             |    1 +
 test/data/misc/data2.txt             |    3 +
 test/data/misc/data3.dat             |    1 +
 test/data/misc/data3.txt             |    5 +
 test/data/misc/data4a.dat            |    1 +
 test/data/misc/data4b.dat            |    1 +
 test/data/pipeline_readcomments.xml  |   18 +++
 test/data/pipeline_writecomments.xml |   26 ++++
 test/temp/README.txt                 |    1 +
 test/unit/CMakeLists.txt             |    1 +
 test/unit/LasWriterTest.cpp          |   18 +-
 test/unit/LiblasWriterTest.cpp       |   26 ++--
 test/unit/PipelineReaderTest.cpp     |    9 +
 test/unit/Support.cpp                |  131 ++++++++++++++++++---
 test/unit/Support.hpp                |   21 +++-
 test/unit/SupportTest.cpp            |  210 +++++++++++++++++++++++++++++++++++
 19 files changed, 435 insertions(+), 48 deletions(-)

diffs (truncated from 780 to 300 lines):

diff -r b0027041eb7a -r 4f3f0edf1584 src/PipelineReader.cpp
--- a/src/PipelineReader.cpp	Thu Aug 11 15:48:12 2011 -0500
+++ b/src/PipelineReader.cpp	Thu Aug 11 16:47:55 2011 -0700
@@ -449,7 +449,8 @@
     m_inputXmlFile = filename;
 
     boost::property_tree::ptree tree;
-    boost::property_tree::xml_parser::read_xml(filename, tree);
+    boost::property_tree::xml_parser::read_xml(filename, tree,
+        boost::property_tree::xml_parser::no_comments);
 
     boost::optional<boost::property_tree::ptree> opt( tree.get_child_optional("WriterPipeline") );
     if (!opt.is_initialized())
@@ -472,7 +473,8 @@
     m_inputXmlFile = filename;
 
     boost::property_tree::ptree tree;
-    boost::property_tree::xml_parser::read_xml(filename, tree);
+    boost::property_tree::xml_parser::read_xml(filename, tree,
+        boost::property_tree::xml_parser::no_comments);
 
     boost::optional<boost::property_tree::ptree> opt( tree.get_child_optional("ReaderPipeline") );
     if (!opt.is_initialized())
diff -r b0027041eb7a -r 4f3f0edf1584 test/data/misc/data1.dat
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/misc/data1.dat	Thu Aug 11 16:47:55 2011 -0700
@@ -0,0 +1,1 @@
+abcde
\ No newline at end of file
diff -r b0027041eb7a -r 4f3f0edf1584 test/data/misc/data1.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/misc/data1.txt	Thu Aug 11 16:47:55 2011 -0700
@@ -0,0 +1,3 @@
+The quick brown fox
+jumped over
+the lazy dog.
diff -r b0027041eb7a -r 4f3f0edf1584 test/data/misc/data2.dat
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/misc/data2.dat	Thu Aug 11 16:47:55 2011 -0700
@@ -0,0 +1,1 @@
+abcdf
\ No newline at end of file
diff -r b0027041eb7a -r 4f3f0edf1584 test/data/misc/data2.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/misc/data2.txt	Thu Aug 11 16:47:55 2011 -0700
@@ -0,0 +1,3 @@
+The quick brown fox
+jumped o'er
+the lazy dog.
diff -r b0027041eb7a -r 4f3f0edf1584 test/data/misc/data3.dat
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/misc/data3.dat	Thu Aug 11 16:47:55 2011 -0700
@@ -0,0 +1,1 @@
+abc
\ No newline at end of file
diff -r b0027041eb7a -r 4f3f0edf1584 test/data/misc/data3.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/misc/data3.txt	Thu Aug 11 16:47:55 2011 -0700
@@ -0,0 +1,5 @@
+The quick brown fox
+jumped over
+the lazy dog.
+Oh, that
+lazy dog.
diff -r b0027041eb7a -r 4f3f0edf1584 test/data/misc/data4a.dat
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/misc/data4a.dat	Thu Aug 11 16:47:55 2011 -0700
@@ -0,0 +1,1 @@
+abcdefghijklmnopqrstuvwxyz
\ No newline at end of file
diff -r b0027041eb7a -r 4f3f0edf1584 test/data/misc/data4b.dat
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/misc/data4b.dat	Thu Aug 11 16:47:55 2011 -0700
@@ -0,0 +1,1 @@
+abcDEFGhijklmnopqrstuvw**z
\ No newline at end of file
diff -r b0027041eb7a -r 4f3f0edf1584 test/data/pipeline_readcomments.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/pipeline_readcomments.xml	Thu Aug 11 16:47:55 2011 -0700
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<ReaderPipeline>
+        <Filter>
+            <Type>filters.crop</Type>
+            <Option>
+                <Name>bounds</Name>
+                <Value>([0,1000000],[0,1000000],[0,1000000])</Value>
+            </Option>
+            <Reader>
+                <Type>drivers.las.reader</Type>
+                <Option>
+                    <Name>filename</Name>
+                    <Value>1.2-with-color.las</Value>
+                </Option>
+                <!-- This is a comment -->
+            </Reader>
+        </Filter>
+</ReaderPipeline>
diff -r b0027041eb7a -r 4f3f0edf1584 test/data/pipeline_writecomments.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/pipeline_writecomments.xml	Thu Aug 11 16:47:55 2011 -0700
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<WriterPipeline>
+    <Writer>
+        <Type>drivers.las.writer</Type>
+        <Option>
+            <Name>filename</Name>
+            <Value>out.las</Value>
+            <Description>junk junk junk</Description>
+        </Option>
+        <Filter>
+            <Type>filters.crop</Type>
+            <Option>
+                <Name>bounds</Name>
+                <Value>([0,1000000],[0,1000000],[0,1000000])</Value>
+            </Option>
+            <Reader>
+                <Type>drivers.las.reader</Type>
+                <Option>
+                    <Name>filename</Name>
+                    <Value>1.2-with-color.las</Value>
+                </Option>
+            </Reader>
+        </Filter>
+    </Writer>
+    <!-- This is a comment -->
+</WriterPipeline>
diff -r b0027041eb7a -r 4f3f0edf1584 test/temp/README.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/temp/README.txt	Thu Aug 11 16:47:55 2011 -0700
@@ -0,0 +1,1 @@
+The unit tests write files into this directory.  This directory must exist.
diff -r b0027041eb7a -r 4f3f0edf1584 test/unit/CMakeLists.txt
--- a/test/unit/CMakeLists.txt	Thu Aug 11 15:48:12 2011 -0500
+++ b/test/unit/CMakeLists.txt	Thu Aug 11 16:47:55 2011 -0700
@@ -47,6 +47,7 @@
     SpatialReferenceTest.cpp
     StageFactoryTest.cpp
     StreamManagerTest.cpp
+    SupportTest.cpp
     TerraSolidTest.cpp
     UtilsTest.cpp
     VectorTest.cpp
diff -r b0027041eb7a -r 4f3f0edf1584 test/unit/LasWriterTest.cpp
--- a/test/unit/LasWriterTest.cpp	Thu Aug 11 15:48:12 2011 -0500
+++ b/test/unit/LasWriterTest.cpp	Thu Aug 11 16:47:55 2011 -0700
@@ -57,7 +57,7 @@
 
     pdal::drivers::las::LasReader reader(Support::datapath("1.2-with-color.las"));
     
-    std::ostream* ofs = FileUtils::createFile("temp.las");
+    std::ostream* ofs = FileUtils::createFile(Support::temppath("temp.las"));
 
     {
         // need to scope the writer, so that's it dtor can use the stream
@@ -78,12 +78,12 @@
 
     FileUtils::closeFile(ofs);
 
-    bool filesSame = Support::compare_files("temp.las", Support::datapath("simple.las"));
+    bool filesSame = Support::compare_files(Support::temppath("temp.las"), Support::datapath("simple.las"));
     BOOST_CHECK(filesSame);
 
     if (filesSame)
     {
-        FileUtils::deleteFile("temp.las");
+        FileUtils::deleteFile(Support::temppath("temp.las"));
     }
 
     return;
@@ -97,7 +97,7 @@
 
     pdal::drivers::las::LasReader reader(Support::datapath("laszip/basefile.las"));
     
-    std::ostream* ofs = FileUtils::createFile(Support::datapath("laszip/LasWriterTest_test_simple_laz.laz"));
+    std::ostream* ofs = FileUtils::createFile(Support::temppath("LasWriterTest_test_simple_laz.laz"));
 
     {
         const boost::uint64_t numPoints = reader.getNumPoints();
@@ -119,16 +119,16 @@
     FileUtils::closeFile(ofs);
 
     {
-        pdal::drivers::las::LasReader reader(Support::datapath("laszip/LasWriterTest_test_simple_laz.laz"));
+        pdal::drivers::las::LasReader reader(Support::temppath("LasWriterTest_test_simple_laz.laz"));
     }
 
-    bool filesSame = Support::compare_files(Support::datapath("laszip/LasWriterTest_test_simple_laz.laz"), 
+    bool filesSame = Support::compare_files(Support::temppath("LasWriterTest_test_simple_laz.laz"), 
                                             Support::datapath("laszip/laszip-generated.laz"));
     BOOST_CHECK(filesSame);
 
     if (filesSame)
     {
-        FileUtils::deleteFile(Support::datapath("laszip/LasWriterTest_test_simple_laz.laz"));
+        FileUtils::deleteFile(Support::temppath("LasWriterTest_test_simple_laz.laz"));
     }
 
     return;
@@ -142,7 +142,7 @@
 
     pdal::drivers::las::LasReader reader(Support::datapath("1.2_3.las"));
     
-    std::ostream* ofs = FileUtils::createFile("temp.las");
+    std::ostream* ofs = FileUtils::createFile(Support::temppath("temp.las"));
 
     {
         const boost::uint64_t numPoints = reader.getNumPoints();
@@ -174,7 +174,7 @@
     //
     //if (filesSame)
     {
-        FileUtils::deleteFile("temp.las");
+        FileUtils::deleteFile(Support::temppath("temp.las"));
     }
 
     return;
diff -r b0027041eb7a -r 4f3f0edf1584 test/unit/LiblasWriterTest.cpp
--- a/test/unit/LiblasWriterTest.cpp	Thu Aug 11 15:48:12 2011 -0500
+++ b/test/unit/LiblasWriterTest.cpp	Thu Aug 11 16:47:55 2011 -0700
@@ -57,7 +57,7 @@
 
     LiblasReader reader(Support::datapath("1.2-with-color.las"));
     
-    std::ostream* ofs = FileUtils::createFile("LiblasWriterTest_test_simple_las.las");
+    std::ostream* ofs = FileUtils::createFile(Support::temppath("LiblasWriterTest_test_simple_las.las"));
 
     {
         // need to scope the writer, so that's it dtor can use the stream
@@ -78,12 +78,12 @@
 
     FileUtils::closeFile(ofs);
 
-    bool filesSame = Support::compare_files("LiblasWriterTest_test_simple_las.las", Support::datapath("simple.las"));
+    bool filesSame = Support::compare_files(Support::temppath("LiblasWriterTest_test_simple_las.las"), Support::datapath("simple.las"));
     BOOST_CHECK(filesSame);
 
     if (filesSame)
     {
-        FileUtils::deleteFile("LiblasWriterTest_test_simple_las.las");
+        FileUtils::deleteFile(Support::temppath("LiblasWriterTest_test_simple_las.las"));
     }
 
     return;
@@ -94,7 +94,7 @@
     // remove file from earlier run, if needed
     FileUtils::deleteFile(Support::datapath("LiblasWriterTest_test_options.las"));
 
-    Option<std::string> opt("filename", Support::datapath("LiblasWriterTest_test_options.las"));
+    Option<std::string> opt("filename", Support::temppath("LiblasWriterTest_test_options.las"));
     Options opts(opt);
 
     LiblasReader reader(Support::datapath("1.2-with-color.las"));
@@ -116,13 +116,13 @@
         writer.write(numPoints);
     }
 
-    bool filesSame = Support::compare_files(Support::datapath("LiblasWriterTest_test_options.las"), 
+    bool filesSame = Support::compare_files(Support::temppath("LiblasWriterTest_test_options.las"), 
                                             Support::datapath("simple.las"));
     BOOST_CHECK(filesSame);
 
     if (filesSame)
     {
-        FileUtils::deleteFile(Support::datapath("LiblasWriterTest_test_options.las"));
+        FileUtils::deleteFile(Support::temppath("LiblasWriterTest_test_options.las"));
     }
 
     return;
@@ -132,11 +132,11 @@
 BOOST_AUTO_TEST_CASE(LiblasWriterTest_test_simple_laz)
 {
     // remove file from earlier run, if needed
-    FileUtils::deleteFile(Support::datapath("laszip/LiblasWriterTest_test_simple_laz.laz"));
+    FileUtils::deleteFile(Support::temppath("LiblasWriterTest_test_simple_laz.laz"));
 
     LiblasReader reader(Support::datapath("laszip/basefile.las"));
     
-    std::ostream* ofs = FileUtils::createFile(Support::datapath("laszip/LiblasWriterTest_test_simple_laz.laz"));
+    std::ostream* ofs = FileUtils::createFile(Support::temppath("LiblasWriterTest_test_simple_laz.laz"));
 
     {
         // need to scope the writer, so that's it dtor can use the stream
@@ -156,13 +156,13 @@
 
     FileUtils::closeFile(ofs);
 
-    bool filesSame = Support::compare_files(Support::datapath("laszip/LiblasWriterTest_test_simple_laz.laz"), 
+    bool filesSame = Support::compare_files(Support::temppath("LiblasWriterTest_test_simple_laz.laz"), 
                                             Support::datapath("laszip/laszip-generated.laz"));
     BOOST_CHECK(filesSame);
 
     if (filesSame)
     {
-        FileUtils::deleteFile(Support::datapath("laszip/LiblasWriterTest_test_simple_laz.laz"));
+        FileUtils::deleteFile(Support::temppath("LiblasWriterTest_test_simple_laz.laz"));
     }
 
     return;


More information about the Liblas-commits mailing list