From 76d116724904ee5de2611a550e2ae6e4203708ec Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Wed, 5 Jul 2017 14:11:11 -0300 Subject: [PATCH 01/36] Fix #1890 - grid=true and last line/column. --- src/observer/components/painter/painterThread.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/observer/components/painter/painterThread.cpp b/src/observer/components/painter/painterThread.cpp index abc1825a..781efed9 100644 --- a/src/observer/components/painter/painterThread.cpp +++ b/src/observer/components/painter/painterThread.cpp @@ -385,11 +385,17 @@ void PainterThread::drawGrid(QImage &imgResult, double &width, double &height) QPainter p(&imgResult); p.setPen(QPen(Qt::black)); - for (int j = 0; j < imgResult.height(); j++) + int adjust = p.pen().width(); + int sizeX = ceil(imgResult.width() / width); + int sizeY = ceil(imgResult.height() / height); + + p.drawRect(0, 0, imgResult.width() - adjust, imgResult.height() - adjust); + + for (int j = 0; j < sizeY; j++) { - for (int i = 0; i < imgResult.width(); i++) + for (int i = 0; i < sizeX; i++) { - p.drawRect(QRectF(i * width, j * height, width, height)); + p.drawRect(QRectF(i * width, j * height, width, height)); } } From 0baeb9f4055b8f24d6de453d1280fbe7d46ff81b Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Wed, 5 Jul 2017 14:17:52 -0300 Subject: [PATCH 02/36] Indentation #1890. --- .../components/painter/painterThread.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/observer/components/painter/painterThread.cpp b/src/observer/components/painter/painterThread.cpp index 781efed9..b244b944 100644 --- a/src/observer/components/painter/painterThread.cpp +++ b/src/observer/components/painter/painterThread.cpp @@ -380,10 +380,10 @@ void PainterThread::drawNeighborhood(QPainter *p, double &xCell, double &yCell, void PainterThread::drawGrid(QImage &imgResult, double &width, double &height) { - mutex.lock(); + mutex.lock(); - QPainter p(&imgResult); - p.setPen(QPen(Qt::black)); + QPainter p(&imgResult); + p.setPen(QPen(Qt::black)); int adjust = p.pen().width(); int sizeX = ceil(imgResult.width() / width); @@ -391,13 +391,13 @@ void PainterThread::drawGrid(QImage &imgResult, double &width, double &height) p.drawRect(0, 0, imgResult.width() - adjust, imgResult.height() - adjust); - for (int j = 0; j < sizeY; j++) - { - for (int i = 0; i < sizeX; i++) - { + for (int j = 0; j < sizeY; j++) + { + for (int i = 0; i < sizeX; i++) + { p.drawRect(QRectF(i * width, j * height, width, height)); - } - } + } + } - mutex.unlock(); + mutex.unlock(); } From 3a6f8726ed0f4dfe81fc9bbe9d448e24b2dc0b80 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Wed, 5 Jul 2017 17:29:08 -0300 Subject: [PATCH 03/36] Close #1904 - Review functional basic tests of Layer:fill(). --- packages/gis/tests/functional/basic/Layer.lua | 485 ++++++++++-------- 1 file changed, 260 insertions(+), 225 deletions(-) diff --git a/packages/gis/tests/functional/basic/Layer.lua b/packages/gis/tests/functional/basic/Layer.lua index 50cc8e13..cf77d4cd 100644 --- a/packages/gis/tests/functional/basic/Layer.lua +++ b/packages/gis/tests/functional/basic/Layer.lua @@ -274,7 +274,7 @@ return { unitTest:assert(not File(filePath1):exists()) end, fill = function(unitTest) - local projName = File("cellular_layer_basic.tview") + local projName = File("gis_fill_func_basic.tview") local layerName1 = "Setores_2000" local localidades = "Localidades" local rodovias = "Rodovias" @@ -301,233 +301,268 @@ return { file = filePath1 } + local presenceSelectUnnecessary = function() + cl:fill{ + operation = "presence", + layer = localidades, + attribute = "presence", + select = "FID" + } + end + unitTest:assertWarning(presenceSelectUnnecessary, unnecessaryArgumentMsg("select")) + local attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "presence") + + local areaSelectUnnecessary = function() + cl:fill{ + attribute = "areattr", + operation = "area", + layer = layerName1, + select = "FID" + } + end + unitTest:assertWarning(areaSelectUnnecessary, unnecessaryArgumentMsg("select")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "areattr") + + local countSelectUnnecessary = function() + cl:fill{ + attribute = "counttr", + operation = "count", + layer = localidades, + select = "FID" + } + end + unitTest:assertWarning(countSelectUnnecessary, unnecessaryArgumentMsg("select")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "counttr") + + local distanceSelectUnnecessary = function() + cl:fill{ + attribute = "disttr", + operation = "distance", + layer = layerName1, + select = "FID" + } + end + unitTest:assertWarning(distanceSelectUnnecessary, unnecessaryArgumentMsg("select")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "disttr") + + local unnecessaryArgument = function() + cl:fill{ + attribute = "minttr", + operation = "minimum", + layer = localidades, + select = "UCS_FATURA", + missin = 3 + } + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("missin", "missing")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "minttr") + + unnecessaryArgument = function() + cl:fill{ + attribute = "maxattr", + operation = "maximum", + layer = localidades, + select = "UCS_FATURA", + missin = 3 + } + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("missin", "missing")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "maxattr") + + unnecessaryArgument = function() + cl:fill{ + attribute = "covttr", + operation = "coverage", + layer = layerName1, + select = "FID", + missin = 3 + } + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("missin", "missing")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "covttr_57") + + unnecessaryArgument = function() + cl:fill{ + operation = "stdev", + layer = localidades, + attribute = "stdev", + select = "UCS_FATURA", + missin = 3 + } + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("missin", "missing")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "stdev") + + unnecessaryArgument = function() + cl:fill{ + operation = "average", + layer = localidades, + attribute = "mean", + select = "UCS_FATURA", + missin = 3 + } + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("missin", "missing")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "mean") + + unnecessaryArgument = function() + cl:fill{ + operation = "average", + layer = localidades, + attribute = "weighted", + select = "UCS_FATURA", + missin = 3 + } + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("missin", "missing")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "weighted") + + + unnecessaryArgument = function() + cl:fill{ + operation = "mode", + layer = localidades, + attribute = "modttr", + select = "UCS_FATURA", + missin = 3 + } + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("missin", "missing")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "modttr") + + unnecessaryArgument = function() + cl:fill{ + operation = "sum", + layer = localidades, + attribute = "ucs_sum", + select = "UCS_FATURA", + missin = 3 + } + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("missin", "missing")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "ucs_sum") + + unnecessaryArgument = function() + cl:fill{ + operation = "sum", + layer = localidades, + attribute = "wsum", + select = "UCS_FATURA", + area = true, + missin = 3 + } + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("missin", "missing")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "wsum") + + local normalizedNameWarning = function() + cl:fill{ + attribute = "max10allowed", + operation = "sum", + layer = layerName1, + select = "FID" + } + end + unitTest:assertWarning(normalizedNameWarning, "The 'attribute' lenght has more than 10 characters. It was truncated to 'max10allow'.") + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "max10allow") - cl:fill{ - operation = "presence", - layer = localidades, - attribute = "presence" - } ---[[ - local areaLayerName = clName1.."_Area" - local filePath3 = areaLayerName..".shp" - - File(filePath3):deleteIfExists() - - cl:fill{ - operation = "area", - layer = layerName1, - attribute = "area" - } ---]] - - cl:fill{ - operation = "count", - layer = localidades, - attribute = "num" - } - - -- local distanceLayerName = clName1.."_Distance" - -- local filePath5 = distanceLayerName..".shp" - - -- File(filePath5):deleteIfExists() - - -- cl:fill{ - -- operation = "distance", - -- layer = localidades, - -- attribute = "distance" - -- } - - cl:fill{ - operation = "minimum", - layer = localidades, - attribute = "minimum", - select = "UCS_FATURA" - } - - cl:fill{ - operation = "maximum", - layer = localidades, - attribute = "maximum", - select = "UCS_FATURA" - } - - --[[ - cl:fill{ - operation = "coverage", - layer = localidades, - attribute = "coverage", - select = "LOCALIDADE" - } - --]] - - cl:fill{ - operation = "stdev", - layer = localidades, - attribute = "stdev", - select = "UCS_FATURA" - } - - cl:fill{ - operation = "average", - layer = localidades, - attribute = "mean", - select = "UCS_FATURA" - } - - cl:fill{ - operation = "average", - layer = localidades, - attribute = "weighted", - select = "UCS_FATURA" - } - - cl:fill{ - operation = "mode", - layer = localidades, - attribute = "high_inter", - select = "UCS_FATURA" - } - - cl:fill{ - operation = "mode", - layer = localidades, - attribute = "high_occur", - select = "UCS_FATURA" - } - - cl:fill{ - operation = "sum", - layer = localidades, - attribute = "ucs_sum", - select = "UCS_FATURA" - } - - cl:fill{ - operation = "sum", - layer = localidades, - attribute = "wsum", - select = "UCS_FATURA", - area = true - } - - -- RASTER TESTS ------------------------------------------ issue #928 - -- local desmatamento = "Desmatamento" - -- Layer{ - -- name = desmatamento, - -- file = filePath("itaituba-deforestation.tif", "gis") - -- } - - -- local rmeanLayerName = clName1.."_Mean_Raster" - -- local filePath16 = shp16 = rmeanLayerName..".shp" - - -- File(filePath16):deleteIfExists() - - -- cl:fill{ - -- operation = "average", - -- layer = desmatamento, - -- attribute = "mean_0", - -- select = 0 - -- } - - -- local rminLayerName = clName1.."_Minimum_Raster" - -- local filePath17 = rminLayerName..".shp" - - -- File(filePath17):deleteIfExists() - - -- cl:fill{ - -- operation = "minimum", - -- layer = desmatamento, - -- attribute = "minimum_0", - -- select = 0 - -- } - - -- local rmaxLayerName = clName1.."_Maximum_Raster" - -- local filePath18 = rmaxLayerName..".shp" - - -- File(filePath18):deleteIfExists() - - -- cl:fill{ - -- operation = "maximum", - -- layer = desmatamento, - -- attribute = "maximum_0", - -- select = 0 - -- } - - -- local rpercentLayerName = clName1.."_Percentage_Raster" - -- local filePath19 = rpercentLayerName..".shp" - - -- File(filePath19):deleteIfExists() - - -- cl:fill{ - -- operation = "coverage", - -- layer = desmatamento, - -- attribute = "percent_0", - -- select = 0 - -- } - - -- local rstdevLayerName = clName1.."_Stdev_Raster" - -- local filePath20 = rstdevLayerName..".shp" - - -- File(filePath20):deleteIfExists() - - -- cl:fill{ - -- operation = "stdev", - -- layer = desmatamento, - -- attribute = "stdev_0", - -- select = 0 - -- } - - -- local rsumLayerName = clName1.."_Sum_Raster" - -- local filePath21 = rstdevLayerName..".shp" - - -- File(filePath21):deleteIfExists() - - -- cl:fill{ - -- operation = "sum", - -- layer = desmatamento, - -- attribute = "sum_0", - -- select = 0 - -- } - - local cs = CellularSpace{ - project = proj, - layer = cl.name - } - - forEachCell(cs, function(cell) - cell.past_ucs_sum = cell.ucs_sum - cell.ucs_sum = cell.ucs_sum + 10000 - end) - - local cellSpaceLayerName = clName1.."_CellSpace_Sum" - local filePath22 = cellSpaceLayerName..".shp" - - File(filePath22):deleteIfExists() - - cs:save(cellSpaceLayerName, "past_ucs_sum") - - local cellSpaceLayer = Layer{ + -- RASTER TESTS + local deforest = "Deforestation" + Layer{ project = proj, - name = cellSpaceLayerName - } - - unitTest:assertEquals(cellSpaceLayer.source, "shp") - unitTest:assertEquals(cellSpaceLayer.file, currentDir()..filePath22) - - projName:deleteIfExists() - - File(filePath1):deleteIfExists() --- File(filePath3):deleteIfExists() --- File(filePath5):deleteIfExists() - --File(filePath16):deleteIfExists() - --File(filePath17):deleteIfExists() - --File(filePath18):deleteIfExists() - --File(filePath19):deleteIfExists() - --File(filePath20):deleteIfExists() - --File(filePath21):deleteIfExists() - File(filePath22):deleteIfExists() + name = deforest, + epsg = 29191, + file = filePath("itaituba-deforestation.tif", "gis") + } + + local areaUnnecessary = function() + cl:fill{ + attribute = "argattr", + operation = "average", + layer = deforest, + area = 2 + } + end + unitTest:assertWarning(areaUnnecessary, unnecessaryArgumentMsg("area")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "argattr") + + areaUnnecessary = function() + cl:fill{ + attribute = "mmittr", + operation = "minimum", + layer = deforest, + area = 2 + } + end + unitTest:assertWarning(areaUnnecessary, unnecessaryArgumentMsg("area")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "mmittr") + + areaUnnecessary = function() + cl:fill{ + attribute = "mmaxttr", + operation = "maximum", + layer = deforest, + area = 2 + } + end + unitTest:assertWarning(areaUnnecessary, unnecessaryArgumentMsg("area")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "mmaxttr") + + areaUnnecessary = function() + cl:fill{ + attribute = "ccvattr", + operation = "coverage", + layer = deforest, + area = 2 + } + end + unitTest:assertWarning(areaUnnecessary, unnecessaryArgumentMsg("area")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "ccvatt_255") + + areaUnnecessary = function() + cl:fill{ + attribute = "ssdvattr", + operation = "stdev", + layer = deforest, + area = 2 + } + end + unitTest:assertWarning(areaUnnecessary, unnecessaryArgumentMsg("area")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "ssdvattr") + + areaUnnecessary = function() + cl:fill{ + attribute = "ssuattr", + operation = "sum", + layer = deforest, + area = 2 + } + end + unitTest:assertWarning(areaUnnecessary, unnecessaryArgumentMsg("area")) + attrs = cl:attributes() + unitTest:assertEquals(attrs[#attrs].name, "ssuattr") - projName:deleteIfExists() + projName:delete() + File(filePath1):delete() end, representation = function(unitTest) local projName = "cellular_layer_representation.tview" From a8e17966259064e0db872d08bc0bf5354cf5fca7 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Thu, 6 Jul 2017 11:30:55 -0300 Subject: [PATCH 04/36] Close #1876 and moved assertWarning() in gis #1878. --- packages/gis/lua/TerraLib.lua | 2 +- .../tests/functional/alternative/Layer.lua | 251 ------------------ .../tests/functional/alternative/Project.lua | 16 -- .../tests/functional/alternative/TerraLib.lua | 24 -- packages/gis/tests/functional/basic/Layer.lua | 54 +++- .../gis/tests/functional/basic/Project.lua | 14 +- .../gis/tests/functional/basic/TerraLib.lua | 25 +- packages/gis/tests/nc/basic/Layer.lua | 38 +-- .../gis/tests/postgis/alternative/Layer.lua | 70 ----- packages/gis/tests/postgis/basic/Layer.lua | 72 +++-- packages/gis/tests/postgis/basic/TerraLib.lua | 7 - .../gis/tests/shapefile/alternative/Layer.lua | 56 ---- .../tests/shapefile/alternative/TerraLib.lua | 13 - packages/gis/tests/shapefile/basic/Layer.lua | 69 +++-- .../gis/tests/shapefile/basic/TerraLib.lua | 15 +- packages/gis/tests/tif/alternative/Layer.lua | 41 +-- .../gis/tests/tif/alternative/TerraLib.lua | 33 +-- packages/gis/tests/tif/basic/Layer.lua | 66 ++--- packages/gis/tests/tif/basic/TerraLib.lua | 8 +- 19 files changed, 206 insertions(+), 668 deletions(-) diff --git a/packages/gis/lua/TerraLib.lua b/packages/gis/lua/TerraLib.lua index 5911b85c..1886d0d7 100644 --- a/packages/gis/lua/TerraLib.lua +++ b/packages/gis/lua/TerraLib.lua @@ -2291,7 +2291,7 @@ TerraLib_ = { local toSrid = toLayer:getSRID() if fromLayer:getSRID() ~= toSrid then local fromSrid = fromLayer:getSRID() - customWarning("Layer projections are different: ("..from..", "..string.format("%.0f", fromSrid)..") and (" + customError("Layer projections are different: ("..from..", "..string.format("%.0f", fromSrid)..") and (" ..to..", "..string.format("%.0f", toSrid).."). Please, reproject your data to the right one.") end diff --git a/packages/gis/tests/functional/alternative/Layer.lua b/packages/gis/tests/functional/alternative/Layer.lua index 8bd48b94..5ae9fb09 100644 --- a/packages/gis/tests/functional/alternative/Layer.lua +++ b/packages/gis/tests/functional/alternative/Layer.lua @@ -221,21 +221,6 @@ return{ unitTest:assertError(attrResolutionNonPositive, positiveArgumentMsg("resolution", 0)) - local unnecessaryArgument = function() - Layer{ - project = proj, - input = "limit", - file = "abc1234.shp", - name = "cells", - resoltion = 200, - resolution = 100000 - } - end - - unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("resoltion", "resolution")) - - File("abc1234.shp"):delete() - noFilePass = function() Layer{ project = proj, @@ -364,21 +349,6 @@ return{ unitTest:assertError(attrBoxNonBoolean, incompatibleTypeMsg("box", "boolean", 123)) - local boxDefaultError = function() - Layer{ - project = proj, - input = layerName1, - name = "cells3", - resolution = 5e4, - box = false, - file = "sampabox.shp" - } - end - - unitTest:assertWarning(boxDefaultError, defaultValueMsg("box", false)) - - File("sampabox.shp"):delete() - local invalidLayerName = function() Layer{ project = proj, @@ -441,22 +411,6 @@ return{ unitTest:assertError(invalidEncoding, "Encoding 'utf16' is invalid.") - local encodingUnnecessary = function() - Layer{ - project = proj, - source = "shp", - input = layerName1, - name = "SPCells", - clean = true, - resolution = 0.7, - file = "csSp.shp", - encoding = "utf8" - } - end - - unitTest:assertWarning(encodingUnnecessary, unnecessaryArgumentMsg("encoding")) - - File("csSp.shp"):delete() File(projName):deleteIfExists() File(shp1):deleteIfExists() end, @@ -630,50 +584,6 @@ return{ unitTest:assertError(attrAlreadyExists, "The attribute '".."row".."' already exists in the Layer.") - local presenceSelectUnnecessary = function() - cl:fill{ - operation = "presence", - layer = layerName1, - attribute = "presence", - select = "FID" - } - end - - unitTest:assertWarning(presenceSelectUnnecessary, unnecessaryArgumentMsg("select")) - - local areaSelectUnnecessary = function() - cl:fill{ - attribute = "areattr", - operation = "area", - layer = layerName1, - select = "FID" - } - end - - unitTest:assertWarning(areaSelectUnnecessary, unnecessaryArgumentMsg("select")) - - local countSelectUnnecessary = function() - cl:fill{ - attribute = "counttr", - operation = "count", - layer = layerName1, - select = "FID" - } - end - - unitTest:assertWarning(countSelectUnnecessary, unnecessaryArgumentMsg("select")) - - local distanceSelectUnnecessary = function() - cl:fill{ - attribute = "disttr", - operation = "distance", - layer = layerName1, - select = "FID" - } - end - - unitTest:assertWarning(distanceSelectUnnecessary, unnecessaryArgumentMsg("select")) - local selectNotString = function() cl:fill{ attribute = "attr", @@ -697,18 +607,6 @@ return{ unitTest:assertError(missingNotNumber, incompatibleTypeMsg("missing", "number", false)) - local unnecessaryArgument = function() - cl:fill{ - attribute = "minttr", - operation = "minimum", - layer = layerName1, - select = "FID", - missin = 3 - } - end - - unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("missin", "missing")) - local selected = "ITNOTEXISTS" local selectNotExists = function() cl:fill{ @@ -756,18 +654,6 @@ return{ unitTest:assertError(missingNotNumber, incompatibleTypeMsg("missing", "number", false)) - unnecessaryArgument = function() - cl:fill{ - attribute = "attr", - operation = "maximum", - layer = layerName1, - select = "FID", - missin = 3 - } - end - - unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("missin", "missing")) - selectNotString = function() cl:fill{ attribute = "attr", @@ -791,18 +677,6 @@ return{ unitTest:assertError(missingNotNumber, incompatibleTypeMsg("missing", "number", false)) - unnecessaryArgument = function() - cl:fill{ - attribute = "covttr", - operation = "coverage", - layer = layerName1, - select = "FID", - missin = 3 - } - end - - unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("missin", "missing")) - selectNotString = function() cl:fill{ attribute = "attr", @@ -826,18 +700,6 @@ return{ unitTest:assertError(missingNotNumber, incompatibleTypeMsg("missing", "number", false)) - missingNotNumber = function() - cl:fill{ - attribute = "sttr", - operation = "stdev", - layer = layerName1, - select = "FID", - missin = 3 - } - end - - unitTest:assertWarning(missingNotNumber, unnecessaryArgumentMsg("missin", "missing")) - selectNotString = function() cl:fill{ attribute = "attr", @@ -873,18 +735,6 @@ return{ unitTest:assertError(missingNotNumber, incompatibleTypeMsg("missing", "number", false)) - unnecessaryArgument = function() - cl:fill{ - attribute = "avettr", - operation = "average", - layer = layerName1, - select = "FID", - missin = 3 - } - end - - unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("missin", "missing")) - selectNotString = function() cl:fill{ attribute = "attr", @@ -920,18 +770,6 @@ return{ unitTest:assertError(missingNotNumber, incompatibleTypeMsg("missing", "number", false)) - unnecessaryArgument = function() - cl:fill{ - attribute = "modttr", - operation = "mode", - layer = layerName1, - select = "FID", - missin = 3 - } - end - - unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("missin", "missing")) - selectNotString = function() cl:fill{ attribute = "attr", @@ -967,29 +805,6 @@ return{ unitTest:assertError(missingNotNumber, incompatibleTypeMsg("missing", "number", false)) - unnecessaryArgument = function() - cl:fill{ - attribute = "sumttr", - operation = "sum", - layer = layerName1, - select = "FID", - missin = 3 - } - end - - unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("missin", "missing")) - - local normalizedNameWarning = function() - cl:fill{ - attribute = "max10allowed", - operation = "sum", - layer = layerName1, - select = "FID" - } - end - - unitTest:assertWarning(normalizedNameWarning, "The 'attribute' lenght has more than 10 characters. It was truncated to 'max10allow'.") - local localidades = "Localidades" Layer{ @@ -1023,17 +838,6 @@ return{ file = filePath("itaituba-deforestation.tif", "gis") } - local areaUnnecessary = function() - cl:fill{ - attribute = "argattr", - operation = "average", - layer = layerName3, - area = 2 - } - end - - unitTest:assertWarning(areaUnnecessary, unnecessaryArgumentMsg("area")) - local selectNotNumber = function() cl:fill{ attribute = "attr", @@ -1068,17 +872,6 @@ return{ -- unitTest:assertError(layerNotIntersect, "The two layers do not intersect.") -- SKIP - areaUnnecessary = function() - cl:fill{ - attribute = "mmittr", - operation = "minimum", - layer = layerName3, - area = 2 - } - end - - unitTest:assertWarning(areaUnnecessary, unnecessaryArgumentMsg("area")) - selectNotNumber = function() cl:fill{ attribute = "attr", @@ -1090,17 +883,6 @@ return{ unitTest:assertError(selectNotNumber, incompatibleTypeMsg("band", "number", "0")) - areaUnnecessary = function() - cl:fill{ - attribute = "mmaxttr", - operation = "maximum", - layer = layerName3, - area = 2 - } - end - - unitTest:assertWarning(areaUnnecessary, unnecessaryArgumentMsg("area")) - selectNotNumber = function() cl:fill{ attribute = "attr", @@ -1112,17 +894,6 @@ return{ unitTest:assertError(selectNotNumber, incompatibleTypeMsg("band", "number", "0")) - areaUnnecessary = function() - cl:fill{ - attribute = "ccvattr", - operation = "coverage", - layer = layerName3, - area = 2 - } - end - - unitTest:assertWarning(areaUnnecessary, unnecessaryArgumentMsg("area")) - selectNotNumber = function() cl:fill{ attribute = "attr", @@ -1134,17 +905,6 @@ return{ unitTest:assertError(selectNotNumber, incompatibleTypeMsg("band", "number", "0")) - areaUnnecessary = function() - cl:fill{ - attribute = "ssdvattr", - operation = "stdev", - layer = layerName3, - area = 2 - } - end - - unitTest:assertWarning(areaUnnecessary, unnecessaryArgumentMsg("area")) - selectNotNumber = function() cl:fill{ attribute = "attr", @@ -1156,17 +916,6 @@ return{ unitTest:assertError(selectNotNumber, incompatibleTypeMsg("band", "number", "0")) - areaUnnecessary = function() - cl:fill{ - attribute = "ssuattr", - operation = "sum", - layer = layerName3, - area = 2 - } - end - - unitTest:assertWarning(areaUnnecessary, unnecessaryArgumentMsg("area")) - selectNotNumber = function() cl:fill{ attribute = "attr", diff --git a/packages/gis/tests/functional/alternative/Project.lua b/packages/gis/tests/functional/alternative/Project.lua index bc68dab1..129a8eb9 100644 --- a/packages/gis/tests/functional/alternative/Project.lua +++ b/packages/gis/tests/functional/alternative/Project.lua @@ -36,22 +36,6 @@ return{ unitTest:assertError(attrFileNonString, incompatibleTypeMsg("file", "File", 123)) - attrFileNonString = function() - Project{file = "abc", author = "No author"} - end - - unitTest:assertWarning(attrFileNonString, defaultValueMsg("author", "No author")) - - File("abc.tview"):delete() - - attrFileNonString = function() - Project{file = "abc", title = "No title"} - end - - unitTest:assertWarning(attrFileNonString, defaultValueMsg("title", "No title")) - - File("abc.tview"):delete() - local attrCreateNonBool = function() Project{file = "myproj.tview", clean = 2} end diff --git a/packages/gis/tests/functional/alternative/TerraLib.lua b/packages/gis/tests/functional/alternative/TerraLib.lua index c09d4df6..4231a1b9 100644 --- a/packages/gis/tests/functional/alternative/TerraLib.lua +++ b/packages/gis/tests/functional/alternative/TerraLib.lua @@ -40,30 +40,6 @@ return { unitTest:assertError(mandatoryExt, "Please, the file extension must be '.tview'.") end, - getArea = function(unitTest) - local proj = {} - proj.file = "myproject.tview" - proj.title = "TerraLib Tests" - proj.author = "Avancini Rodrigo" - - File(proj.file):deleteIfExists() - - TerraLib().createProject(proj, {}) - - local layerName1 = "PA" - local layerFile1 = filePath("itaituba-localities.shp", "gis") - TerraLib().addShpLayer(proj, layerName1, layerFile1) - - local dSet = TerraLib().getDataSet(proj, layerName1) - - local areaError = function() - TerraLib().getArea(dSet[0].OGR_GEOMETRY) - end - - unitTest:assertWarning(areaError, "Geometry should be a polygon to get the area.") - - proj.file:deleteIfExists() - end, saveDataSet = function(unitTest) local proj = {} proj.file = "tlib_savedset.tview" diff --git a/packages/gis/tests/functional/basic/Layer.lua b/packages/gis/tests/functional/basic/Layer.lua index cf77d4cd..e47e6102 100644 --- a/packages/gis/tests/functional/basic/Layer.lua +++ b/packages/gis/tests/functional/basic/Layer.lua @@ -231,12 +231,56 @@ return { clSet = TerraLib().getDataSet(proj, clName1) unitTest:assertEquals(getn(clSet), 104) - projName:deleteIfExists() + local filePath6 = "sampabox.shp" + local boxDefaultError = function() + Layer{ + project = proj, + input = layerName1, + name = "cells3", + resolution = 0.7, + box = false, + file = filePath6 + } + end + unitTest:assertWarning(boxDefaultError, defaultValueMsg("box", false)) + -- \\ BOX + + local filePath5 = "csSp.shp" + local encodingUnnecessary = function() + Layer{ + project = proj, + source = "shp", + input = layerName1, + name = "SPCells", + clean = true, + resolution = 0.7, + file = filePath5, + encoding = "utf8" + } + end + unitTest:assertWarning(encodingUnnecessary, unnecessaryArgumentMsg("encoding")) - File(filePath1):deleteIfExists() - File(filePath2):deleteIfExists() - File(filePath3):deleteIfExists() - File(filePath4):deleteIfExists() + local filePath7 = "cells7.shp" + local unnecessaryArgument = function() + Layer{ + project = proj, + input = layerName1, + file = filePath7, + name = "cells7", + resoltion = 200, + resolution = 0.7 + } + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("resoltion", "resolution")) + + projName:delete() + File(filePath1):delete() + File(filePath2):delete() + File(filePath3):delete() + File(filePath4):delete() + File(filePath5):delete() + File(filePath6):delete() + File(filePath7):delete() end, delete = function(unitTest) local projName = File("cellular_layer_del.tview") diff --git a/packages/gis/tests/functional/basic/Project.lua b/packages/gis/tests/functional/basic/Project.lua index a2976f28..102a0dd2 100644 --- a/packages/gis/tests/functional/basic/Project.lua +++ b/packages/gis/tests/functional/basic/Project.lua @@ -125,6 +125,18 @@ layers vector of size 0 title string [The Amazonia] ]]) - file:deleteIfExists() + file:delete() + + local defaultValueError = function() + Project{file = "abc", title = "No title"} + end + unitTest:assertWarning(defaultValueError, defaultValueMsg("title", "No title")) + File("abc.tview"):delete() + + defaultValueError = function() + Project{file = "abc", author = "No author"} + end + unitTest:assertWarning(defaultValueError, defaultValueMsg("author", "No author")) + File("abc.tview"):delete() end } diff --git a/packages/gis/tests/functional/basic/TerraLib.lua b/packages/gis/tests/functional/basic/TerraLib.lua index 273ac766..0162ad96 100644 --- a/packages/gis/tests/functional/basic/TerraLib.lua +++ b/packages/gis/tests/functional/basic/TerraLib.lua @@ -58,6 +58,29 @@ return { unitTest:assertEquals(TerraLib().checkName("sum"), "Invalid name: using reserved word SUM") unitTest:assertEquals(TerraLib().checkName("file-name"), "Invalid character: mathematical symbol '-'") unitTest:assertEquals(TerraLib().checkName("$ymbol"), "Invalid symbol: '$'") - end + end, + getArea = function(unitTest) + local proj = {} + proj.file = "myproject.tview" + proj.title = "TerraLib Tests" + proj.author = "Avancini Rodrigo" + + File(proj.file):deleteIfExists() + + TerraLib().createProject(proj, {}) + + local layerName1 = "PA" + local layerFile1 = filePath("itaituba-localities.shp", "gis") + TerraLib().addShpLayer(proj, layerName1, layerFile1) + + local dSet = TerraLib().getDataSet(proj, layerName1) + + local areaWarn = function() + TerraLib().getArea(dSet[0].OGR_GEOMETRY) + end + unitTest:assertWarning(areaWarn, "Geometry should be a polygon to get the area.") + + proj.file:delete() + end, } diff --git a/packages/gis/tests/nc/basic/Layer.lua b/packages/gis/tests/nc/basic/Layer.lua index ff2b0766..090db7a6 100644 --- a/packages/gis/tests/nc/basic/Layer.lua +++ b/packages/gis/tests/nc/basic/Layer.lua @@ -32,11 +32,6 @@ return { clean = true } - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - local layerName1 = "Vegtype_layer" Layer { @@ -64,10 +59,8 @@ return { unitTest:assertEquals(cl1.source, "shp") -- SKIP unitTest:assertEquals(cl1.file, currentDir()..filePath1) -- SKIP - File(filePath1):deleteIfExists() - File(projName):deleteIfExists() - - customWarning = customWarningBkp + File(filePath1):delete() + File(projName):delete() else unitTest:assert(true) -- SKIP end @@ -81,11 +74,6 @@ return { clean = true } - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - local vegType = "Vegtype_layer" local l = Layer { project = proj, @@ -95,9 +83,7 @@ return { unitTest:assertEquals(l:representation(), "raster") -- SKIP - File(projName):deleteIfExists() - - customWarning = customWarningBkp + File(projName):delete() else unitTest:assert(true) -- SKIP end @@ -111,11 +97,6 @@ return { clean = true } - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - local vegType = "Vegtype_layer" local l = Layer { project = proj, @@ -125,9 +106,7 @@ return { unitTest:assertEquals(l:bands(), 1) -- SKIP - File(projName):deleteIfExists() - - customWarning = customWarningBkp + File(projName):delete() else unitTest:assert(true) -- SKIP end @@ -141,11 +120,6 @@ return { clean = true } - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - local layerName1 = "Vegtype_layer" local l = Layer { @@ -163,9 +137,7 @@ rep string [raster] source string [nc] ]], 0, true) - File(projName):deleteIfExists() - - customWarning = customWarningBkp + File(projName):delete() else unitTest:assert(true) -- SKIP end diff --git a/packages/gis/tests/postgis/alternative/Layer.lua b/packages/gis/tests/postgis/alternative/Layer.lua index bf97fb72..60233d13 100644 --- a/packages/gis/tests/postgis/alternative/Layer.lua +++ b/packages/gis/tests/postgis/alternative/Layer.lua @@ -79,25 +79,6 @@ return { unitTest:assertError(layerAlreadyExists, "Layer '"..layerName2.."' already exists in the Project.") - local mlayer - - local fileUnnecessary = function() - mlayer = Layer{ - project = proj1, - source = "postgis", - name = layerName2.."u", - port = port, - password = password, - database = database, - table = tableName, - file = filePath("test/sampa.shp", "gis") - } - end - - unitTest:assertWarning(fileUnnecessary, unnecessaryArgumentMsg("file")) - - mlayer:delete() - local sourceMandatory = function() Layer{ project = proj1, @@ -657,24 +638,6 @@ return { TerraLib().dropPgTable(data) - local unnecessaryArgument = function() - mlayer = Layer{ - project = proj, - source = "postgis", - input = layerName1, - name = clName1.."f", - resolution = 0.7, - password = password, - database = database, - table = tName1.."b", - file = filePath("test/sampa.shp", "gis") - } - end - - unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("file")) - - mlayer:delete() - local boxNonBoolean = function() Layer{ project = proj, @@ -840,39 +803,6 @@ return { if File(projName):exists() then File(projName):deleteIfExists() end - - -- SPATIAL INDEX TEST - proj = Project{ - file = projName, - clean = true, - author = "Avancini", - title = "The Amazonia" - } - - Layer{ - project = proj, - name = layerName1, - file = filePath("test/sampa.shp", "gis") - } - - local indexUnnecessary = function() - Layer{ - project = proj, - source = "postgis", - input = layerName1, - name = clName1.."i", - resolution = 0.7, - password = password, - database = database, - table = tName1, - index = true - } - end - - unitTest:assertWarning(indexUnnecessary, unnecessaryArgumentMsg("index")) - - proj.file:delete() - -- // SPATIAL INDEX TEST end, export = function(unitTest) local projName = "layer_func_alt.tview" diff --git a/packages/gis/tests/postgis/basic/Layer.lua b/packages/gis/tests/postgis/basic/Layer.lua index b9e76e78..fd630cb5 100644 --- a/packages/gis/tests/postgis/basic/Layer.lua +++ b/packages/gis/tests/postgis/basic/Layer.lua @@ -208,36 +208,43 @@ return { local tName4 = string.lower(clName1) pgData.table = tName4 - Layer{ - project = proj, - source = "postgis", - input = layerName1, - clean = true, - name = clName1, - resolution = 0.7, - box = true, - password = password, - database = database - } - + local unnecessaryArgument = function() + Layer{ + project = proj, + source = "postgis", + input = layerName1, + clean = true, + name = clName1, + resolution = 0.7, + box = true, + password = password, + database = database, + file = filePath("test/sampa.shp", "gis") + } + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("file")) clSet = TerraLib().getDataSet(proj, clName1) unitTest:assertEquals(getn(clSet), 104) -- CHANGE EPSG local layerName5 = "SampaDBNewSrid" - local layer5 = Layer{ - project = proj, - source = "postgis", - name = layerName5, - -- host = host, - -- port = port, - password = password, - database = database, - table = tName1, - epsg = 29901 - } - + local layer5 + local indexUnnecessary = function() + layer5 = Layer{ + project = proj, + source = "postgis", + name = layerName5, + -- host = host, + -- port = port, + password = password, + database = database, + table = tName1, + epsg = 29901, + index = true + } + end + unitTest:assertWarning(indexUnnecessary, unnecessaryArgumentMsg("index")) unitTest:assertEquals(layer5.epsg, 29901.0) unitTest:assert(layer5.epsg ~= layer4.epsg) -- // CHANGE EPSG @@ -276,8 +283,7 @@ return { -- table = tableName -- } - File(projName):deleteIfExists() - + File(projName):delete() l1:delete() -- layer1:delete() -- layer1 should not be deleted. What must be deleted is the exported data. -- layer2:delete() -- layer2 was read from a pg database. it does not have an encoding @@ -323,12 +329,6 @@ return { end, fill = function(unitTest) local projName = "cellular_layer_fill_pgis.tview" - - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - local layerName1 = "limitepa" local protecao = "protecao" local rodovias = "Rodovias" @@ -933,7 +933,6 @@ return { unitTest:assertSnapshot(map, "polygons-coverage-2-pg.png", 0.1) - customWarning = customWarningBkp proj.file:delete() -- TIFF @@ -944,11 +943,6 @@ return { clean = true } - customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - layerName1 = "limiteitaituba" local l1 = Layer{ project = proj, @@ -1223,8 +1217,6 @@ return { unitTest:assertSnapshot(map, "tiff-average-nodata-pg.png") File(projName):delete() - - customWarning = customWarningBkp end, projection = function(unitTest) local projName = "layer_basic.tview" diff --git a/packages/gis/tests/postgis/basic/TerraLib.lua b/packages/gis/tests/postgis/basic/TerraLib.lua index a8c67fc6..878e7918 100644 --- a/packages/gis/tests/postgis/basic/TerraLib.lua +++ b/packages/gis/tests/postgis/basic/TerraLib.lua @@ -188,11 +188,6 @@ return { -- CREATE A PROJECT TerraLib().createProject(proj, {}) - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - -- CREATE A LAYER THAT WILL BE USED AS REFERENCE TO CREATE THE CELLULAR SPACE local layerName1 = "Para" local layerFile1 = filePath("test/limitePA_polyc_pol.shp", "gis") @@ -1115,8 +1110,6 @@ return { -- END POSTGIS TESTS proj.file:delete() - - customWarning = customWarningBkp end, getDataSet = function(unitTest) -- see in saveDataSet() test -- diff --git a/packages/gis/tests/shapefile/alternative/Layer.lua b/packages/gis/tests/shapefile/alternative/Layer.lua index 118f4b7d..2cddce11 100644 --- a/packages/gis/tests/shapefile/alternative/Layer.lua +++ b/packages/gis/tests/shapefile/alternative/Layer.lua @@ -23,62 +23,6 @@ ------------------------------------------------------------------------------------------- return { - Layer = function(unitTest) - local projName = "layer_shape_alt.tview" - - local proj = Project { - file = projName, - clean = true - } - - -- SPATIAL INDEX TEST - local layerName1 = "Setores" - - local indexDefaultError1 = function() - Layer{ - project = proj, - name = layerName1.."c", - file = filePath("itaituba-census.shp", "gis"), - index = true - } - end - - unitTest:assertWarning(indexDefaultError1, defaultValueMsg("index", true)) - - Layer{ - project = proj, - name = layerName1, - file = filePath("itaituba-census.shp", "gis") - } - - local clName1 = "PA_Cells50x50" - local indexDefaultError2 = function() - Layer{ - project = proj, - source = "shp", - clean = true, - input = layerName1, - name = clName1, - resolution = 50000, - file = clName1..".shp", - index = true - } - end - - unitTest:assertWarning(indexDefaultError2, defaultValueMsg("index", true)) - File(clName1..".shp"):delete() - - local epsgError = function() - Layer{ - project = proj, - name = "Elevation", - file = filePath("cabecadeboi-box.shp", "gis") - } - end - unitTest:assertWarning(epsgError, "It was not possible to find the projection of layer 'Elevation'. It should be one of the projections available at www.terrame.org/projections.html") - - proj.file:delete() - end, export = function(unitTest) local projName = "layer_func_alt.tview" diff --git a/packages/gis/tests/shapefile/alternative/TerraLib.lua b/packages/gis/tests/shapefile/alternative/TerraLib.lua index 4c3ff378..c5dfaf07 100644 --- a/packages/gis/tests/shapefile/alternative/TerraLib.lua +++ b/packages/gis/tests/shapefile/alternative/TerraLib.lua @@ -33,11 +33,6 @@ return { TerraLib().createProject(proj, {}) - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - local layerName1 = "Para" local layerFile1 = filePath("test/limitePA_polyc_pol.shp", "gis") TerraLib().addShpLayer(proj, layerName1, layerFile1) @@ -71,14 +66,6 @@ return { local area = nil local default = nil - customWarning = customWarningBkp - - local attributeTruncateWarning = function() - TerraLib().attributeFill(proj, layerName2, clName, presLayerName, attribute, operation, select, area, default) - end - - unitTest:assertWarning(attributeTruncateWarning, "The 'attribute' lenght has more than 10 characters. It was truncated to 'presence_t'.") - attribute = "FID" local attributeAlreadyExists = function() TerraLib().attributeFill(proj, layerName2, clName, presLayerName, attribute, operation, select, area, default) diff --git a/packages/gis/tests/shapefile/basic/Layer.lua b/packages/gis/tests/shapefile/basic/Layer.lua index 746c3099..b90ac820 100644 --- a/packages/gis/tests/shapefile/basic/Layer.lua +++ b/packages/gis/tests/shapefile/basic/Layer.lua @@ -75,23 +75,58 @@ return { unitTest:assert(not File(qixFile):exists()) local clName2 = "Setores_Cells9x9" - local cl2 = Layer{ - project = proj, - source = "shp", - clean = true, - input = layerName1, - name = clName2, - resolution = 9e3, - file = clName2..".shp" - } - + local cl2 + local indexWarn2 = function() + cl2 = Layer{ + project = proj, + source = "shp", + clean = true, + input = layerName1, + name = clName2, + resolution = 9e3, + file = clName2..".shp", + index = true + } + end + unitTest:assertWarning(indexWarn2, defaultValueMsg("index", true)) qixFile = string.gsub(cl2.file, ".shp", ".qix") unitTest:assert(File(qixFile):exists()) File(cl1.file):delete() File(cl2.file):delete() + -- \\ SPATIAL INDEX + + local l1Name = "Elevation" + local l1 + local epsgWarn = function() + l1 = Layer{ + project = proj, + name = l1Name, + file = filePath("cabecadeboi-box.shp", "gis") + } + end + unitTest:assertWarning(epsgWarn, "It was not possible to find the projection of layer 'Elevation'. It should be one of the projections available at www.terrame.org/projections.html") + unitTest:assertEquals(l1.name, l1Name) + + local clName1 = "PA_Cells50x50" + local clLayer1 + local indexWarn = function() + clLayer1 = Layer{ + project = proj, + source = "shp", + clean = true, + input = layerName1, + name = clName1, + resolution = 50000, + file = clName1..".shp", + index = true + } + end + unitTest:assertWarning(indexWarn, defaultValueMsg("index", true)) + unitTest:assertEquals(clLayer1.name, clName1) proj.file:delete() + File(clLayer1.file):delete() end, __len = function(unitTest) local projName = "layer_shape_basic.tview" @@ -108,12 +143,6 @@ return { end, fill = function(unitTest) local projName = "cellular_layer_fill_shape.tview" - - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - local layerName1 = "limitepa" local protecao = "protecao" local rodovias = "Rodovias" @@ -716,7 +745,6 @@ return { unitTest:assertSnapshot(map, "polygons-coverage-2.png", 0.1) - customWarning = customWarningBkp proj.file:delete() forEachElement(shapes, function(_, value) @@ -738,11 +766,6 @@ return { unitTest:assertEquals(layer:projection(), "'SAD69 / UTM zone 21S', with EPSG: 29191 (PROJ4: '+proj=utm +zone=21 +south +ellps=aust_SA +towgs84=-66.87,4.37,-38.52,0,0,0,0 +units=m +no_defs ')") - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - layer = Layer{ project = proj, name = "PA", @@ -752,8 +775,6 @@ return { unitTest:assertEquals(layer:projection(), "'SAD69 / Brazil Polyconic', with EPSG: 29101 (PROJ4: '+proj=poly +lat_0=0 +lon_0=-54 +x_0=5000000 +y_0=10000000 +ellps=aust_SA +towgs84=-66.87,4.37,-38.52,0,0,0,0 +units=m +no_defs ')") - customWarning = customWarningBkp - proj.file:delete() end, attributes = function(unitTest) diff --git a/packages/gis/tests/shapefile/basic/TerraLib.lua b/packages/gis/tests/shapefile/basic/TerraLib.lua index d2b98f51..7f762144 100644 --- a/packages/gis/tests/shapefile/basic/TerraLib.lua +++ b/packages/gis/tests/shapefile/basic/TerraLib.lua @@ -181,11 +181,6 @@ return { TerraLib().createProject(proj, {}) - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - local layerName1 = "Para" local layerFile1 = filePath("test/limitePA_polyc_pol.shp", "gis") TerraLib().addShpLayer(proj, layerName1, layerFile1) @@ -678,8 +673,12 @@ return { select = 0 area = nil default = nil - TerraLib().attributeFill(proj, layerName4, wsumLayerName, percTifLayerName, attribute, operation, select, area, default) - + + local attributeTruncateWarning = function() + TerraLib().attributeFill(proj, layerName4, wsumLayerName, percTifLayerName, attribute, operation, select, area, default) + end + unitTest:assertWarning(attributeTruncateWarning, "The 'attribute' lenght has more than 10 characters. It was truncated to 'rpercentag'.") + percentSet = TerraLib().getDataSet(proj, percTifLayerName, 0) unitTest:assertEquals(getn(percentSet), 9) @@ -1011,8 +1010,6 @@ return { end proj.file:delete() - - customWarning = customWarningBkp end, getDataSet = function(unitTest) -- see in saveDataSet() test -- diff --git a/packages/gis/tests/tif/alternative/Layer.lua b/packages/gis/tests/tif/alternative/Layer.lua index 722e7c8e..84b0d435 100644 --- a/packages/gis/tests/tif/alternative/Layer.lua +++ b/packages/gis/tests/tif/alternative/Layer.lua @@ -56,28 +56,8 @@ return { -- unitTest:assertError(boxUnnecessary, unnecessaryArgumentMsg("box")) -- SKIP -- File(projName):delete() - - -- SPATIAL INDEX TEST - local projName = "layer_tif_alternative.tview" - - local proj = Project{ - file = projName, - clean = true - } - - local prodes = "prodes" - local indexUnnecessary = function() - Layer{ - project = proj, - name = prodes, - file = filePath("amazonia-prodes.tif", "gis"), - index = true - } - end - - unitTest:assertWarning(indexUnnecessary, unnecessaryArgumentMsg("index")) - - proj.file:delete() + + unitTest:assert(true) end, fill = function(unitTest) local projName = "cellular_layer_fill_tiff_alternative.tview" @@ -176,18 +156,7 @@ return { unitTest:assertError(dummyTypeError, incompatibleTypeMsg("dummy", "number", true)) - local nodataDefaultError = function() - clcabeca:fill{ - operation = "average", - attribute = "aver_nd", - layer = "altimetria", - dummy = 255 - } - end - - unitTest:assertWarning(nodataDefaultError, defaultValueMsg("dummy", 255.0)) -- SKIP - - local diffSridWarning = function() + local diffSridError = function() cl:fill{ operation = "average", attribute = "aver", @@ -195,11 +164,11 @@ return { } end - unitTest:assertWarning(diffSridWarning, "Layer projections are different: (altimetria, 2311) and (cells, 29101). Please, reproject your data to the right one.") + unitTest:assertError(diffSridError, "Layer projections are different: (altimetria, 2311) and (cells, 29101). Please, reproject your data to the right one.") File("cabecadeboi.shp"):delete() File(projName):delete() - File(shp1):deleteIfExists() + File(shp1):delete() end, dummy = function(unitTest) local projName = "layer_tif_nodata.tview" diff --git a/packages/gis/tests/tif/alternative/TerraLib.lua b/packages/gis/tests/tif/alternative/TerraLib.lua index f4b3b9a2..7378892d 100644 --- a/packages/gis/tests/tif/alternative/TerraLib.lua +++ b/packages/gis/tests/tif/alternative/TerraLib.lua @@ -23,37 +23,6 @@ ------------------------------------------------------------------------------------------- return { - addShpCellSpaceLayer = function(unitTest) - local proj = {} - proj.file = "myproject.tview" - proj.title = "TerraLib Tests" - proj.author = "Avancini Rodrigo" - - File(proj.file):deleteIfExists() - - TerraLib().createProject(proj, {}) - - local layerName1 = "AmazoniaTif" - local layerFile1 = filePath("amazonia-prodes.tif", "gis") - TerraLib().addGdalLayer(proj, layerName1, layerFile1) - - local clName = "Amazonia_Cells" - local shp1 = File(clName..".shp") - - shp1:deleteIfExists() - - local resolution = 60e3 - local mask = true - - local maskNotWork = function() - TerraLib().addShpCellSpaceLayer(proj, layerName1, clName, resolution, shp1, mask) - end - - unitTest:assertWarning(maskNotWork, "The 'mask' not work to Raster, it was ignored.") - - proj.file:delete() - File("Amazonia_Cells.shp"):delete() - end, --addPgCellSpaceLayer = function(unitTest) -- #1152 --end, @@ -125,7 +94,7 @@ return { TerraLib().attributeFill(proj, layerName2, clName, percTifLayerName, attribute, operation, select, area, default, repr) end - unitTest:assertWarning(differentSrids, "Layer projections are different: (Prodes_PA, 29100) and (Para_Cells, 29101). Please, reproject your data to the right one.") + unitTest:assertError(differentSrids, "Layer projections are different: (Prodes_PA, 29100) and (Para_Cells, 29101). Please, reproject your data to the right one.") local layerName3 = "Prodes_PA_NewSRID" TerraLib().addGdalLayer(proj, layerName3, layerFile4, 29101) diff --git a/packages/gis/tests/tif/basic/Layer.lua b/packages/gis/tests/tif/basic/Layer.lua index fd6366f1..05d85e3f 100644 --- a/packages/gis/tests/tif/basic/Layer.lua +++ b/packages/gis/tests/tif/basic/Layer.lua @@ -32,11 +32,15 @@ return { } local layerName1 = "Prodes" - Layer{ - project = proj, - name = layerName1, - file = filePath("amazonia-prodes.tif", "gis") - } + local indexUnnecessary = function() + Layer{ + project = proj, + name = layerName1, + file = filePath("amazonia-prodes.tif", "gis"), + index = true + } + end + unitTest:assertWarning(indexUnnecessary, unnecessaryArgumentMsg("index")) local filePath1 = "prodes_cells_tif_basic.shp" @@ -63,19 +67,12 @@ return { __len = function(unitTest) local projName = "layer_tiff_basic.tview" - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - local proj = Project{ file = projName, prodes = filePath("test/prodes_polyc_10k.tif", "gis"), clean = true } - customWarning = customWarningBkp - unitTest:assertEquals(#proj.prodes, 20020) proj.file:delete() @@ -88,11 +85,6 @@ return { clean = true } - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - local layerName1 = "limiteitaituba" local l1 = Layer{ project = proj, @@ -109,7 +101,7 @@ return { } local altimetria = "altimetria" - Layer{ + local altLayer = Layer{ project = proj, name = altimetria, file = filePath("itaituba-elevation.tif", "gis"), @@ -299,12 +291,15 @@ return { end -- AVERAGE - - cl:fill{ - operation = "average", - layer = "altimetria", - attribute = "height" - } + local nodataDefaultWarn = function() + cl:fill{ + operation = "average", + layer = "altimetria", + attribute = "height", + dummy = altLayer:dummy() + } + end + unitTest:assertWarning(nodataDefaultWarn, defaultValueMsg("dummy", altLayer:dummy())) cs = CellularSpace{ project = proj, @@ -427,8 +422,6 @@ return { File("amazonia-indigenous.shp"):delete() File("fill_mcount.tview"):delete() - - customWarning = customWarningBkp end, representation = function(unitTest) local projName = "layer_fill_tiff_repr.tview" @@ -438,11 +431,6 @@ return { clean = true } - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - local prodes = "prodes" local l = Layer{ project = proj, @@ -453,8 +441,6 @@ return { unitTest:assertEquals(l:representation(), "raster") File(projName):delete() - - customWarning = customWarningBkp end, bands = function(unitTest) local projName = "layer_tif_bands.tview" @@ -464,11 +450,6 @@ return { clean = true } - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - local prodes = "prodes" local l = Layer{ project = proj, @@ -479,8 +460,6 @@ return { unitTest:assertEquals(l:bands(), 1) File(projName):delete() - - customWarning = customWarningBkp end, projection = function(unitTest) local projName = "tif_basic.tview" @@ -530,11 +509,6 @@ return { clean = true } - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - local prodes = "prodes" local l = Layer{ project = proj, @@ -554,8 +528,6 @@ return { unitTest:assertNil(l:dummy()) File(projName):delete() - - customWarning = customWarningBkp end } diff --git a/packages/gis/tests/tif/basic/TerraLib.lua b/packages/gis/tests/tif/basic/TerraLib.lua index 985b3fc3..a1da52fe 100644 --- a/packages/gis/tests/tif/basic/TerraLib.lua +++ b/packages/gis/tests/tif/basic/TerraLib.lua @@ -66,8 +66,12 @@ return { shp1:deleteIfExists() local resolution = 2e5 - local mask = false - TerraLib().addShpCellSpaceLayer(proj, layerName1, clName, resolution, shp1, mask) + local mask = true + + local maskNotWork = function() + TerraLib().addShpCellSpaceLayer(proj, layerName1, clName, resolution, shp1, mask) + end + unitTest:assertWarning(maskNotWork, "The 'mask' not work to Raster, it was ignored.") local layerInfo = TerraLib().getLayerInfo(proj, clName) From c4d44083b3f5da1d5ff953712401a356558eeb0f Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Thu, 6 Jul 2017 14:05:11 -0300 Subject: [PATCH 05/36] Corrections #1878. --- packages/gis/tests/functional/basic/Project.lua | 4 ++-- .../gis/tests/shapefile/alternative/TerraLib.lua | 3 +-- packages/gis/tests/shapefile/basic/Layer.lua | 14 +++++++------- packages/gis/tests/shapefile/basic/TerraLib.lua | 4 ++-- packages/gis/tests/tif/alternative/Layer.lua | 12 +----------- packages/gis/tests/tif/basic/TerraLib.lua | 2 +- 6 files changed, 14 insertions(+), 25 deletions(-) diff --git a/packages/gis/tests/functional/basic/Project.lua b/packages/gis/tests/functional/basic/Project.lua index 102a0dd2..67c9a9a3 100644 --- a/packages/gis/tests/functional/basic/Project.lua +++ b/packages/gis/tests/functional/basic/Project.lua @@ -132,11 +132,11 @@ title string [The Amazonia] end unitTest:assertWarning(defaultValueError, defaultValueMsg("title", "No title")) File("abc.tview"):delete() - + defaultValueError = function() Project{file = "abc", author = "No author"} end unitTest:assertWarning(defaultValueError, defaultValueMsg("author", "No author")) - File("abc.tview"):delete() + File("abc.tview"):delete() end } diff --git a/packages/gis/tests/shapefile/alternative/TerraLib.lua b/packages/gis/tests/shapefile/alternative/TerraLib.lua index c5dfaf07..4b4aa177 100644 --- a/packages/gis/tests/shapefile/alternative/TerraLib.lua +++ b/packages/gis/tests/shapefile/alternative/TerraLib.lua @@ -61,12 +61,11 @@ return { shp[2]:deleteIfExists() local operation = "presence" - local attribute = "presence_truncate" + local attribute = "FID" local select = "FID" local area = nil local default = nil - attribute = "FID" local attributeAlreadyExists = function() TerraLib().attributeFill(proj, layerName2, clName, presLayerName, attribute, operation, select, area, default) end diff --git a/packages/gis/tests/shapefile/basic/Layer.lua b/packages/gis/tests/shapefile/basic/Layer.lua index b90ac820..d9b8000f 100644 --- a/packages/gis/tests/shapefile/basic/Layer.lua +++ b/packages/gis/tests/shapefile/basic/Layer.lua @@ -108,25 +108,25 @@ return { unitTest:assertWarning(epsgWarn, "It was not possible to find the projection of layer 'Elevation'. It should be one of the projections available at www.terrame.org/projections.html") unitTest:assertEquals(l1.name, l1Name) - local clName1 = "PA_Cells50x50" - local clLayer1 + local clName3 = "PA_Cells50x50" + local clLayer3 local indexWarn = function() - clLayer1 = Layer{ + clLayer3 = Layer{ project = proj, source = "shp", clean = true, input = layerName1, - name = clName1, + name = clName3, resolution = 50000, - file = clName1..".shp", + file = clName3..".shp", index = true } end unitTest:assertWarning(indexWarn, defaultValueMsg("index", true)) - unitTest:assertEquals(clLayer1.name, clName1) + unitTest:assertEquals(clLayer3.name, clName3) proj.file:delete() - File(clLayer1.file):delete() + File(clLayer3.file):delete() end, __len = function(unitTest) local projName = "layer_shape_basic.tview" diff --git a/packages/gis/tests/shapefile/basic/TerraLib.lua b/packages/gis/tests/shapefile/basic/TerraLib.lua index 7f762144..992a1afe 100644 --- a/packages/gis/tests/shapefile/basic/TerraLib.lua +++ b/packages/gis/tests/shapefile/basic/TerraLib.lua @@ -673,12 +673,12 @@ return { select = 0 area = nil default = nil - + local attributeTruncateWarning = function() TerraLib().attributeFill(proj, layerName4, wsumLayerName, percTifLayerName, attribute, operation, select, area, default) end unitTest:assertWarning(attributeTruncateWarning, "The 'attribute' lenght has more than 10 characters. It was truncated to 'rpercentag'.") - + percentSet = TerraLib().getDataSet(proj, percTifLayerName, 0) unitTest:assertEquals(getn(percentSet), 9) diff --git a/packages/gis/tests/tif/alternative/Layer.lua b/packages/gis/tests/tif/alternative/Layer.lua index 84b0d435..52626eef 100644 --- a/packages/gis/tests/tif/alternative/Layer.lua +++ b/packages/gis/tests/tif/alternative/Layer.lua @@ -56,7 +56,7 @@ return { -- unitTest:assertError(boxUnnecessary, unnecessaryArgumentMsg("box")) -- SKIP -- File(projName):delete() - + unitTest:assert(true) end, fill = function(unitTest) @@ -125,15 +125,6 @@ return { epsg = 2311 } - local clcabeca = Layer{ - project = proj, - clean = true, - file = "cabecadeboi.shp", - input = "box", - name = "cellscabeca", - resolution = 600 - } - invalidBand = function() cl:fill{ operation = "mode", @@ -166,7 +157,6 @@ return { unitTest:assertError(diffSridError, "Layer projections are different: (altimetria, 2311) and (cells, 29101). Please, reproject your data to the right one.") - File("cabecadeboi.shp"):delete() File(projName):delete() File(shp1):delete() end, diff --git a/packages/gis/tests/tif/basic/TerraLib.lua b/packages/gis/tests/tif/basic/TerraLib.lua index a1da52fe..f4508257 100644 --- a/packages/gis/tests/tif/basic/TerraLib.lua +++ b/packages/gis/tests/tif/basic/TerraLib.lua @@ -67,7 +67,7 @@ return { local resolution = 2e5 local mask = true - + local maskNotWork = function() TerraLib().addShpCellSpaceLayer(proj, layerName1, clName, resolution, shp1, mask) end From 375437a3809a41172940c33431fc6bfc78ec8540 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Mon, 10 Jul 2017 11:11:20 -0300 Subject: [PATCH 06/36] Close #1878 - move alternative tests that use assertWarning() to basic tests. --- packages/base/lua/CellularSpace.lua | 6 +- .../base/tests/database/alternative/Cell.lua | 12 +- .../database/alternative/CellularSpace.lua | 24 -- packages/base/tests/database/basics/Cell.lua | 24 +- .../tests/database/basics/CellularSpace.lua | 29 ++- .../tests/functional/alternative/Agent.lua | 16 +- .../functional/alternative/CellularSpace.lua | 173 ++----------- .../tests/functional/alternative/Choice.lua | 38 --- .../functional/alternative/Directory.lua | 15 -- .../functional/alternative/Environment.lua | 6 - .../functional/alternative/ErrorHandling.lua | 7 - .../tests/functional/alternative/Event.lua | 77 +----- .../tests/functional/alternative/File.lua | 18 +- .../tests/functional/alternative/Group.lua | 33 --- .../tests/functional/alternative/Model.lua | 15 +- .../functional/alternative/Neighborhood.lua | 8 +- .../tests/functional/alternative/Package.lua | 6 - .../tests/functional/alternative/Random.lua | 36 --- .../functional/alternative/SocialNetwork.lua | 15 -- .../tests/functional/alternative/Society.lua | 134 +--------- .../tests/functional/alternative/Timer.lua | 15 -- .../functional/alternative/Trajectory.lua | 37 --- .../tests/functional/alternative/Utils.lua | 12 - .../base/tests/functional/basics/Agent.lua | 28 ++- .../tests/functional/basics/CellularSpace.lua | 183 +++++++++++--- .../base/tests/functional/basics/Choice.lua | 30 ++- .../tests/functional/basics/Directory.lua | 12 +- .../tests/functional/basics/Environment.lua | 5 +- .../tests/functional/basics/ErrorHandling.lua | 7 + .../base/tests/functional/basics/Event.lua | 109 ++++++-- .../base/tests/functional/basics/File.lua | 16 ++ .../base/tests/functional/basics/Group.lua | 46 +++- .../base/tests/functional/basics/Model.lua | 67 ++++- .../tests/functional/basics/Neighborhood.lua | 10 + .../base/tests/functional/basics/Package.lua | 6 + .../base/tests/functional/basics/Random.lua | 60 ++++- .../tests/functional/basics/SocialNetwork.lua | 8 + .../base/tests/functional/basics/Society.lua | 213 ++++++++++++++-- .../base/tests/functional/basics/Timer.lua | 11 + .../tests/functional/basics/Trajectory.lua | 53 ++-- .../base/tests/functional/basics/Utils.lua | 36 +-- .../base/tests/observer/alternative/Chart.lua | 74 +++++- .../base/tests/observer/alternative/Clock.lua | 8 - .../observer/alternative/Environment.lua | 106 -------- .../base/tests/observer/alternative/Event.lua | 37 --- .../observer/alternative/InternetSender.lua | 5 + .../base/tests/observer/alternative/Map.lua | 70 +----- packages/base/tests/observer/basics/Chart.lua | 20 +- packages/base/tests/observer/basics/Clock.lua | 6 +- packages/base/tests/observer/basics/Event.lua | 8 +- .../tests/observer/basics/InternetSender.lua | 1 + packages/base/tests/observer/basics/Map.lua | 234 +++++++++++------- 52 files changed, 1082 insertions(+), 1143 deletions(-) delete mode 100644 packages/base/tests/observer/alternative/Environment.lua delete mode 100644 packages/base/tests/observer/alternative/Event.lua diff --git a/packages/base/lua/CellularSpace.lua b/packages/base/lua/CellularSpace.lua index 5556a4c2..d3973329 100644 --- a/packages/base/lua/CellularSpace.lua +++ b/packages/base/lua/CellularSpace.lua @@ -969,16 +969,14 @@ CellularSpace_ = { positiveTableArgument(data, "m") if data.m % 2 == 0 then - data.m = data.m + 1 - customWarning("Argument 'm' is even. It will be increased by one to keep the Cell in the center of the Neighborhood.") + customError("Value or argument 'm' should be even, got "..data.m..".") end defaultTableValue(data, "n", data.m) integerTableArgument(data, "n") positiveTableArgument(data, "n") if data.n % 2 == 0 then - data.n = data.n + 1 - customWarning("Argument 'n' is even. It will be increased by one to keep the Cell in the center of the Neighborhood.") + customError("Value or argument 'n' should be even, got "..data.n..".") end data.func = getMxNNeighborhood diff --git a/packages/base/tests/database/alternative/Cell.lua b/packages/base/tests/database/alternative/Cell.lua index bd4c47e2..31318e0a 100644 --- a/packages/base/tests/database/alternative/Cell.lua +++ b/packages/base/tests/database/alternative/Cell.lua @@ -38,17 +38,13 @@ return{ title = title } - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - local layerName1 = "Brazil" gis.Layer{ project = proj, name = layerName1, - file = filePath("brazilstates.shp", "base") + file = filePath("brazilstates.shp", "base"), + epsg = 4326 } -- SHAPE @@ -80,7 +76,6 @@ return{ -- POSTGIS local clName2 = "Brazil_Cells_PG" - local user = "postgres" local password = getConfig().password local database = "postgis_22_sample" @@ -90,7 +85,6 @@ return{ input = layerName1, name = clName2, resolution = 100e3, - user = user, password = password, database = database, clean = true @@ -111,7 +105,5 @@ return{ File(filePath1):deleteIfExists() pgLayer:delete() - - customWarning = customWarningBkp end } diff --git a/packages/base/tests/database/alternative/CellularSpace.lua b/packages/base/tests/database/alternative/CellularSpace.lua index b92f73a0..478a5757 100644 --- a/packages/base/tests/database/alternative/CellularSpace.lua +++ b/packages/base/tests/database/alternative/CellularSpace.lua @@ -64,24 +64,6 @@ return{ unitTest:assertError(error_func, "File '"..pgmFile.."' does not contain the PGM identifier 'P2' in its first line.") - pgmFile = filePath("test/error/pgm-invalid-size.pgm", "base") - error_func = function() - CellularSpace{ - file = pgmFile - } - end - - unitTest:assertWarning(error_func, "Data from file '"..pgmFile.."' does not match declared size: expected '(2, 2)', got '(10, 10)'.") - - pgmFile = filePath("test/error/pgm-invalid-max.pgm", "base") - error_func = function() - CellularSpace{ - file = pgmFile - } - end - - unitTest:assertWarning(error_func, "File '"..pgmFile.."' does not have a maximum value declared.") - error_func = function() cs = CellularSpace{file = 2, source = "pgm", sep = ";"} end @@ -265,12 +247,6 @@ return{ file = filePath("brazilstates.shp") } - error_func = function() - cs:loadNeighborhood{file = filePath("test/brazil-ok.gal"), che = false} - end - - unitTest:assertWarning(error_func, unnecessaryArgumentMsg("che")) - mfile = filePath("test/brazil.gal") error_func = function() diff --git a/packages/base/tests/database/basics/Cell.lua b/packages/base/tests/database/basics/Cell.lua index 024ca669..b7f3fccf 100644 --- a/packages/base/tests/database/basics/Cell.lua +++ b/packages/base/tests/database/basics/Cell.lua @@ -38,17 +38,13 @@ return{ title = title } - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - local layerName1 = "Brazil" gis.Layer{ project = proj, name = layerName1, - file = filePath("brazilstates.shp", "base") + file = filePath("brazilstates.shp", "base"), + epsg = 4326 } -- SHAPE @@ -78,7 +74,6 @@ return{ -- POSTGIS local clName2 = "Brazil_Cells_PG" - local user = "postgres" local password = getConfig().password local database = "postgis_22_sample" @@ -88,7 +83,6 @@ return{ input = layerName1, name = clName2, resolution = 100e3, - user = user, password = password, database = database, clean = true @@ -108,8 +102,6 @@ return{ File(filePath1):deleteIfExists() pgLayer:delete() - - customWarning = customWarningBkp end, distance = function(unitTest) local projName = "cell_area.tview" @@ -126,17 +118,13 @@ return{ title = title } - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - local layerName1 = "Brazil" gis.Layer{ project = proj, name = layerName1, - file = filePath("brazilstates.shp", "base") + file = filePath("brazilstates.shp", "base"), + epsg = 4326 } -- SHAPE @@ -170,7 +158,6 @@ return{ -- POSTGIS local clName2 = "Brazil_Cells_PG" - local user = "postgres" local password = "postgres" local database = "postgis_22_sample" @@ -180,7 +167,6 @@ return{ input = layerName1, name = clName2, resolution = 100e3, - user = user, password = password, database = database, clean = true @@ -204,7 +190,5 @@ return{ File(filePath1):deleteIfExists() pgLayer:delete() - - customWarning = customWarningBkp end } diff --git a/packages/base/tests/database/basics/CellularSpace.lua b/packages/base/tests/database/basics/CellularSpace.lua index a8b2a906..e4993ce1 100644 --- a/packages/base/tests/database/basics/CellularSpace.lua +++ b/packages/base/tests/database/basics/CellularSpace.lua @@ -231,7 +231,24 @@ return{ cs = CellularSpace{ file = filePath("simple.pgm", "base") } + unitTest:assertEquals(#cs, 100) + + local pgmFile = filePath("test/error/pgm-invalid-max.pgm", "base") + local pgmWarn = function() + cs = CellularSpace{ + file = pgmFile + } + end + unitTest:assertWarning(pgmWarn, "File '"..pgmFile.."' does not have a maximum value declared.") + unitTest:assertEquals(#cs, 100) + pgmFile = filePath("test/error/pgm-invalid-size.pgm", "base") + local pgmWarn2 = function() + cs = CellularSpace{ + file = pgmFile + } + end + unitTest:assertWarning(pgmWarn2, "Data from file '"..pgmFile.."' does not match declared size: expected '(2, 2)', got '(10, 10)'.") unitTest:assertEquals(#cs, 100) -- csv file @@ -472,10 +489,14 @@ return{ -- .GAL Regular CS countTest = countTest + 1 - cs1:loadNeighborhood{ - file = filePath("test/cabecadeboi-neigh.gal", "base"), - name = "my_neighborhood"..countTest - } + local unnecessaryArgument = function() + cs1:loadNeighborhood{ + file = filePath("test/cabecadeboi-neigh.gal", "base"), + name = "my_neighborhood"..countTest, + che = false + } + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("che")) sizes = {} diff --git a/packages/base/tests/functional/alternative/Agent.lua b/packages/base/tests/functional/alternative/Agent.lua index d1e75e6c..ab05f794 100644 --- a/packages/base/tests/functional/alternative/Agent.lua +++ b/packages/base/tests/functional/alternative/Agent.lua @@ -82,12 +82,6 @@ return { ag:die() - local warning_function = function() - ag:execute() - end - - unitTest:assertWarning(warning_function, "Trying to execute a dead agent.") - local ag2 = Agent{} local test_function = function() @@ -217,19 +211,11 @@ return { local e = Environment{predators, cs} e:createPlacement() - local c = cs:sample() - - local warning_func = function() - predators:sample():enter(c) - end - - unitTest:assertWarning(warning_func, "Agent is already inside of a Cell. Use Agent:move() instead.") - local ag = predators:sample() ag:leave() - c = Cell{} + local c = Cell{} error_func = function() ag:enter(c) diff --git a/packages/base/tests/functional/alternative/CellularSpace.lua b/packages/base/tests/functional/alternative/CellularSpace.lua index d56b4397..6bae000c 100644 --- a/packages/base/tests/functional/alternative/CellularSpace.lua +++ b/packages/base/tests/functional/alternative/CellularSpace.lua @@ -104,17 +104,6 @@ return{ unitTest:assertError(error_func, "The same instance cannot be used in two CellularSpaces.") - c1 = Cell{getNeighborhood = function() end} - - local warning_func = function() - CellularSpace{ - xdim = 10, - instance = c1 - } - end - - unitTest:assertWarning(warning_func, "Function 'getNeighborhood()' from Cell is replaced in the instance.") - error_func = function() CellularSpace{ xdim = 10, @@ -124,79 +113,6 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg("instance", "Cell", 2)) - c1 = Cell{ - status = "forest" - } - - warning_func = function() - CellularSpace{ - xdim = 10, - instance = c1, - status = 5 - } - end - - unitTest:assertWarning(warning_func, "Attribute 'status' will not be replaced by a summary function.") - - c1 = Cell{ - alive = true - } - - - warning_func = function() - CellularSpace{ - xdim = 10, - instance = c1, - alive = 5 - } - end - - unitTest:assertWarning(warning_func, "Attribute 'alive' will not be replaced by a summary function.") - - c1 = Cell{ - value = 4 - } - - warning_func = function() - CellularSpace{ - xdim = 10, - instance = c1, - value = 5 - } - end - - unitTest:assertWarning(warning_func, "Attribute 'value' will not be replaced by a summary function.") - - c1 = Cell{ - set = function() end - } - - warning_func = function() - CellularSpace{ - xdim = 10, - instance = c1, - set = 5 - } - end - - unitTest:assertWarning(warning_func, "Attribute 'set' will not be replaced by a summary function.") - - c1 = Cell{ - init = function(self) - self.status = "forest" - end - } - - warning_func = function() - CellularSpace{ - xdim = 10, - instance = c1, - status = 5 - } - end - - unitTest:assertWarning(warning_func, "Attribute 'status' will not be replaced by a summary function.") - local cell = Cell{ water = 2, exec = function() end @@ -267,15 +183,6 @@ return{ unitTest:assertError(layerDoesNotExists, "Layer '"..layerName.."' does not exist in Project '"..File(projFile).."'.") - local geometryDefaultValue = function() - CellularSpace { - file = filePath("cabecadeboi.shp"), - geometry = false - } - end - - unitTest:assertWarning(geometryDefaultValue, defaultValueMsg("geometry", false)) - local geometryNotBoolean = function() CellularSpace { project = proj, @@ -539,19 +446,6 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg("weight", "function", true)) - local warning_func = function() - cs:createNeighborhood{ - strategy = "mxn", - name = "my_neighborhood_w", - m = 5, - n = 5, - filter = function() end, - weight = function() end - } - end - - unitTest:assertWarning(warning_func, defaultValueMsg("n", 5)) - error_func = function() cs:createNeighborhood{ strategy = "mxn", @@ -565,27 +459,6 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg("target", "CellularSpace", "teste")) - warning_func = function() - cs:createNeighborhood{ - strategy = "mxn", - name = "my_neighborhood_x", - m = 4 - } - end - - unitTest:assertWarning(warning_func, "Argument 'm' is even. It will be increased by one to keep the Cell in the center of the Neighborhood.") - - warning_func = function() - cs:createNeighborhood{ - strategy = "mxn", - name = "my_neighborhood_z", - m = 5, - n = 4 - } - end - - unitTest:assertWarning(warning_func, "Argument 'n' is even. It will be increased by one to keep the Cell in the center of the Neighborhood.") - error_func = function() cs:createNeighborhood{ strategy = "mxn", @@ -688,6 +561,28 @@ return{ unitTest:assertError(error_func, integerArgumentMsg("n", 1.3)) + error_func = function() + cs:createNeighborhood{ + strategy = "mxn", + name = "my_neighborhood", + target = cs2, + m = 4 + } + end + + unitTest:assertError(error_func, "Value or argument 'm' should be even, got 4.") + + error_func = function() + cs:createNeighborhood{ + strategy = "mxn", + name = "my_neighborhood", + target = cs2, + n = 2 + } + end + + unitTest:assertError(error_func, "Value or argument 'n' should be even, got 2.") + error_func = function() cs:createNeighborhood{ strategy = "function" @@ -745,12 +640,6 @@ return{ end unitTest:assertError(error_func, "Neighborhood 'abc' already exists.") - - warning_func = function() - cs:createNeighborhood{namen = "abc"} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("namen", "name")) end, cut = function(unitTest) local cs = CellularSpace{xdim = 10} @@ -767,12 +656,6 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg("xmin", "number", false)) - local warning_func = function() - cs:cut{xmin = 0} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("xmin", 0)) - error_func = function() cs:cut{xmax = false} end @@ -790,12 +673,6 @@ return{ end unitTest:assertError(error_func, incompatibleTypeMsg("ymax", "number", false)) - - warning_func = function() - cs:cut{xmox = 5} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("xmox", "xmax")) end, get = function(unitTest) local cs = CellularSpace{xdim = 10} @@ -823,12 +700,6 @@ return{ end unitTest:assertError(error_func, integerArgumentMsg(2, 2.3)) - - local warning_func = function() - cs:get("4", 2.3) - end - - unitTest:assertWarning(warning_func, "As #1 is string, #2 should be nil, but got number.") end, notify = function(unitTest) local cs = CellularSpace{xdim = 10} diff --git a/packages/base/tests/functional/alternative/Choice.lua b/packages/base/tests/functional/alternative/Choice.lua index 1290c7aa..5481ae9c 100644 --- a/packages/base/tests/functional/alternative/Choice.lua +++ b/packages/base/tests/functional/alternative/Choice.lua @@ -36,38 +36,18 @@ return{ unitTest:assertError(error_func, "There are no options for the Choice (table is empty).") - local ch - local warning_func = function() - ch = Choice{1} - end - - unitTest:assertWarning(warning_func, "Choice has only one available value.") - unitTest:assertType(ch, "Choice") - error_func = function() Choice{1, 2, "3"} end unitTest:assertError(error_func, "All the elements of Choice should have the same type.") - warning_func = function() - Choice{1, 2, 3, default = 1} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("default", 1)) - error_func = function() Choice{1, 2, 3, default = 4} end unitTest:assertError(error_func, "The default value (4) does not belong to Choice.") - warning_func = function() - Choice{1, 2, 3, max = 4} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("max")) - error_func = function() Choice{false, true} end @@ -110,24 +90,12 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg("step", "number", false)) - warning_func = function() - Choice{min = 2, max = 4, w = false} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("w")) - error_func = function() Choice{10, 20, "30"} end unitTest:assertError(error_func, "All the elements of Choice should have the same type.") - warning_func = function() - Choice{min = 1, max = 10, step = 1, default = 1} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("default", 1)) - error_func = function() Choice{min = 1, max = 10, step = 1, default = "a"} end @@ -158,12 +126,6 @@ return{ unitTest:assertError(error_func, "Argument 'max' should be greater than 'min'.") - warning_func = function() - Choice{min = 1, max = 10, step = 1, default = 1} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("default", 1)) - error_func = function() Choice{min = 1, max = 10, step = 4} end diff --git a/packages/base/tests/functional/alternative/Directory.lua b/packages/base/tests/functional/alternative/Directory.lua index 9f8be8ea..7c86c696 100644 --- a/packages/base/tests/functional/alternative/Directory.lua +++ b/packages/base/tests/functional/alternative/Directory.lua @@ -54,21 +54,6 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg("name", "string", 1)) - local warning_func = function() - Directory{ - name = ".tmp_XXXXX", - tmpd = true - } - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("tmpd", "tmp")) - - warning_func = function() - Directory{name = "abc", tmpd = true} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("tmpd", "tmp")) - error_func = function() Directory(packageInfo("base").path.."data/agents.csv") end diff --git a/packages/base/tests/functional/alternative/Environment.lua b/packages/base/tests/functional/alternative/Environment.lua index 3688d8a8..4c391a6d 100644 --- a/packages/base/tests/functional/alternative/Environment.lua +++ b/packages/base/tests/functional/alternative/Environment.lua @@ -93,12 +93,6 @@ return{ end unitTest:assertError(error_func, "The Environment has an Automaton but not a CellularSpace.") - - local warning_func = function() - Environment{2} - end - - unitTest:assertWarning(warning_func, "Argument '1' (a 'number') is unnecessary for the Environment.") end, add = function(unitTest) local env = Environment{} diff --git a/packages/base/tests/functional/alternative/ErrorHandling.lua b/packages/base/tests/functional/alternative/ErrorHandling.lua index 9d7033ca..f69dcc03 100644 --- a/packages/base/tests/functional/alternative/ErrorHandling.lua +++ b/packages/base/tests/functional/alternative/ErrorHandling.lua @@ -46,13 +46,6 @@ return{ end unitTest:assertError(error_func, incompatibleTypeMsg("x", "boolean", 5)) - - local warning_func = function() - defaultTableValue(t, "x", 5) - end - - unitTest:assertWarning(warning_func, defaultValueMsg("x", 5)) - unitTest:assertEquals(t.x, 5) end, defaultValueWarning = function(unitTest) local error_func = function() diff --git a/packages/base/tests/functional/alternative/Event.lua b/packages/base/tests/functional/alternative/Event.lua index 55f3f95f..afdf1366 100644 --- a/packages/base/tests/functional/alternative/Event.lua +++ b/packages/base/tests/functional/alternative/Event.lua @@ -74,12 +74,6 @@ return{ unitTest:assertError(error_func, switchInvalidArgumentMsg("aaa", "priority", options)) - local warning_func = function() - Event{start = 0.5, period = 2, priority = "medium", action = function() end} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("priority", 0)) - error_func = function() event = Event{period = 0, priority = 1, action = function() end} end @@ -92,30 +86,6 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg("action", "one of the TerraME types or a function", -5.5)) - warning_func = function() - Event{action = function() end, myperiod = function() end} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("myperiod", "period")) - - warning_func = function() - Event{period = 1, priority = 1, action = function() end} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("period", 1)) - - warning_func = function() - Event{start = 1, priority = 1, action = function() end} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("start", 1)) - - warning_func = function() - Event{priority = 0, action = function() end} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("priority", 0)) - local t = Timer{ Event{action = function() customError("aaa") @@ -161,51 +131,14 @@ return{ unitTest:assertError(error_func, "Incompatible types. Attribute 'execute' from CellularSpace should be a function, got number.") - local cell = Cell{execute = function() end} - - warning_func = function() - Event{action = cell, priority = "high"} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("priority", -5)) - - warning_func = function() - Event{action = cell, priority = "high"} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("priority", -5)) - - local agent = Agent{} - - warning_func = function() - Event{action = agent, priority = "medium"} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("priority", 0)) - - soc = Society{instance = Agent{}, quantity = 2} - - warning_func = function() - Event{action = soc, priority = "medium"} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("priority", 0)) - + -- TODO(#1905) local group = Group{target = soc} - warning_func = function() + local warning_func = function() Event{action = group, priority = "medium"} end unitTest:assertWarning(warning_func, defaultValueMsg("priority", 0)) - - local traj = Trajectory{target = cs} - - warning_func = function() - Event{action = traj, priority = "medium"} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("priority", 0)) end, config = function(unitTest) local event = Event{action = function() end} @@ -216,12 +149,6 @@ return{ unitTest:assertError(error_func, tableArgumentMsg()) - local warning_func = function() - event:config{perod = false} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("perod", "period")) - error_func = function() event:config{period = false} end diff --git a/packages/base/tests/functional/alternative/File.lua b/packages/base/tests/functional/alternative/File.lua index 4ed24108..16d06384 100644 --- a/packages/base/tests/functional/alternative/File.lua +++ b/packages/base/tests/functional/alternative/File.lua @@ -71,14 +71,7 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg(1, "string", 1)) end, close = function(unitTest) - local file = File("abc.txt") - local warning_func = function() - file:close() - end - - unitTest:assertWarning(warning_func, "File is not opened.") - - file = File("123") + local file = File("123") file.file = true local error_func = function() @@ -181,15 +174,6 @@ return{ end unitTest:assertError(error_func, resourceNotFoundMsg("file", file.filename)) - - local s = sessionInfo().separator - file = filePath("test/error"..s.."csv-error.csv") - - local warning_func = function() - file:read() - end - - unitTest:assertWarning(warning_func, "Line 3 ('\"mary\",18,100,3,1') should contain 6 attributes but has 5.") end, touch = function(unitTest) local file = File("abc.txt") diff --git a/packages/base/tests/functional/alternative/Group.lua b/packages/base/tests/functional/alternative/Group.lua index fe1f5492..9e1459c4 100644 --- a/packages/base/tests/functional/alternative/Group.lua +++ b/packages/base/tests/functional/alternative/Group.lua @@ -50,15 +50,6 @@ return{ unitTest:assertError(error_func, namedArgumentsMsg()) - local warning_func = function() - Group{ - target = sc1, - selection = function() return true end - } - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("selection", "select")) - error_func = function() group1 = Group{ target = cs, @@ -82,24 +73,6 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg("build", "boolean", 15)) - warning_func = function() - Group{ - target = sc1, - build = true - } - end - - unitTest:assertWarning(warning_func, defaultValueMsg("build", true)) - - warning_func = function() - Group{ - target = sc1, - random = false - } - end - - unitTest:assertWarning(warning_func, defaultValueMsg("random", false)) - error_func = function() group1 = Group{ target = sc1, @@ -170,12 +143,6 @@ return{ end unitTest:assertError(error_func, incompatibleTypeMsg(1, "function", "notFunction")) - - local warning_func = function() - group:sort() - end - - unitTest:assertWarning(warning_func, "Cannot sort the Group because there is no previous function.") end } diff --git a/packages/base/tests/functional/alternative/Model.lua b/packages/base/tests/functional/alternative/Model.lua index caba268c..bb0e7f48 100644 --- a/packages/base/tests/functional/alternative/Model.lua +++ b/packages/base/tests/functional/alternative/Model.lua @@ -72,6 +72,7 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg("random", "boolean", 2)) + -- TODO(#1908): remove this test after fix it local warning_func = function() Model{random = false, init = function() end} end @@ -249,18 +250,6 @@ return{ unitTest:assertError(error_func, incompatibleValueMsg("block.level", "one of {1, 2, 3}", 40)) - warning_func = function() - Tube{block = {mblock = 40}} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("block.mblock")) - - warning_func = function() - Tube{s = 3} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("s")) - error_func = function() Tube{checkZero = 3} end @@ -273,6 +262,7 @@ return{ unitTest:assertError(error_func, "Initial water should be greater than zero.") + -- TODO(#1908): remove this test after fix it warning_func = function() Tube{block = {xmix = 5}} end @@ -573,6 +563,7 @@ return{ unitTest:assertError(error_func, "Argument 'number' cannot be displayed twice in the interface().") + -- TODO(#1907) local warning_func = function() Model{ simulationSteps = 10, diff --git a/packages/base/tests/functional/alternative/Neighborhood.lua b/packages/base/tests/functional/alternative/Neighborhood.lua index be5822db..19c94474 100644 --- a/packages/base/tests/functional/alternative/Neighborhood.lua +++ b/packages/base/tests/functional/alternative/Neighborhood.lua @@ -46,6 +46,7 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg(2, "number", "not_number")) + -- TODO(#1909): remove this test after fix it local warning_func = function() neigh:add(cell2) neigh:add(cell2) @@ -91,7 +92,6 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg(1, "Cell", 123)) end, remove = function(unitTest) - local cell1 = Cell{} local neigh = Neighborhood() local error_func = function() @@ -111,12 +111,6 @@ return{ end unitTest:assertError(error_func, incompatibleTypeMsg(1, "Cell", 123)) - - local warning_func = function() - neigh:remove(cell1) - end - - unitTest:assertWarning(warning_func, "Trying to remove a Cell that does not belong to the Neighborhood.") end, sample = function(unitTest) local neigh = Neighborhood() diff --git a/packages/base/tests/functional/alternative/Package.lua b/packages/base/tests/functional/alternative/Package.lua index d4d34e17..1f8657b0 100644 --- a/packages/base/tests/functional/alternative/Package.lua +++ b/packages/base/tests/functional/alternative/Package.lua @@ -99,12 +99,6 @@ return{ end unitTest:assertError(error_func, "Package 'asdfgh' is not installed.") - - local warning_func = function() - import("base") - end - - unitTest:assertWarning(warning_func, "Package 'base' is already loaded.") end, isLoaded = function(unitTest) local error_func = function() diff --git a/packages/base/tests/functional/alternative/Random.lua b/packages/base/tests/functional/alternative/Random.lua index 1fbc16e5..1931708c 100644 --- a/packages/base/tests/functional/alternative/Random.lua +++ b/packages/base/tests/functional/alternative/Random.lua @@ -48,18 +48,6 @@ return{ unitTest:assertError(error_func, "Argument 'max' should be greater than 'min'.") - local warning_func = function() - Random{min = 2, max = 5, w = 2} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("w")) - - warning_func = function() - Random{p = 0.3, w = 2} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("w")) - error_func = function() Random{1, 2, 4, 5, 6, w = 2} end @@ -107,30 +95,6 @@ return{ end unitTest:assertError(error_func, "Sum should be one, got 0.9.") - - warning_func = function() - Random{mean = 1, sd = 0.5} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("mean", 1)) - - warning_func = function() - Random{mean = 0.5, sd = 1} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("sd", 1)) - - warning_func = function() - Random{mean = 0.5, sd = 0.5, abc = 2} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("abc")) - - warning_func = function() - Random{lambda = 1} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("lambda", 1)) end, integer = function(unitTest) local randomObj = Random{} diff --git a/packages/base/tests/functional/alternative/SocialNetwork.lua b/packages/base/tests/functional/alternative/SocialNetwork.lua index 2dc9cbc2..ce6c2c8e 100644 --- a/packages/base/tests/functional/alternative/SocialNetwork.lua +++ b/packages/base/tests/functional/alternative/SocialNetwork.lua @@ -26,7 +26,6 @@ return{ add = function(unitTest) local sn = SocialNetwork() local ag1 = Agent{} - local ag2 = Agent{id = "2"} local error_func = function() sn:add() @@ -51,13 +50,6 @@ return{ end unitTest:assertError(error_func, "Agent should have an id in order to be added to a SocialNetwork.") - - local warning_func = function() - sn:add(ag2) - sn:add(ag2) - end - - unitTest:assertWarning(warning_func, "Agent '2' already belongs to the SocialNetwork.") end, getWeight = function(unitTest) local ag1 = Agent{id = "1"} @@ -105,7 +97,6 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg(1, "Agent", 123)) end, remove = function(unitTest) - local ag1 = Agent{id = "1"} local sn = SocialNetwork() local error_func = function() @@ -119,12 +110,6 @@ return{ end unitTest:assertError(error_func, incompatibleTypeMsg(1, "Agent", 123)) - - local warning_func = function() - sn:remove(ag1) - end - - unitTest:assertWarning(warning_func, "Trying to remove an Agent that does not belong to the SocialNetwork.") end, sample = function(unitTest) local sn = SocialNetwork() diff --git a/packages/base/tests/functional/alternative/Society.lua b/packages/base/tests/functional/alternative/Society.lua index 0a9f4b55..2acd269f 100644 --- a/packages/base/tests/functional/alternative/Society.lua +++ b/packages/base/tests/functional/alternative/Society.lua @@ -92,17 +92,6 @@ return{ unitTest:assertError(error_func, "Argument 'instance' should not have attribute 'parent'.") - ag1 = Agent{instance = 2} - - local warning_func = function() - Society{ - instance = ag1, - quantity = 20 - } - end - - unitTest:assertWarning(warning_func, "Attribute 'instance' belongs to both Society and Agent.") - ag1 = Agent{} Society{ @@ -119,81 +108,6 @@ return{ unitTest:assertError(error_func, "The same instance cannot be used by two Societies.") - ag1 = Agent{enter = function() end} - - warning_func = function() - Society{ - instance = ag1, - quantity = 20 - } - end - - unitTest:assertWarning(warning_func, "Function 'enter()' from Agent is replaced in the instance.") - - ag1 = Agent{status = "alive"} - - warning_func = function() - Society{ - instance = ag1, - quantity = 20, - status = 5 - } - end - - unitTest:assertWarning(warning_func, "Attribute 'status' will not be replaced by a summary function.") - - ag1 = Agent{male = true} - - warning_func = function() - Society{ - instance = ag1, - quantity = 20, - male = 4 - } - end - - unitTest:assertWarning(warning_func, "Attribute 'male' will not be replaced by a summary function.") - - ag1 = Agent{value = 4} - - warning_func = function() - Society{ - instance = ag1, - quantity = 20, - value = 5 - } - end - - unitTest:assertWarning(warning_func, "Attribute 'value' will not be replaced by a summary function.") - - ag1 = Agent{set = function() end} - - warning_func = function() - Society{ - instance = ag1, - quantity = 20, - set = 5 - } - end - - unitTest:assertWarning(warning_func, "Attribute 'set' will not be replaced by a summary function.") - - ag1 = Agent{ - init = function(self) - self.male = true - end - } - - warning_func = function() - Society{ - instance = ag1, - quantity = 20, - male = 5 - } - end - - unitTest:assertWarning(warning_func, "Attribute 'male' will not be replaced by a summary function.") - local ag = Agent{ water = 2, exec = function() end @@ -297,16 +211,6 @@ return{ unitTest:assertError(error_func, "SocialNetwork 'void' already exists in the Society.") - local warning_func = function() - sc1:createSocialNetwork{ - strategy = "void", - name = "void2", - probability = 0.5 - } - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("probability")) - error_func = function() sc1:createSocialNetwork{ strategy = "void", @@ -344,7 +248,8 @@ return{ unitTest:assertError(error_func, integerArgumentMsg("quantity", 2.2)) - warning_func = function() + -- TODO(#1910) + local warning_func = function() sc1:createSocialNetwork{ strategy = "quantity", quantity = 5, @@ -355,6 +260,7 @@ return{ unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("probability")) + -- TODO(#1910) warning_func = function() sc1:createSocialNetwork{ strategy = "quantity", @@ -402,6 +308,7 @@ return{ unitTest:assertError(error_func, incompatibleValueMsg("probability", "a number between 0 and 1", 0)) + -- TODO(#1910) warning_func = function() sc1:createSocialNetwork{ strategy = "probability", @@ -470,7 +377,6 @@ return{ sc1 = Society{instance = ag1, quantity = 20} cs = CellularSpace{xdim = 5} cs:createNeighborhood() - env = Environment{cs, sc1} error_func = function() sc1:createSocialNetwork{strategy = "neighbor", name = "c"} @@ -478,31 +384,19 @@ return{ unitTest:assertError(error_func, "Society has no placement. Please call Environment:createPlacement() first.") - env:createPlacement() - warning_func = function() - sc1:createSocialNetwork{strategy = "cell", quantity = 5, name = "5"} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("quantity")) - error_func = function() sc1:createSocialNetwork{strategy = "neighbor", name = 22} end unitTest:assertError(error_func, incompatibleTypeMsg("name", "string", 22)) - warning_func = function() - sc1:createSocialNetwork{strategy = "neighbor", quantity = 1, name = "6"} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("quantity")) - error_func = function() sc1:createSocialNetwork{strategy = "function", name = "c", filter = 3} end unitTest:assertError(error_func, incompatibleTypeMsg("filter", "function", 3)) + -- TODO(#1910) warning_func = function() sc1:createSocialNetwork{strategy = "function", name = "c", filter = function() return true end, quantity = 1} end @@ -537,12 +431,6 @@ return{ unitTest:assertError(error_func, "Argument 'inmemory' does not work with strategy 'erdos'.") - warning_func = function() - sc1:createSocialNetwork{strategy = "erdos", quantity = 5, abc = true, name = "8"} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("abc")) - error_func = function() sc1:createSocialNetwork{strategy = "barabasi", start = 3, quantity = "abc"} end @@ -585,12 +473,6 @@ return{ unitTest:assertError(error_func, "Argument 'inmemory' does not work with strategy 'barabasi'.") - warning_func = function() - sc1:createSocialNetwork{strategy = "barabasi", quantity = 5, start = 8, abc = true, name = "9"} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("abc")) - error_func = function() sc1:createSocialNetwork{strategy = "barabasi", quantity = 5, start = 21} end @@ -638,12 +520,6 @@ return{ end unitTest:assertError(error_func, "Argument 'inmemory' does not work with strategy 'watts'.") - - warning_func = function() - sc1:createSocialNetwork{strategy = "watts", quantity = 5, probability = 0.8, abc = true} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("abc")) end, get = function(unitTest) local ag1 = Agent{ diff --git a/packages/base/tests/functional/alternative/Timer.lua b/packages/base/tests/functional/alternative/Timer.lua index aec86809..63312f46 100644 --- a/packages/base/tests/functional/alternative/Timer.lua +++ b/packages/base/tests/functional/alternative/Timer.lua @@ -62,14 +62,6 @@ return { end unitTest:assertError(error_func, incompatibleTypeMsg(1, "Event", "ev")) - - timer:run(10) - - local warning_func = function() - timer:add(Event{period = 2, action = function() end}) - end - - unitTest:assertWarning(warning_func, "Adding an Event with time (1) before the current simulation time (10).") end, addReplacement = function(unitTest) local timer = Timer{} @@ -193,13 +185,6 @@ return { Event{period = 2, action = function() end} } - - timer:run(10) - local warning_func = function() - timer:run(2) - end - - unitTest:assertWarning(warning_func, "Simulating until a time (2) before the current simulation time (10).") end } diff --git a/packages/base/tests/functional/alternative/Trajectory.lua b/packages/base/tests/functional/alternative/Trajectory.lua index 89e4dc5a..974ae9e0 100644 --- a/packages/base/tests/functional/alternative/Trajectory.lua +++ b/packages/base/tests/functional/alternative/Trajectory.lua @@ -36,17 +36,6 @@ return{ end unitTest:assertError(error_func, namedArgumentsMsg()) - local traj - local warning_func = function() - traj = Trajectory{ - target = cs, - selection = function() return true end - } - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("selection", "select")) - unitTest:assertEquals(#traj, #cs) - error_func = function() trajectory = Trajectory{} end @@ -71,26 +60,6 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg("build", "boolean", "build")) - warning_func = function() - traj = Trajectory{ - target = cs, - build = true - } - end - - unitTest:assertWarning(warning_func, defaultValueMsg("build", true)) - unitTest:assertEquals(#traj, #cs) - - warning_func = function() - traj = Trajectory{ - target = cs, - random = false - } - end - - unitTest:assertWarning(warning_func, defaultValueMsg("random", false)) - unitTest:assertEquals(#traj, #cs) - error_func = function() Trajectory{ target = cs, @@ -180,12 +149,6 @@ return{ end unitTest:assertError(error_func, incompatibleTypeMsg(1, "function", "func")) - - error_func = function() - trajectory:sort() - end - - unitTest:assertWarning(error_func, "Cannot sort the Trajectory because there is no previous function.") end } diff --git a/packages/base/tests/functional/alternative/Utils.lua b/packages/base/tests/functional/alternative/Utils.lua index aa789708..83c591f4 100644 --- a/packages/base/tests/functional/alternative/Utils.lua +++ b/packages/base/tests/functional/alternative/Utils.lua @@ -448,12 +448,6 @@ return{ unitTest:assertError(error_func, positiveArgumentMsg("step", -0.5)) - local warning_func = function() - integrate{step = 0.1, method = "euler", equation = function() end, initial = 0} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("method", "euler")) - error_func = function() integrate{step = 0.1, method = "eler", equation = function() end, initial = 0} end @@ -490,12 +484,6 @@ return{ unitTest:assertError(error_func, "Tables equation and initial shoud have the same size.") - warning_func = function() - integrate{equation = function() end, initial = 1, step = 5, metod = 3} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("metod", "method")) - local event = Event{start = 0.5, period = 2, priority = 1, action = function() end} error_func = function() diff --git a/packages/base/tests/functional/basics/Agent.lua b/packages/base/tests/functional/basics/Agent.lua index d8d7f400..5bb60fd7 100644 --- a/packages/base/tests/functional/basics/Agent.lua +++ b/packages/base/tests/functional/basics/Agent.lua @@ -160,10 +160,10 @@ state_ State unitTest:assertType(dead, "") unitTest:assertEquals(4, #predators) - local test_function = function() - print(dead.a) + local warning_function = function() + dead:execute() end - unitTest:assertError(test_function, "Trying to use a function or an attribute of a dead Agent.") + unitTest:assertWarning(warning_function, "Trying to execute a dead agent.") end, emptyNeighbor = function(unitTest) local ag = Agent{} @@ -680,6 +680,26 @@ state_ State for _ = 1, 20 do unitTest:assert(soc:sample():walkToEmpty()) end - end + end, + enter = function(unitTest) + local predator = Agent{} + + local predators = Society{ + instance = predator, + quantity = 5 + } + + local cs = CellularSpace{xdim = 5} + + local e = Environment{predators, cs} + e:createPlacement() + + local c = cs:sample() + + local warning_func = function() + predators:sample():enter(c) + end + unitTest:assertWarning(warning_func, "Agent is already inside of a Cell. Use Agent:move() instead.") + end, } diff --git a/packages/base/tests/functional/basics/CellularSpace.lua b/packages/base/tests/functional/basics/CellularSpace.lua index 0b285880..923aba29 100644 --- a/packages/base/tests/functional/basics/CellularSpace.lua +++ b/packages/base/tests/functional/basics/CellularSpace.lua @@ -39,14 +39,18 @@ return{ road = true, cover = "pasture", deforest = function(self) self.defor = self.defor + 1 end, - water = Random{1, 2, 3} - } - - cs = CellularSpace{ - instance = cell, - xdim = 10 + water = Random{1, 2, 3}, + set = function() end } + local replaceWarn = function() + cs = CellularSpace{ + instance = cell, + xdim = 10, + set = 5 + } + end + unitTest:assertWarning(replaceWarn, "Attribute 'set' will not be replaced by a summary function.") unitTest:assertEquals(cs:defor(), 100) unitTest:assertEquals(cs:road(), 100) unitTest:assertEquals(cs:cover().pasture, 100) @@ -63,18 +67,113 @@ return{ end self.defor = self.defor + 1 - end + end, + init = function(self) + self.status = "forest" + end, + value = 4 } - cs = CellularSpace{ - instance = cell, - xdim = 10 + replaceWarn = function() + cs = CellularSpace{ + instance = cell, + xdim = 10, + status = 5 + } + end + unitTest:assertWarning(replaceWarn, "Attribute 'status' will not be replaced by a summary function.") + unitTest:assertEquals(cs:defor(), 100) + unitTest:assert(not cs:deforest()) + unitTest:assertEquals(cs:defor(), 150) + + + cell = Cell{ + defor = 1, + deforest = function(self) + if self.x > 4 then + return false + end + + self.defor = self.defor + 1 + end, + value = 4 + } + + replaceWarn = function() + cs = CellularSpace{ + instance = cell, + xdim = 10, + value = 5 + } + end + unitTest:assertWarning(replaceWarn, "Attribute 'value' will not be replaced by a summary function.") + unitTest:assertEquals(cs:defor(), 100) + unitTest:assert(not cs:deforest()) + unitTest:assertEquals(cs:defor(), 150) + + cell = Cell{ + defor = 1, + deforest = function(self) + if self.x > 4 then + return false + end + + self.defor = self.defor + 1 + end, + alive = true + } + + replaceWarn = function() + cs = CellularSpace{ + instance = cell, + xdim = 10, + alive = 5 + } + end + unitTest:assertWarning(replaceWarn, "Attribute 'alive' will not be replaced by a summary function.") + unitTest:assertEquals(cs:defor(), 100) + unitTest:assert(not cs:deforest()) + unitTest:assertEquals(cs:defor(), 150) + + cell = Cell{ + defor = 1, + deforest = function(self) + if self.x > 4 then + return false + end + + self.defor = self.defor + 1 + end, + status = "forest" } + replaceWarn = function() + cs = CellularSpace{ + instance = cell, + xdim = 10, + status = 5 + } + end + unitTest:assertWarning(replaceWarn, "Attribute 'status' will not be replaced by a summary function.") unitTest:assertEquals(cs:defor(), 100) unitTest:assert(not cs:deforest()) unitTest:assertEquals(cs:defor(), 150) + cell = Cell{ + getNeighborhood = function() + return "neighbor" + end + } + + replaceWarn = function() + cs = CellularSpace{ + instance = cell, + xdim = 10 + } + end + unitTest:assertWarning(replaceWarn, "Function 'getNeighborhood()' from Cell is replaced in the instance.") + unitTest:assertEquals(cs:sample():getNeighborhood(), "neighbor") + -- Shapefile local projName = "cellspace.tview" local author = "Avancini" @@ -89,17 +188,12 @@ return{ title = title } - local customWarningBkp = customWarning - customWarning = function(msg) - return msg - end - local layerName1 = "Sampa" gis.Layer{ project = proj, name = layerName1, - file = filePath("test/sampa.shp", "gis") + file = filePath("test/sampa.shp", "gis"), } local testDir = currentDir() @@ -120,10 +214,14 @@ return{ file = filePath1 } - cs = CellularSpace{ - project = projName, - layer = clName1 - } + local geometryDefaultValue = function() + cs = CellularSpace{ + project = projName, + layer = clName1, + geometry = false + } + end + unitTest:assertWarning(geometryDefaultValue, defaultValueMsg("geometry", false)) unitTest:assertEquals(File(projName), cs.project.file) unitTest:assertType(cs.layer, "Layer") @@ -391,8 +489,6 @@ return{ unitTest:assertEquals(#cs.cells, 9964) -- SKIP File(projName):deleteIfExists() end - - customWarning = customWarningBkp end, __len = function(unitTest) local cs = CellularSpace{xdim = 10} @@ -432,7 +528,10 @@ ydim number [20] local icell = Cell{} local cs = CellularSpace{xdim = 5, instance = icell} - cs:createNeighborhood() + local unnecessaryArgument = function() + cs:createNeighborhood{namen = "abc"} + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("namen", "name")) -- Vector of size counters - Used to verify the size of the neighborhoods local sizes = {} @@ -1089,14 +1188,18 @@ ydim number [20] end end - cs:createNeighborhood{ - strategy = "mxn", - name = "my_neighborhood6", - target = cs2, - m = 5, - filter = filterFunction, - weight = weightFunction - } + local defaultValue = function() + cs:createNeighborhood{ + strategy = "mxn", + name = "my_neighborhood6", + target = cs2, + m = 5, + n = 5, + filter = filterFunction, + weight = weightFunction + } + end + unitTest:assertWarning(defaultValue, defaultValueMsg("n", 5)) sizes = {} @@ -1369,8 +1472,17 @@ ydim number [20] region = cs:cut{xmin = 5} unitTest:assertEquals(#region, 50) - region = cs:cut{xmin = 1, xmax = 5, ymin = 3, ymax = 7} + local unnecessaryArgument = function() + region = cs:cut{xmin = 1, xmax = 5, ymin = 3, ymax = 7, xmox = 5} + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("xmox", "xmax")) unitTest:assertEquals(#region, 25) + + local defaultValue = function() + region = cs:cut{xmin = 0} + end + unitTest:assertWarning(defaultValue, defaultValueMsg("xmin", 0)) + unitTest:assertEquals(#region, #cs) end, get = function(unitTest) local cs = CellularSpace{xdim = 10} @@ -1385,6 +1497,13 @@ ydim number [20] c = cs:get(100, 100) unitTest:assertNil(c) + + local warningFunc = function() + c = cs:get("4", 2.3) + end + unitTest:assertWarning(warningFunc, "As #1 is string, #2 should be nil, but got number.") + unitTest:assertEquals(c.x, 0) + unitTest:assertEquals(c.y, 3) end, load = function(unitTest) local cs = CellularSpace{xdim = 5} diff --git a/packages/base/tests/functional/basics/Choice.lua b/packages/base/tests/functional/basics/Choice.lua index cb2586f3..514298fa 100644 --- a/packages/base/tests/functional/basics/Choice.lua +++ b/packages/base/tests/functional/basics/Choice.lua @@ -25,8 +25,26 @@ return{ Choice = function(unitTest) - local c = Choice{1, 2, 3} + local c + + local oneValueWarn = function() + c = Choice{1} + end + unitTest:assertWarning(oneValueWarn, "Choice has only one available value.") + unitTest:assertType(c, "Choice") + unitTest:assertEquals(#c.values, 1) + local unnecessaryArgument = function() + c = Choice{1, 2, 3, max = 4} + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("max")) + unitTest:assertType(c, "Choice") + unitTest:assertEquals(#c.values, 3) + + local defaultValue = function() + c = Choice{1, 2, 3, default = 1} + end + unitTest:assertWarning(defaultValue, defaultValueMsg("default", 1)) unitTest:assertType(c, "Choice") unitTest:assertEquals(#c.values, 3) @@ -42,11 +60,17 @@ return{ unitTest:assertEquals(c.min, 5) unitTest:assertEquals(c.default, 7) - c = Choice{min = 5} + defaultValue = function() + c = Choice{min = 5, default = 5} + end + unitTest:assertWarning(defaultValue, defaultValueMsg("default", 5)) unitTest:assertType(c, "Choice") unitTest:assertEquals(c.default, 5) - c = Choice{max = 5, default = 3} + unnecessaryArgument = function() + c = Choice{max = 5, default = 3, w = false} + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("w")) unitTest:assertType(c, "Choice") unitTest:assertEquals(c.max, 5) unitTest:assertEquals(c.default, 3) diff --git a/packages/base/tests/functional/basics/Directory.lua b/packages/base/tests/functional/basics/Directory.lua index ae7365f9..792a6d85 100644 --- a/packages/base/tests/functional/basics/Directory.lua +++ b/packages/base/tests/functional/basics/Directory.lua @@ -27,10 +27,14 @@ return{ local dir = packageInfo("base").data unitTest:assertType(dir, "Directory") - dir = Directory{ - name = ".tmp_XXXXX", - tmp = true - } + local unnecessaryArgument = function() + dir = Directory{ + name = ".tmp_XXXXX", + tmp = true, + tmpd = true, + } + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("tmpd", "tmp")) unitTest:assert(dir:exists()) diff --git a/packages/base/tests/functional/basics/Environment.lua b/packages/base/tests/functional/basics/Environment.lua index a3d68d95..57d74d0b 100644 --- a/packages/base/tests/functional/basics/Environment.lua +++ b/packages/base/tests/functional/basics/Environment.lua @@ -55,7 +55,10 @@ return{ env:run(10) unitTest:assertEquals(13, a.x) - env = Environment{} + local unnecessaryArg = function() + env = Environment{2} + end + unitTest:assertWarning(unnecessaryArg, "Argument '1' (a 'number') is unnecessary for the Environment.") env:add(cs) env:add(a) diff --git a/packages/base/tests/functional/basics/ErrorHandling.lua b/packages/base/tests/functional/basics/ErrorHandling.lua index 322648f1..fe6a7f32 100644 --- a/packages/base/tests/functional/basics/ErrorHandling.lua +++ b/packages/base/tests/functional/basics/ErrorHandling.lua @@ -52,6 +52,13 @@ return{ defaultTableValue(t, "y", 8) unitTest:assertEquals(t.y, 8) + + local warning_func = function() + defaultTableValue(t, "x", 5) + end + + unitTest:assertWarning(warning_func, defaultValueMsg("x", 5)) + unitTest:assertEquals(t.x, 5) end, defaultValueMsg = function(unitTest) unitTest:assertEquals(defaultValueMsg("aaa", 2), "Argument 'aaa' could be removed as it is the default value (2).") diff --git a/packages/base/tests/functional/basics/Event.lua b/packages/base/tests/functional/basics/Event.lua index cb6933e7..d222dc9a 100644 --- a/packages/base/tests/functional/basics/Event.lua +++ b/packages/base/tests/functional/basics/Event.lua @@ -26,15 +26,48 @@ return{ Event = function(unitTest) - local event = Event{action = function() end} + local event + + local warning_func = function() + event = Event{ + action = function() end, + priority = "medium" + } + end + unitTest:assertWarning(warning_func, defaultValueMsg("priority", 0)) + unitTest:assertEquals(event:getTime(), 1) + unitTest:assertEquals(event:getPeriod(), 1) + unitTest:assertEquals(event:getPriority(), 0) + unitTest:assertEquals(type(event), "Event") + warning_func = function() + event = Event{ + action = function() end, + start = 1 + } + end + unitTest:assertWarning(warning_func, defaultValueMsg("start", 1)) unitTest:assertEquals(event:getTime(), 1) unitTest:assertEquals(event:getPeriod(), 1) unitTest:assertEquals(event:getPriority(), 0) unitTest:assertEquals(type(event), "Event") - event = Event{start = 0.5, period = 2, priority = 1, action = function() end} + warning_func = function() + event = Event{ + action = function() end, + period = 1 + } + end + unitTest:assertWarning(warning_func, defaultValueMsg("period", 1)) + unitTest:assertEquals(event:getTime(), 1) + unitTest:assertEquals(event:getPeriod(), 1) + unitTest:assertEquals(event:getPriority(), 0) + unitTest:assertEquals(type(event), "Event") + local unnecessaryArgument = function() + event = Event{start = 0.5, period = 2, priority = 1, action = function() end, myperiod = function() end} + end + unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("myperiod", "period")) unitTest:assertEquals(event:getTime(), 0.5) unitTest:assertEquals(event:getPeriod(), 2) unitTest:assertEquals(event:getPriority(), 1) @@ -107,14 +140,55 @@ return{ local instance = m{} - local t = Timer{ - Event{action = soc}, -- 1000 - Event{action = c}, -- 2 - Event{action = cs}, - Event{action = instance}, -- 20 - Event{action = ag}, -- 100 - Event{action = traj} - } + local t + -- TODO(#1906) + warning_func = function() + t = Timer{ + Event{action = soc}, -- 1000 + Event{action = c}, -- 2 + Event{action = cs}, + Event{action = instance}, -- 20 + Event{action = ag}, -- 100 + Event{action = traj, priority = "medium"} + } + end + unitTest:assertWarning(warning_func, defaultValueMsg("priority", 0)) + + warning_func = function() + t = Timer{ + Event{action = soc, priority = "medium"}, -- 1000 + Event{action = c}, -- 2 + Event{action = cs}, + Event{action = instance}, -- 20 + Event{action = ag}, -- 100 + Event{action = traj} + } + end + unitTest:assertWarning(warning_func, defaultValueMsg("priority", 0)) + + warning_func = function() + t = Timer{ + Event{action = soc}, -- 1000 + Event{action = c}, -- 2 + Event{action = cs}, + Event{action = instance}, -- 20 + Event{action = ag, priority = "medium"}, -- 100 + Event{action = traj} + } + end + unitTest:assertWarning(warning_func, defaultValueMsg("priority", 0)) + + warning_func = function() + t = Timer{ + Event{action = soc}, -- 1000 + Event{action = c, priority = "high"}, -- 2 + Event{action = cs}, + Event{action = instance}, -- 20 + Event{action = ag}, -- 100 + Event{action = traj} + } + end + unitTest:assertWarning(warning_func, defaultValueMsg("priority", -5)) t:run(2) unitTest:assertEquals(count, 1222) @@ -173,12 +247,15 @@ return{ config = function(unitTest) local event = Event{action = function() end} - event:config{ - time = 0.5, - period = 2, - priority = 1 - } - + local warning_func = function() + event:config{ + time = 0.5, + period = 2, + priority = 1, + perod = false + } + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("perod", "period")) unitTest:assertEquals(event:getTime(), 0.5) unitTest:assertEquals(event:getPeriod(), 2) unitTest:assertEquals(event:getPriority(), 1) diff --git a/packages/base/tests/functional/basics/File.lua b/packages/base/tests/functional/basics/File.lua index cb55d37b..b6c63dde 100644 --- a/packages/base/tests/functional/basics/File.lua +++ b/packages/base/tests/functional/basics/File.lua @@ -51,6 +51,11 @@ return{ local filename = "test.csv" local file = File(filename) + local warning_func = function() + file:close() + end + unitTest:assertWarning(warning_func, "File is not opened.") + file.file = io.open(file.filename, "a+") local close = file:close() @@ -171,6 +176,17 @@ return{ unitTest:assertType(csv, "DataFrame") unitTest:assertEquals(4, #csv) unitTest:assertEquals(20, csv[1].age) + + local s = sessionInfo().separator + file = filePath("test/error"..s.."csv-error.csv") + + local warning_func = function() + csv = file:read() + end + unitTest:assertWarning(warning_func, "Line 3 ('\"mary\",18,100,3,1') should contain 6 attributes but has 5.") + unitTest:assertType(csv, "DataFrame") + unitTest:assertEquals(3, #csv) + unitTest:assertEquals(20, csv[1].age) end, split = function(unitTest) local file = filePath("agents.csv", "base") diff --git a/packages/base/tests/functional/basics/Group.lua b/packages/base/tests/functional/basics/Group.lua index 5e11626a..db86bcff 100644 --- a/packages/base/tests/functional/basics/Group.lua +++ b/packages/base/tests/functional/basics/Group.lua @@ -45,9 +45,44 @@ return{ quantity = 10 } - local g = Group{ - target = nonFooSociety - } + local g + local warning_func = function() + g = Group{ + target = nonFooSociety, + random = false + } + end + unitTest:assertWarning(warning_func, defaultValueMsg("random", false)) + unitTest:assertType(g, "Group") + unitTest:assertEquals(#g, #nonFooSociety) + unitTest:assertEquals(g.agents[1], nonFooSociety.agents[1]) + unitTest:assertNil(g.select) + unitTest:assertNil(g.greater) + unitTest:assertEquals(g:w(), 30) + unitTest:assertEquals(g:p(), 50) + + warning_func = function() + g = Group{ + target = nonFooSociety, + build = true + } + end + unitTest:assertWarning(warning_func, defaultValueMsg("build", true)) + unitTest:assertType(g, "Group") + unitTest:assertEquals(#g, #nonFooSociety) + unitTest:assertEquals(g.agents[1], nonFooSociety.agents[1]) + unitTest:assertNil(g.select) + unitTest:assertNil(g.greater) + unitTest:assertEquals(g:w(), 30) + unitTest:assertEquals(g:p(), 50) + + warning_func = function() + g = Group{ + target = nonFooSociety, + selection = function() return true end + } + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("selection", "select")) unitTest:assertType(g, "Group") unitTest:assertEquals(#g, #nonFooSociety) unitTest:assertEquals(g.agents[1], nonFooSociety.agents[1]) @@ -340,6 +375,11 @@ select function target = nonFooSociety } + local warning_func = function() + g:sort() + end + unitTest:assertWarning(warning_func, "Cannot sort the Group because there is no previous function.") + g:sort(function(ag1, ag2) return ag1.age < ag2.age end) diff --git a/packages/base/tests/functional/basics/Model.lua b/packages/base/tests/functional/basics/Model.lua index c5a3ddcd..83b13170 100644 --- a/packages/base/tests/functional/basics/Model.lua +++ b/packages/base/tests/functional/basics/Model.lua @@ -75,7 +75,12 @@ local Tube2 = Model{ return{ Model = function(unitTest) unitTest:assertType(Tube, "Model") - local t = Tube{filter = function() end} + -- TODO(#1908) + --local t + --local warning_func = function() + local t = Tube{filter = function() end} --, block = {xmix = 5}} + --end + --unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("block.xmix", "block.xmax")) -- SKIP unitTest:assertType(t, "Tube") unitTest:assertEquals(t.simulationSteps, 10) @@ -121,16 +126,60 @@ title function type_ string [Tube] water number [200] ]]) + local warning_func = function() + t = Tube{ + simulationSteps = 20, + observingStep = 0.7, + block = {xmin = 2, xmax = 10}, + checkZero = true, + finalTime = 5, + filter = function() end, + s = 3 + } + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("s")) + unitTest:assertEquals(t.simulationSteps, 20) + unitTest:assertEquals(t.block.xmin, 2) + unitTest:assertEquals(t.block.xmax, 10) + unitTest:assertEquals(t.block.level, 1) + unitTest:assertEquals(t.block.sleep, 2) + unitTest:assertEquals(t.observingStep, 0.7) + unitTest:assertEquals(t.finalTime, 5) + unitTest:assert(t.checkZero) - t = Tube{ - simulationSteps = 20, - observingStep = 0.7, - block = {xmin = 2, xmax = 10}, - checkZero = true, - finalTime = 5, - filter = function() end - } + warning_func = function() + t = Tube{ + simulationSteps = 20, + observingStep = 0.7, + block = {xmin = 2, xmax = 10, mblock = 40}, + checkZero = true, + finalTime = 5, + filter = function() end + } + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("block.mblock")) + unitTest:assertEquals(t.simulationSteps, 20) + unitTest:assertEquals(t.block.xmin, 2) + unitTest:assertEquals(t.block.xmax, 10) + unitTest:assertEquals(t.block.level, 1) + unitTest:assertEquals(t.block.sleep, 2) + unitTest:assertEquals(t.observingStep, 0.7) + unitTest:assertEquals(t.finalTime, 5) + unitTest:assert(t.checkZero) + -- TODO(#1908) + --local defaultValue = function() + t = Tube{ + simulationSteps = 20, + observingStep = 0.7, + block = {xmin = 2, xmax = 10}, + checkZero = true, + finalTime = 5, + filter = function() end, + -- random = false + } + --end + --unitTest:assertWarning(defaultValue, defaultValueMsg("random", false)) -- SKIP unitTest:assertEquals(t.simulationSteps, 20) unitTest:assertEquals(t.block.xmin, 2) unitTest:assertEquals(t.block.xmax, 10) diff --git a/packages/base/tests/functional/basics/Neighborhood.lua b/packages/base/tests/functional/basics/Neighborhood.lua index 686f4c52..20764d28 100644 --- a/packages/base/tests/functional/basics/Neighborhood.lua +++ b/packages/base/tests/functional/basics/Neighborhood.lua @@ -62,6 +62,10 @@ weights vector of size 0 unitTest:assertEquals(#neigh, 1) neigh:add(cell2, 0.5) + --local warning_func = function() -- TODO(#1909) + -- neigh:add(cell2) + --end + --unitTest:assertWarning(warning_func, "Cell 'C01L01' already belongs to the Neighborhood.") -- SKIP unitTest:assert(neigh:isNeighbor(cell1)) unitTest:assertEquals(neigh:getWeight(cell1), 1) unitTest:assert(neigh:isNeighbor(cell2)) @@ -125,11 +129,17 @@ weights vector of size 0 local cell1 = Cell{} local cell2 = Cell{x = 0, y = 1} local cell3 = Cell{x = 1, y = 1} + local cell4 = Cell{} neigh:add(cell1) neigh:add(cell2) neigh:add(cell3) + local warning_func = function() + neigh:remove(cell4) + end + unitTest:assertWarning(warning_func, "Trying to remove a Cell that does not belong to the Neighborhood.") + neigh:remove(cell1) unitTest:assertEquals(#neigh, 2) unitTest:assert(not neigh:isNeighbor(cell1)) diff --git a/packages/base/tests/functional/basics/Package.lua b/packages/base/tests/functional/basics/Package.lua index f869e121..8c561e44 100644 --- a/packages/base/tests/functional/basics/Package.lua +++ b/packages/base/tests/functional/basics/Package.lua @@ -53,6 +53,12 @@ return{ import("base", true) unitTest:assertType(forEachCell, "function") + + local warning_func = function() + import("base") + end + unitTest:assertWarning(warning_func, "Package 'base' is already loaded.") + unitTest:assertType(forEachCell, "function") end, packageInfo = function(unitTest) local r = packageInfo() diff --git a/packages/base/tests/functional/basics/Random.lua b/packages/base/tests/functional/basics/Random.lua index 26191482..370d422a 100644 --- a/packages/base/tests/functional/basics/Random.lua +++ b/packages/base/tests/functional/basics/Random.lua @@ -25,16 +25,64 @@ ------------------------------------------------------------------------------------------- return { - Random = function(self) + Random = function(unitTest) local r = Random() - self:assertEquals(type(r), "Random") - self:assertEquals(type(r:integer()), "number") - self:assertEquals(type(r:number()), "number") + unitTest:assertEquals(type(r), "Random") + unitTest:assertEquals(type(r:integer()), "number") + unitTest:assertEquals(type(r:number()), "number") + + local warning_func = function() + r = Random{lambda = 1} + end + unitTest:assertWarning(warning_func, defaultValueMsg("lambda", 1)) + unitTest:assertEquals(type(r), "Random") + unitTest:assertEquals(type(r:integer()), "number") + unitTest:assertEquals(type(r:number()), "number") + + warning_func = function() + r = Random{mean = 0.5, sd = 0.5, abc = 2} + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("abc")) + unitTest:assertEquals(type(r), "Random") + unitTest:assertEquals(type(r:integer()), "number") + unitTest:assertEquals(type(r:number()), "number") + + warning_func = function() + r = Random{p = 0.3, w = 2} + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("w")) + unitTest:assertEquals(type(r), "Random") + unitTest:assertEquals(type(r:integer()), "number") + unitTest:assertEquals(type(r:number()), "number") + + warning_func = function() + r = Random{min = 2, max = 5, w = 2} + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("w")) + unitTest:assertEquals(type(r), "Random") + unitTest:assertEquals(type(r:integer()), "number") + unitTest:assertEquals(type(r:number()), "number") + + warning_func = function() + Random{mean = 0.5, sd = 1} + end + unitTest:assertWarning(warning_func, defaultValueMsg("sd", 1)) + unitTest:assertEquals(type(r), "Random") + unitTest:assertEquals(type(r:integer()), "number") + unitTest:assertEquals(type(r:number()), "number") + + warning_func = function() + Random{mean = 1, sd = 0.5} + end + unitTest:assertWarning(warning_func, defaultValueMsg("mean", 1)) + unitTest:assertEquals(type(r), "Random") + unitTest:assertEquals(type(r:integer()), "number") + unitTest:assertEquals(type(r:number()), "number") Random_.cObj_ = nil r = Random() - self:assertEquals(type(r:integer()), "number") - self:assertEquals(type(r:number()), "number") + unitTest:assertEquals(type(r:integer()), "number") + unitTest:assertEquals(type(r:number()), "number") end, __tostring = function(unitTest) local bern = Random{p = 0.3} diff --git a/packages/base/tests/functional/basics/SocialNetwork.lua b/packages/base/tests/functional/basics/SocialNetwork.lua index 4672a7b8..a15e08d2 100644 --- a/packages/base/tests/functional/basics/SocialNetwork.lua +++ b/packages/base/tests/functional/basics/SocialNetwork.lua @@ -68,6 +68,10 @@ weights named table of size 1 unitTest:assertEquals(sntw.count, 1) sntw:add(ag2, 0.5) + local warning_func = function() + sntw:add(ag2) + end + unitTest:assertWarning(warning_func, "Agent '2' already belongs to the SocialNetwork.") unitTest:assertEquals(ag1, sntw.connections["1"]) unitTest:assertEquals(ag2, sntw.connections["2"]) unitTest:assertEquals(sntw.weights["1"], 1) @@ -139,6 +143,10 @@ weights named table of size 1 sntw:add(ag3) sntw:remove(ag1) + local warning_func = function() + sntw:remove(ag1) + end + unitTest:assertWarning(warning_func, "Trying to remove an Agent that does not belong to the SocialNetwork.") unitTest:assertEquals(#sntw, 2) unitTest:assert(not sntw:isConnection(ag1)) diff --git a/packages/base/tests/functional/basics/Society.lua b/packages/base/tests/functional/basics/Society.lua index 5d48c1e2..c58c6ba6 100644 --- a/packages/base/tests/functional/basics/Society.lua +++ b/packages/base/tests/functional/basics/Society.lua @@ -52,6 +52,7 @@ return { init = function(self) self.charge = 0 unitTest:assertType(self.parent, "Society") + self.male = true end, age = Random{min = 0, max = 10, step = 1}, gender = Random{"male", "female"}, @@ -68,11 +69,14 @@ return { unitTest:assertNil(nonFooAgent.charge) - nonFooSociety = Society{ - instance = nonFooAgent, - quantity = 50 - } - + local warning_func = function() + nonFooSociety = Society{ + instance = nonFooAgent, + quantity = 50, + male = 5 + } + end + unitTest:assertWarning(warning_func, "Attribute 'male' will not be replaced by a summary function.") unitTest:assertType(nonFooSociety, "Society") unitTest:assertEquals(50, #nonFooSociety) unitTest:assertEquals(nonFooSociety:gender().male, 24) @@ -111,12 +115,18 @@ return { unitTest:assertEquals(51, count1) unitTest:assertEquals(50, count2) - local agent1 = Agent{} + local agent1 = Agent{set = function() end} - local soc1 = Society{ - instance = agent1, - quantity = 10 - } + local soc1 + + warning_func = function() + soc1 = Society{ + instance = agent1, + quantity = 10, + set = 5 + } + end + unitTest:assertWarning(warning_func, "Attribute 'set' will not be replaced by a summary function.") unitTest:assertEquals(10, #soc1) local counter = 1 @@ -152,14 +162,143 @@ return { end self.age = self.age + 1 - end + end, + value = 4, + male = true } - local soc = Society{ - instance = ag, - quantity = 10 + local soc + + warning_func = function() + soc = Society{ + instance = ag, + quantity = 10, + value = 5 + } + end + unitTest:assertWarning(warning_func, "Attribute 'value' will not be replaced by a summary function.") + unitTest:assertEquals(soc:age(), 0) + unitTest:assertEquals(soc:human(), 10) + unitTest:assertEquals(soc:gender().male, 10) + + unitTest:assert(soc:getOld()) + unitTest:assertEquals(soc:age(), 10) + unitTest:assert(not soc:getOld()) + unitTest:assertEquals(soc:age(), 10) + + ag = Agent{ + age = 0, + human = true, + gender = "male", + getOld = function(self) + if self.age > 0 then + return false + end + + self.age = self.age + 1 + end, + male = true + } + + warning_func = function() + soc = Society{ + instance = ag, + quantity = 10, + male = 5 + } + end + unitTest:assertWarning(warning_func, "Attribute 'male' will not be replaced by a summary function.") + unitTest:assertEquals(soc:age(), 0) + unitTest:assertEquals(soc:human(), 10) + unitTest:assertEquals(soc:gender().male, 10) + + unitTest:assert(soc:getOld()) + unitTest:assertEquals(soc:age(), 10) + unitTest:assert(not soc:getOld()) + unitTest:assertEquals(soc:age(), 10) + + ag = Agent{ + age = 0, + human = true, + gender = "male", + getOld = function(self) + if self.age > 0 then + return false + end + + self.age = self.age + 1 + end, + status = "alive" } + warning_func = function() + soc = Society{ + instance = ag, + quantity = 10, + status = 5 + } + end + unitTest:assertWarning(warning_func, "Attribute 'status' will not be replaced by a summary function.") + unitTest:assertEquals(soc:age(), 0) + unitTest:assertEquals(soc:human(), 10) + unitTest:assertEquals(soc:gender().male, 10) + + unitTest:assert(soc:getOld()) + unitTest:assertEquals(soc:age(), 10) + unitTest:assert(not soc:getOld()) + unitTest:assertEquals(soc:age(), 10) + + ag = Agent{ + age = 0, + human = true, + gender = "male", + getOld = function(self) + if self.age > 0 then + return false + end + + self.age = self.age + 1 + end, + enter = function() end + } + + warning_func = function() + soc = Society{ + instance = ag, + quantity = 10 + } + end + unitTest:assertWarning(warning_func, "Function 'enter()' from Agent is replaced in the instance.") + unitTest:assertEquals(soc:age(), 0) + unitTest:assertEquals(soc:human(), 10) + unitTest:assertEquals(soc:gender().male, 10) + + unitTest:assert(soc:getOld()) + unitTest:assertEquals(soc:age(), 10) + unitTest:assert(not soc:getOld()) + unitTest:assertEquals(soc:age(), 10) + + ag = Agent{ + age = 0, + human = true, + gender = "male", + getOld = function(self) + if self.age > 0 then + return false + end + + self.age = self.age + 1 + end, + instance = function() end + } + + warning_func = function() + soc = Society{ + instance = ag, + quantity = 10 + } + end + unitTest:assertWarning(warning_func, "Attribute 'instance' belongs to both Society and Agent.") unitTest:assertEquals(soc:age(), 0) unitTest:assertEquals(soc:human(), 10) unitTest:assertEquals(soc:gender().male, 10) @@ -259,7 +398,10 @@ state_ State predators:createSocialNetwork{probability = 0.5, name = "friends"} predators:createSocialNetwork{quantity = 1, name = "boss"} - predators:createSocialNetwork{filter = function() return true end, name = "all"} + local warning_func = function() + predators:createSocialNetwork{filter = function() return true end, name = "all", abc = true} + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("abc")) local count_prob = 0 local count_quant = 0 @@ -282,8 +424,16 @@ state_ State local env = Environment{cs, predators} env:createPlacement{max = 5} - predators:createSocialNetwork{strategy = "cell", name = "c"} - predators:createSocialNetwork{strategy = "neighbor", name = "n"} + warning_func = function() + predators:createSocialNetwork{strategy = "cell", name = "c", quantity = 1} + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("quantity")) + + warning_func = function() + predators:createSocialNetwork{strategy = "neighbor", name = "n", quantity = 1} + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("quantity")) + predators:createSocialNetwork{neighborhood = "2", name = "n2"} local count_c = 0 @@ -320,10 +470,14 @@ state_ State quantity = 10 } - sc:createSocialNetwork{ - strategy = "void", - name = "void" - } + warning_func = function() + sc:createSocialNetwork{ + strategy = "void", + name = "void", + probability = 0.5 + } + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("probability")) unitTest:assertEquals(0, #sc:sample():getSocialNetwork("void")) ag1 = sc:sample() @@ -447,9 +601,20 @@ state_ State quantity = 20 } - predators:createSocialNetwork{strategy = "erdos", quantity = 40, name = "erdos"} - predators:createSocialNetwork{strategy = "barabasi", start = 10, quantity = 2, name = "barabasi"} - predators:createSocialNetwork{strategy = "watts", probability = 0.1, quantity = 2, name = "watts"} + warning_func = function() + predators:createSocialNetwork{strategy = "erdos", quantity = 40, name = "erdos", abc = false} + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("abc")) + + warning_func = function() + predators:createSocialNetwork{strategy = "barabasi", start = 10, quantity = 2, name = "barabasi", abc = true} + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("abc")) + + warning_func = function() + predators:createSocialNetwork{strategy = "watts", probability = 0.1, quantity = 2, name = "watts", abc = true} + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("abc")) local count_barabasi = 0 local count_erdos = 0 diff --git a/packages/base/tests/functional/basics/Timer.lua b/packages/base/tests/functional/basics/Timer.lua index 267b8a31..7af034d3 100644 --- a/packages/base/tests/functional/basics/Timer.lua +++ b/packages/base/tests/functional/basics/Timer.lua @@ -231,6 +231,12 @@ time number [-inf] } timer2:run(6) + + local warning_func = function() + timer2:add(Event{period = 2, action = function() end}) + end + unitTest:assertWarning(warning_func, "Adding an Event with time (1) before the current simulation time (6).") + unitTest:assertEquals(6, timer2:getTime()) unitTest:assertEquals(10, cont) end, @@ -253,6 +259,11 @@ time number [-inf] timer:run(4) + local warning_func = function() + timer:run(2) + end + unitTest:assertWarning(warning_func, "Simulating until a time (2) before the current simulation time (4).") + unitTest:assertEquals(4, qt1) unitTest:assertEquals(3, qt2) unitTest:assertEquals(2, qt3) diff --git a/packages/base/tests/functional/basics/Trajectory.lua b/packages/base/tests/functional/basics/Trajectory.lua index 5ee0a4d3..0b7d35a5 100644 --- a/packages/base/tests/functional/basics/Trajectory.lua +++ b/packages/base/tests/functional/basics/Trajectory.lua @@ -28,9 +28,14 @@ return{ Trajectory = function(unitTest) local cs = CellularSpace{xdim = 10} - local it = Trajectory{ - target = cs - } + local it + local warning_func = function() + it = Trajectory{ + target = cs, + build = true + } + end + unitTest:assertWarning(warning_func, defaultValueMsg("build", true)) local cont = 0 forEachCell(cs, function(cell) @@ -38,6 +43,7 @@ return{ unitTest:assert(cell.id == it.cells[cont].id) end) + unitTest:assertEquals(#it, #cs) unitTest:assertType(it, "Trajectory") unitTest:assertNil(it.select) unitTest:assertNil(it.greater) @@ -51,22 +57,32 @@ return{ unitTest:assertEquals(100, cont) - local tr = Trajectory{ - target = cs, - build = false - } + local tr + warning_func = function() + tr = Trajectory{ + target = cs, + build = false, + random = false + } + end + unitTest:assertWarning(warning_func, defaultValueMsg("random", false)) unitTest:assertEquals(#tr, 0) - local t = Trajectory{ - target = cs, - select = function(c) - if c.x > 7 and c.y > 5 then return true end - end, - greater = function(a, b) - return a.y > b.y - end - } + local t + warning_func = function() + t = Trajectory{ + target = cs, + select = function(c) + if c.x > 7 and c.y > 5 then return true end + end, + greater = function(a, b) + return a.y > b.y + end, + selection = function() return true end + } + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("selection", "select")) cont = 0 local orderMemory = 10 @@ -324,6 +340,11 @@ xyz function local cs = CellularSpace{xdim = 10} local it = Trajectory{target = cs} + local sortWarn = function() + it:sort() + end + unitTest:assertWarning(sortWarn, "Cannot sort the Trajectory because there is no previous function.") + it:sort(function(a, b) return a.y > b.y end) diff --git a/packages/base/tests/functional/basics/Utils.lua b/packages/base/tests/functional/basics/Utils.lua index 6d8b9bb9..71c3762a 100644 --- a/packages/base/tests/functional/basics/Utils.lua +++ b/packages/base/tests/functional/basics/Utils.lua @@ -703,23 +703,31 @@ return{ unitTest:assertEquals(16.48360, v, 0.0001) - v = integrate{ - equation = f, - initial = 0, - a = 0, - b = 3, - step = 0.01 - } + local warning_func = function() + v = integrate{ + equation = f, + initial = 0, + a = 0, + b = 3, + step = 0.01, + metod = 3 + } + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("metod", "method")) unitTest:assertEquals(20.11522, v, 0.0001) - v = integrate{ - equation = f, - initial = 0, - a = 0, - b = 3, - step = 0.001 - } + warning_func = function() + v = integrate{ + equation = f, + initial = 0, + a = 0, + b = 3, + step = 0.001, + method = "euler" + } + end + unitTest:assertWarning(warning_func, defaultValueMsg("method", "euler")) unitTest:assertEquals(20.23650, v, 0.0001) diff --git a/packages/base/tests/observer/alternative/Chart.lua b/packages/base/tests/observer/alternative/Chart.lua index 3f6ce904..15a0f8e7 100644 --- a/packages/base/tests/observer/alternative/Chart.lua +++ b/packages/base/tests/observer/alternative/Chart.lua @@ -98,12 +98,6 @@ return{ unitTest:assertError(error_func, "Attribute 'value' cannot belong to argument 'select' as it was already selected as 'xAxis'.") - local warning_func = function() - Chart{target = c, xwc = 5} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("xwc")) - error_func = function() Chart{target = c, select = {}} end @@ -420,6 +414,74 @@ return{ end unitTest:assertError(error_func, "Selected column 'limit2' does not exist in the DataFrame.") + + local init = function(model) + local contacts = 6 + + model.timer = Timer{ + Event{action = function() + local proportion = model.susceptible / + (model.susceptible + model.infected + model.recovered) + + local newInfected = model.infected * contacts * model.probability * proportion + + local newRecovered = model.infected / model.duration + + model.susceptible = model.susceptible - newInfected + model.recovered = model.recovered + newRecovered + model.infected = model.infected + newInfected - newRecovered + end}, + Event{action = function() + if model.infected >= model.maximum then + contacts = contacts / 2 + return false + end + end} + } + end + + local SIR = Model{ + susceptible = 9998, + infected = 2, + recovered = 0, + duration = 2, + finalTime = 30, + maximum = 1000, + probability = 0.25, + init = init + } + + local e = Environment{ + max1000 = SIR{maximum = 1000}, + max2000 = SIR{maximum = 2000} + } + + error_func = function() + c = Chart{ + target = Environment{}, + select = "infected" + } + end + + unitTest:assertError(error_func, "There is no Model instance within the Environment.") + + error_func = function() + c = Chart{ + target = e + } + end + + unitTest:assertError(error_func, mandatoryArgumentMsg("select")) + + error_func = function() + c = Chart{ + target = e, + select = "infected", + color = {"blue", "red", "green"} + } + end + + unitTest:assertError(error_func, "Arguments 'select' and 'color' should have the same size, got 2 and 3.") end, save = function(unitTest) local c = Cell{value = 5} diff --git a/packages/base/tests/observer/alternative/Clock.lua b/packages/base/tests/observer/alternative/Clock.lua index cc773fa9..66e8891c 100644 --- a/packages/base/tests/observer/alternative/Clock.lua +++ b/packages/base/tests/observer/alternative/Clock.lua @@ -24,8 +24,6 @@ return{ Clock = function(unitTest) - local t = Timer{} - local error_func = function() Clock(2) end @@ -43,12 +41,6 @@ return{ end unitTest:assertError(error_func, incompatibleTypeMsg("target", "Timer", Cell{})) - - local warning_func = function() - Clock{target = t, xwc = 5} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("xwc")) end, save = function(unitTest) local c = Clock{target = Timer{}} diff --git a/packages/base/tests/observer/alternative/Environment.lua b/packages/base/tests/observer/alternative/Environment.lua deleted file mode 100644 index 9d3e39cd..00000000 --- a/packages/base/tests/observer/alternative/Environment.lua +++ /dev/null @@ -1,106 +0,0 @@ -------------------------------------------------------------------------------------------- --- TerraME - a software platform for multiple scale spatially-explicit dynamic modeling. --- Copyright (C) 2001-2017 INPE and TerraLAB/UFOP -- www.terrame.org - --- This code is part of the TerraME framework. --- This framework is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. - --- You should have received a copy of the GNU Lesser General Public --- License along with this library. - --- The authors reassure the license terms regarding the warranties. --- They specifically disclaim any warranties, including, but not limited to, --- the implied warranties of merchantability and fitness for a particular purpose. --- The framework provided hereunder is on an "as is" basis, and the authors have no --- obligation to provide maintenance, support, updates, enhancements, or modifications. --- In no event shall INPE and TerraLAB / UFOP be held liable to any party for direct, --- indirect, special, incidental, or consequential damages arising out of the use --- of this software and its documentation. --- -------------------------------------------------------------------------------------------- - -return{ - Environment = function(unitTest) - local init = function(model) - local contacts = 6 - - model.timer = Timer{ - Event{action = function() - local proportion = model.susceptible / - (model.susceptible + model.infected + model.recovered) - - local newInfected = model.infected * contacts * model.probability * proportion - - local newRecovered = model.infected / model.duration - - model.susceptible = model.susceptible - newInfected - model.recovered = model.recovered + newRecovered - model.infected = model.infected + newInfected - newRecovered - end}, - Event{action = function() - if model.infected >= model.maximum then - contacts = contacts / 2 - return false - end - end} - } - end - - local SIR = Model{ - susceptible = 9998, - infected = 2, - recovered = 0, - duration = 2, - finalTime = 30, - maximum = 1000, - probability = 0.25, - init = init - } - - local e = Environment{ - max1000 = SIR{maximum = 1000}, - max2000 = SIR{maximum = 2000} - } - - local error_func = function() - c = Chart{ - target = Environment{}, - select = "infected" - } - end - - unitTest:assertError(error_func, "There is no Model instance within the Environment.") - - local warning_func = function() - Chart{ - target = e, - select = "infected", - title = "Infected" - } - end - - unitTest:assertWarning(warning_func, defaultValueMsg("title", "Infected")) - - error_func = function() - c = Chart{ - target = e - } - end - - unitTest:assertError(error_func, mandatoryArgumentMsg("select")) - - error_func = function() - c = Chart{ - target = e, - select = "infected", - color = {"blue", "red", "green"} - } - end - - unitTest:assertError(error_func, "Arguments 'select' and 'color' should have the same size, got 2 and 3.") - end -} - diff --git a/packages/base/tests/observer/alternative/Event.lua b/packages/base/tests/observer/alternative/Event.lua deleted file mode 100644 index 6bc8fe99..00000000 --- a/packages/base/tests/observer/alternative/Event.lua +++ /dev/null @@ -1,37 +0,0 @@ -------------------------------------------------------------------------------------------- --- TerraME - a software platform for multiple scale spatially-explicit dynamic modeling. --- Copyright (C) 2001-2017 INPE and TerraLAB/UFOP -- www.terrame.org - --- This code is part of the TerraME framework. --- This framework is free software; you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public --- License as published by the Free Software Foundation; either --- version 2.1 of the License, or (at your option) any later version. - --- You should have received a copy of the GNU Lesser General Public --- License along with this library. - --- The authors reassure the license terms regarding the warranties. --- They specifically disclaim any warranties, including, but not limited to, --- the implied warranties of merchantability and fitness for a particular purpose. --- The framework provided hereunder is on an "as is" basis, and the authors have no --- obligation to provide maintenance, support, updates, enhancements, or modifications. --- In no event shall INPE and TerraLAB / UFOP be held liable to any party for direct, --- indirect, special, incidental, or consequential damages arising out of the use --- of this software and its documentation. --- -------------------------------------------------------------------------------------------- - -return{ - Event = function(unitTest) - local cell = Cell{value = 3} - local chart = Chart{target = cell, select = "value"} - - local warning_func = function() - Event{action = chart, priority = "verylow"} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("priority", 10)) - end -} - diff --git a/packages/base/tests/observer/alternative/InternetSender.lua b/packages/base/tests/observer/alternative/InternetSender.lua index 45331eb9..a76a954e 100644 --- a/packages/base/tests/observer/alternative/InternetSender.lua +++ b/packages/base/tests/observer/alternative/InternetSender.lua @@ -63,6 +63,7 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg("host", "string", 5)) + -- TODO(#1911) local warning_func = function() InternetSender{target = c, host = "localhost"} end @@ -81,6 +82,7 @@ return{ unitTest:assertError(error_func, "Argument 'port' should be greater or equal to 50000, got 49999.") + -- TODO(#1911) warning_func = function() InternetSender{target = c, port = 456456} end @@ -93,6 +95,7 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg("protocol", "string", 5)) + -- TODO(#1911) warning_func = function() InternetSender{target = c, protocol = "udp"} end @@ -111,6 +114,7 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg("visible", "boolean", 4)) + -- TODO(#1911) warning_func = function() InternetSender{target = c, visible = true} end @@ -123,6 +127,7 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg("compress", "boolean", 4)) + -- TODO(#1911) warning_func = function() InternetSender{target = c, compress = true} end diff --git a/packages/base/tests/observer/alternative/Map.lua b/packages/base/tests/observer/alternative/Map.lua index 6ede01ab..90cd89a1 100644 --- a/packages/base/tests/observer/alternative/Map.lua +++ b/packages/base/tests/observer/alternative/Map.lua @@ -75,12 +75,6 @@ return{ unitTest:assertError(error_func, "All the elements of an RGB composition should be numbers, got 'string' in position 1.") - local warning_func = function() - Map{target = c, select = "x", slices = 10, min = 0, max = 10, values = {"a"}, color = "Blues"} - end - - unitTest:assertWarning(warning_func, "Argument 'values' is unnecessary. Do you mean 'value'?") - -- equalsteps error_func = function() Map{target = c, grouping = "equalsteps"} @@ -154,12 +148,6 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg("title", "string", 5)) - warning_func = function() - Map{target = c, select = "x", author = 5, slices = 10, color = {"blue", "red"}} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("author")) - error_func = function() Map{ target = c, @@ -222,12 +210,6 @@ return{ unitTest:assertError(error_func, incompatibleTypeMsg("invert", "boolean", 2)) - warning_func = function() - Map{target = c, select = "x", invert = false, slices = 10, min = 0, max = 100, color = "Blues"} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("invert", false)) - -- quantil error_func = function() Map{target = c, grouping = "quantil"} @@ -295,19 +277,14 @@ return{ unitTest:assertError(error_func, "Invalid description for color in position 1. It should be a table or string, got number.") - warning_func = function() - Map{target = c, select = "x", author = 5, slices = 10, color = {"blue", "red"}, grouping = "quantil"} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("author")) - error_func = function() Map{target = c, select = "x", invert = 2, slices = 10, color = "Blues", grouping = "quantil"} end unitTest:assertError(error_func, incompatibleTypeMsg("invert", "boolean", 2)) - warning_func = function() + -- TODO(#1914): remove it + local warning_func = function() Map{target = c, select = "x", invert = false, slices = 10, color = "Blues", grouping = "quantil"} end @@ -517,19 +494,6 @@ return{ unitTest:assertError(error_func, "There should not exist repeated elements in 'value'.") - warning_func = function() - Map{target = c, select = "x", author = 5, value = {1, 2}, color = {"blue", "red"}} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("author")) - - -- none - warning_func = function() - Map{target = c, grouping = "none", author = "aaa"} - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("author")) - error_func = function() Map{target = c, grouping = "none", color = {"blue", "red"}} end @@ -579,37 +543,21 @@ return{ unitTest:assertError(error_func, "The Society does not have a placement. Please call Environment:createPlacement() first.") - local map = Map{ - target = cs, - grouping = "none" - } - Environment{soc, cs}:createPlacement{} - warning_func = function() - Map{target = soc, background = map, grid = true} - end - - unitTest:assertWarning(warning_func, "Argument 'grid' cannot be used with a Map 'background'.") - error_func = function() Map{target = soc, grid = 2} end unitTest:assertError(error_func, incompatibleTypeMsg("grid", "boolean", 2)) - warning_func = function() - Map{target = soc, grid = false} - end - - unitTest:assertWarning(warning_func, defaultValueMsg("grid", false)) - error_func = function() Map{target = soc, color = "Blues"} end unitTest:assertError(error_func, "Grouping 'none' cannot use ColorBrewer.") + -- TODO(#1912): remove after warning_func = function() Map{target = soc, font = "Blues"} end @@ -658,18 +606,6 @@ return{ unitTest:assertError(error_func, "It is necessary to set 'value' or 'slices' to draw the placement.") - warning_func = function() - Map{ - target = cs, - grouping = "placement", - abx = 2, - value = {0, 1}, - color = {"red", "blue"} - } - end - - unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("abx")) - error_func = function() Map{ target = soc, diff --git a/packages/base/tests/observer/basics/Chart.lua b/packages/base/tests/observer/basics/Chart.lua index cb55a33c..c868baf9 100644 --- a/packages/base/tests/observer/basics/Chart.lua +++ b/packages/base/tests/observer/basics/Chart.lua @@ -90,7 +90,12 @@ return{ end } - local c1 = Chart{target = world} + local c1 + local warning_func = function() + c1 = Chart{target = world, xwc = 5} + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("xwc")) + c1:update(0) c1:update(1) unitTest:assertSnapshot(c1, "chart-table-base.bmp", 0.03) @@ -244,10 +249,15 @@ return{ max2000 = SIR{maximum = 2000} } - local c = Chart{ - target = e, - select = "infected" - } + local c + warning_func = function() + c = Chart{ + target = e, + select = "infected", + title = "Infected" + } + end + unitTest:assertWarning(warning_func, defaultValueMsg("title", "Infected")) e:add(Event{action = c}) e:run() diff --git a/packages/base/tests/observer/basics/Clock.lua b/packages/base/tests/observer/basics/Clock.lua index dfb9a36f..1e216cba 100644 --- a/packages/base/tests/observer/basics/Clock.lua +++ b/packages/base/tests/observer/basics/Clock.lua @@ -29,7 +29,11 @@ return{ ev1 = Event{action = function() c:update() end}, } - c = Clock{target = timer} + local warning_func = function() + c = Clock{target = timer, xwc = 5} + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("xwc")) + timer:run(50) unitTest:assertSnapshot(c, "clock_single_event.bmp", 0.5) diff --git a/packages/base/tests/observer/basics/Event.lua b/packages/base/tests/observer/basics/Event.lua index 193e523b..4ee41f07 100644 --- a/packages/base/tests/observer/basics/Event.lua +++ b/packages/base/tests/observer/basics/Event.lua @@ -34,12 +34,16 @@ return{ } model.timer = Timer{ - Event{action = model.ch} + Event{action = model.ch, priority = "verylow"} } end } - local instance = m{} + local instance + local warning_func = function() + instance = m{} + end + unitTest:assertWarning(warning_func, defaultValueMsg("priority", 10)) instance:run() diff --git a/packages/base/tests/observer/basics/InternetSender.lua b/packages/base/tests/observer/basics/InternetSender.lua index be85d78c..a56358b9 100644 --- a/packages/base/tests/observer/basics/InternetSender.lua +++ b/packages/base/tests/observer/basics/InternetSender.lua @@ -24,6 +24,7 @@ return{ InternetSender = function(unitTest) + -- TODO(#1911) --[[ local world = Cell{ count = 0, diff --git a/packages/base/tests/observer/basics/Map.lua b/packages/base/tests/observer/basics/Map.lua index 00e6e8ea..453b2094 100644 --- a/packages/base/tests/observer/basics/Map.lua +++ b/packages/base/tests/observer/basics/Map.lua @@ -40,28 +40,38 @@ return{ cell.value = r:number() end) - m = Map{ - target = cs, - title = "Basic", - select = "value", - min = 0, - max = 1, - slices = 10, - color = "Blues" - } + local warning_func = function() + m = Map{ + target = cs, + title = "Basic", + select = "value", + min = 0, + max = 1, + slices = 10, + color = "Blues", + abx = 2 + } + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("abx")) unitTest:assertType(m, "Map") unitTest:assertEquals(m.title, "Basic") + -- TODO(#1912) + --local mi + --warning_func = function() local mi = Map{ - target = cs, - select = "value", - min = 0, - max = 1, - slices = 10, - invert = true, - color = "Blues" - } + target = cs, + select = "value", + min = 0, + max = 1, + slices = 10, + invert = true, + color = "Blues", + -- font = "Blues" + } + --end + --unitTest:assertWarning(warning_func, "Font 'Blues' is not installed. Using default font.") -- SKIP unitTest:assertType(m, "Map") @@ -127,14 +137,18 @@ return{ instance = c } - m = Map{ - target = cs, - select = "mvalue", - min = 0, - max = 1, - slices = 10, - color = "Blues" - } + warning_func = function() + m = Map{ + target = cs, + select = "mvalue", + min = 0, + max = 1, + slices = 10, + color = "Blues", + invert = false + } + end + unitTest:assertWarning(warning_func, defaultValueMsg("invert", false)) m:update() unitTest:assertSnapshot(m, "map_function.bmp") @@ -145,12 +159,16 @@ return{ cell.level = c:sample() end) - m = Map{ - target = cs, - select = "level", - color = {"blue", "green", "red"}, - value = {"low", "medium", "high"} - } + warning_func = function() + m = Map{ + target = cs, + select = "level", + color = {"blue", "green", "red"}, + value = {"low", "medium", "high"}, + author = 5 + } + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("author")) unitTest:assertType(m, "Map") @@ -175,16 +193,20 @@ return{ color = "Blues" } - mi = Map{ - target = cs, - select = "value", - min = 0, - max = 1, - slices = 10, - grouping = "quantil", - invert = true, - color = "Blues" - } + warning_func = function() + mi = Map{ + target = cs, + select = "value", + min = 0, + max = 1, + slices = 10, + grouping = "quantil", + invert = true, + color = "Blues", + values = {"a"} + } + end + unitTest:assertWarning(warning_func, "Argument 'values' is unnecessary. Do you mean 'value'?") unitTest:assertType(m, "Map") unitTest:assertSnapshot(m, "map_quantil.bmp") @@ -194,27 +216,36 @@ return{ cell.w = cell.x end) - m = Map{ - target = cs, - select = "w", - min = 0, - max = 10, - slices = 3, - grouping = "quantil", - color = "Blues" - } + warning_func = function() + m = Map{ + target = cs, + select = "w", + min = 0, + max = 10, + slices = 3, + grouping = "quantil", + color = "Blues", + author = 5 + } + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("author")) unitTest:assertSnapshot(m, "map_quantil_3.bmp") - m = Map{ - target = cs, - select = "w", - min = 0, - max = 10, - slices = 10, - grouping = "quantil", - color = "Blues" - } + -- TODO(#1914) + --warning_func = function() + m = Map{ + target = cs, + select = "w", + min = 0, + max = 10, + slices = 10, + grouping = "quantil", + color = "Blues", + -- invert = false + } + --end + --unitTest:assertWarning(warning_func, defaultValueMsg("invert", false)) -- SKIP unitTest:assertSnapshot(m, "map_quantil_10.bmp") @@ -253,20 +284,28 @@ return{ m:update() unitTest:assertSnapshot(m, "map_society_background.bmp", 0.02) - - m = Map{ - target = soc, - background = "green", - symbol = "turtle" - } + -- TODO(#1912) + --warning_func = function() + m = Map{ + target = soc, + background = "green", + symbol = "turtle", + -- font = "Blues" + } + --end + --unitTest:assertWarning(warning_func, "Font 'Blues' is not installed. Using default font.") -- SKIP unitTest:assertSnapshot(m, "map_society_background2.bmp", 0.02) - m = Map{ - target = soc, - select = "class", - value = {"small", "large"}, - color = {"green", "red"} - } + warning_func = function() + m = Map{ + target = soc, + select = "class", + value = {"small", "large"}, + color = {"green", "red"}, + grid = false + } + end + unitTest:assertWarning(warning_func, defaultValueMsg("grid", false)) unitTest:assertSnapshot(m, "map_society_uniquevalue.bmp", 0.03) @@ -287,14 +326,18 @@ return{ cell.value = r:number() end) - m = Map{ - target = cs, - select = "value", - min = 0, - max = 1, - slices = 10, - color = "Blues" - } + warning_func = function() + m = Map{ + target = cs, + select = "value", + min = 0, + max = 1, + slices = 10, + color = "Blues", + author = "aaa" + } + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("author")) m:update() unitTest:assertType(m, "Map") @@ -329,18 +372,27 @@ return{ end end) - m = Map{ - target = cs, - select = "state", - value = {"empty", "full"}, - color = {"white", "yellow"} - } - - local m2 = Map{ - background = m, - target = soc, - color = "red" - } + warning_func = function() + m = Map{ + target = cs, + select = "state", + value = {"empty", "full"}, + color = {"white", "yellow"}, + author = 5 + } + end + unitTest:assertWarning(warning_func, unnecessaryArgumentMsg("author")) + + local m2 + warning_func = function() + m2 = Map{ + background = m, + target = soc, + color = "red", + grid = true + } + end + unitTest:assertWarning(warning_func, "Argument 'grid' cannot be used with a Map 'background'.") unitTest:assertSnapshot(m2, "map_society_location.bmp", 0.03) From 7e631cdb122ee8e434609cea84b0a2dd3adf3cee Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Mon, 10 Jul 2017 14:52:55 -0300 Subject: [PATCH 07/36] Close #1839 - Create test that open Project with 'clean = true' many times. --- .../gis/tests/functional/basic/Project.lua | 135 +++++++++++++++++- 1 file changed, 134 insertions(+), 1 deletion(-) diff --git a/packages/gis/tests/functional/basic/Project.lua b/packages/gis/tests/functional/basic/Project.lua index 67c9a9a3..7e3e9a20 100644 --- a/packages/gis/tests/functional/basic/Project.lua +++ b/packages/gis/tests/functional/basic/Project.lua @@ -92,12 +92,145 @@ return { } unitTest:assertType(proj5.firebreak, "Layer") + unitTest:assertEquals(proj5.firebreak.rep, "line") + unitTest:assertEquals(proj5.firebreak.source, "shp") + unitTest:assertType(proj5.cover, "Layer") + unitTest:assertEquals(proj5.cover.rep, "raster") + unitTest:assertEquals(proj5.cover.source, "tif") unitTest:assertType(proj5.river, "Layer") + unitTest:assertEquals(proj5.river.rep, "line") + unitTest:assertEquals(proj5.river.source, "shp") + unitTest:assertType(proj5.limit, "Layer") + unitTest:assertEquals(proj5.limit.rep, "polygon") + unitTest:assertEquals(proj5.limit.source, "shp") - file:deleteIfExists() + proj5 = Project{ + file = file:name(true), + clean = true, + author = "Almeida, R.", + title = "Emas database", + firebreak = filePath("emas-firebreak.shp", "gis"), + cover = filePath("emas-accumulation.tif", "gis"), + river = filePath("emas-river.shp", "gis"), + limit = filePath("emas-limit.shp", "gis") + } + + unitTest:assertType(proj5.firebreak, "Layer") + unitTest:assertEquals(proj5.firebreak.rep, "line") + unitTest:assertEquals(proj5.firebreak.source, "shp") + + unitTest:assertType(proj5.cover, "Layer") + unitTest:assertEquals(proj5.cover.rep, "raster") + unitTest:assertEquals(proj5.cover.source, "tif") + + unitTest:assertType(proj5.river, "Layer") + unitTest:assertEquals(proj5.river.rep, "line") + unitTest:assertEquals(proj5.river.source, "shp") + + unitTest:assertType(proj5.limit, "Layer") + unitTest:assertEquals(proj5.limit.rep, "polygon") + unitTest:assertEquals(proj5.limit.source, "shp") + + local cl = Layer{ + project = proj5, + file = "emas.shp", + clean = true, + input = "limit", + name = "cells", + resolution = 2e3 + } + + unitTest:assertType(cl, "Layer") + unitTest:assertEquals(cl.rep, "polygon") + unitTest:assertEquals(cl.source, "shp") + + proj5 = Project{ + file = file:name(true), + clean = true, + author = "Almeida, R.", + title = "Emas database", + firebreak = filePath("emas-firebreak.shp", "gis"), + river = filePath("emas-river.shp", "gis"), + limit = filePath("emas-limit.shp", "gis"), + cells = "emas.shp" + } + + local cover = Layer{ + project = proj5, + name = "cover", + file = filePath("emas-accumulation.tif", "gis"), + epsg = 29192 + } + + unitTest:assertType(proj5.firebreak, "Layer") + unitTest:assertEquals(proj5.firebreak.rep, "line") + unitTest:assertEquals(proj5.firebreak.source, "shp") + + unitTest:assertType(cover, "Layer") + unitTest:assertEquals(cover.rep, "raster") + unitTest:assertEquals(cover.source, "tif") + + unitTest:assertType(proj5.river, "Layer") + unitTest:assertEquals(proj5.river.rep, "line") + unitTest:assertEquals(proj5.river.source, "shp") + + unitTest:assertType(proj5.limit, "Layer") + unitTest:assertEquals(proj5.limit.rep, "polygon") + unitTest:assertEquals(proj5.limit.source, "shp") + + unitTest:assertType(proj5.cells, "Layer") + unitTest:assertEquals(proj5.cells.rep, "polygon") + unitTest:assertEquals(proj5.cells.source, "shp") + + cl:fill{ + operation = "maximum", + attribute = "maxcover", + layer = "cover" + } + + proj5 = Project{ + file = file:name(true), + clean = true, + author = "Almeida, R.", + title = "Emas database", + firebreak = filePath("emas-firebreak.shp", "gis"), + river = filePath("emas-river.shp", "gis"), + cells = "emas.shp" + } + + unitTest:assertType(proj5.firebreak, "Layer") + unitTest:assertEquals(proj5.firebreak.rep, "line") + unitTest:assertEquals(proj5.firebreak.source, "shp") + + unitTest:assertType(cover, "Layer") + unitTest:assertEquals(cover.rep, "raster") + unitTest:assertEquals(cover.source, "tif") + + unitTest:assertType(proj5.river, "Layer") + unitTest:assertEquals(proj5.river.rep, "line") + unitTest:assertEquals(proj5.river.source, "shp") + + unitTest:assertType(proj5.cells, "Layer") + unitTest:assertEquals(proj5.cells.rep, "polygon") + unitTest:assertEquals(proj5.cells.source, "shp") + + local attrs = proj5.cells:attributes() + unitTest:assertEquals(attrs[5].name, "maxcover") + + proj5 = Project{ + file = file:name(true), + clean = true, + author = "Almeida, R.", + title = "Emas database", + } + + unitTest:assertEquals(#proj5.layers, 0) + + file:delete() + cl:delete() file = File("abc.tview") local proj = Project{ From f0aacd36fe89427d08f7f85d90dfe8126c63dd7a Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Mon, 10 Jul 2017 15:09:34 -0300 Subject: [PATCH 08/36] Updating logs #1878. --- test/log/test-onefile.log | 13 +++++-------- test/log/test-onetest.log | 13 +++++-------- test/log/test-pattern.log | 4 ++-- test/log/test-twofiles.log | 13 +++++-------- test/log/test-twotest.log | 13 +++++-------- 5 files changed, 22 insertions(+), 34 deletions(-) diff --git a/test/log/test-onefile.log b/test/log/test-onefile.log index e952079c..cc9ec439 100644 --- a/test/log/test-onefile.log +++ b/test/log/test-onefile.log @@ -19,9 +19,6 @@ Testing getPeriod Testing getPriority Testing getTime Checking if all asserts were executed -Testing tests/observer/alternative/Event.lua -Testing Event -Checking if all asserts were executed Testing tests/observer/basics/Event.lua Testing Event Checking if all asserts were executed @@ -32,15 +29,15 @@ Skipping examples Skipping logs check Functional test report for package 'base': -Tests were executed in 6.0 seconds. +Tests were executed in 2.07 seconds. No print() calls were found when loading the package. No variable is overwritten when loading the package. There are no invalid files or directories in directory 'tests'. All asserts were executed at least once. -All 64 asserts were executed successfully. -All 11 tested functions do not have any unexpected execution error. -All 11 tested functions have at least one assert. -All 11 tested functions exist in the source code of the package. +All 70 asserts were executed successfully. +All 10 tested functions do not have any unexpected execution error. +All 10 tested functions have at least one assert. +All 10 tested functions exist in the source code of the package. No tested function creates or updates any global variable. No function prints any text on the screen. No assertError() calls have error messages pointing to internal files. diff --git a/test/log/test-onetest.log b/test/log/test-onetest.log index 3770a336..859fd1de 100644 --- a/test/log/test-onetest.log +++ b/test/log/test-onetest.log @@ -12,9 +12,6 @@ Skip checking asserts Testing tests/functional/basics/Event.lua Testing Event Skip checking asserts -Testing tests/observer/alternative/Event.lua -Testing Event -Skip checking asserts Testing tests/observer/basics/Event.lua Testing Event Skip checking asserts @@ -24,15 +21,15 @@ Skipping examples Skipping logs check Functional test report for package 'base': -Tests were executed in 4.62 seconds. +Tests were executed in 1.53 seconds. No print() calls were found when loading the package. No variable is overwritten when loading the package. There are no invalid files or directories in directory 'tests'. Execution of all asserts was not verified. -All 46 asserts were executed successfully. -All 4 tested functions do not have any unexpected execution error. -All 4 tested functions have at least one assert. -All 4 tested functions exist in the source code of the package. +All 52 asserts were executed successfully. +All 3 tested functions do not have any unexpected execution error. +All 3 tested functions have at least one assert. +All 3 tested functions exist in the source code of the package. No tested function creates or updates any global variable. No function prints any text on the screen. No assertError() calls have error messages pointing to internal files. diff --git a/test/log/test-pattern.log b/test/log/test-pattern.log index 51501498..aa15788d 100644 --- a/test/log/test-pattern.log +++ b/test/log/test-pattern.log @@ -36,12 +36,12 @@ Skipping examples Skipping logs check Functional test report for package 'base': -Tests were executed in 7.18 seconds. +Tests were executed in 2.57 seconds. No print() calls were found when loading the package. No variable is overwritten when loading the package. There are no invalid files or directories in directory 'tests'. All asserts were executed at least once. -All 72 asserts were executed successfully. +All 70 asserts were executed successfully. All 20 tested functions do not have any unexpected execution error. All 20 tested functions have at least one assert. All 20 tested functions exist in the source code of the package. diff --git a/test/log/test-twofiles.log b/test/log/test-twofiles.log index a9f57525..2b842fae 100644 --- a/test/log/test-twofiles.log +++ b/test/log/test-twofiles.log @@ -25,9 +25,6 @@ Checking if all asserts were executed Testing tests/functional/basics/Jump.lua Testing Jump Checking if all asserts were executed -Testing tests/observer/alternative/Event.lua -Testing Event -Checking if all asserts were executed Testing tests/observer/basics/Event.lua Testing Event Checking if all asserts were executed @@ -39,15 +36,15 @@ Skipping examples Skipping logs check Functional test report for package 'base': -Tests were executed in 6.2 seconds. +Tests were executed in 1.72 seconds. No print() calls were found when loading the package. No variable is overwritten when loading the package. There are no invalid files or directories in directory 'tests'. All asserts were executed at least once. -All 71 asserts were executed successfully. -All 13 tested functions do not have any unexpected execution error. -All 13 tested functions have at least one assert. -All 13 tested functions exist in the source code of the package. +All 77 asserts were executed successfully. +All 12 tested functions do not have any unexpected execution error. +All 12 tested functions have at least one assert. +All 12 tested functions exist in the source code of the package. No tested function creates or updates any global variable. No function prints any text on the screen. No assertError() calls have error messages pointing to internal files. diff --git a/test/log/test-twotest.log b/test/log/test-twotest.log index d32001a4..35512e02 100644 --- a/test/log/test-twotest.log +++ b/test/log/test-twotest.log @@ -15,9 +15,6 @@ Skip checking asserts Testing tests/functional/basics/Event.lua Testing Event Skip checking asserts -Testing tests/observer/alternative/Event.lua -Testing Event -Skip checking asserts Testing tests/observer/basics/Event.lua Testing Event Skip checking asserts @@ -27,15 +24,15 @@ Skipping examples Skipping logs check Functional test report for package 'base': -Tests were executed in 5.09 seconds. +Tests were executed in 1.46 seconds. No print() calls were found when loading the package. No variable is overwritten when loading the package. There are no invalid files or directories in directory 'tests'. Execution of all asserts was not verified. -All 48 asserts were executed successfully. -All 5 tested functions do not have any unexpected execution error. -All 5 tested functions have at least one assert. -All 5 tested functions exist in the source code of the package. +All 54 asserts were executed successfully. +All 4 tested functions do not have any unexpected execution error. +All 4 tested functions have at least one assert. +All 4 tested functions exist in the source code of the package. No tested function creates or updates any global variable. No function prints any text on the screen. No assertError() calls have error messages pointing to internal files. From f3dbe6e8b6311b47d1e167da0c15c0f0cfec6b27 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Mon, 10 Jul 2017 16:04:11 -0300 Subject: [PATCH 09/36] Close #1915 - Update version number to 2.0.0-rc4. --- build/scripts/linux/terrame-conf.cmake | 2 +- build/scripts/mac/terrame-conf.cmake | 2 +- build/scripts/win/terrame-conf.cmake | 2 +- packages/base/tests/functional/basics/Package.lua | 2 +- test/log/basic-version.log | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build/scripts/linux/terrame-conf.cmake b/build/scripts/linux/terrame-conf.cmake index ede07252..b0df5859 100755 --- a/build/scripts/linux/terrame-conf.cmake +++ b/build/scripts/linux/terrame-conf.cmake @@ -29,7 +29,7 @@ set(TERRALIB_DIR "$ENV{_TERRALIB_MODULES_DIR}" CACHE PATH "TerraLib directory" F set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) set(CMAKE_INSTALL_PREFIX "$ENV{_TERRAME_INSTALL_PATH}" CACHE PATH "Where to install TerraME?" FORCE) set(CMAKE_PREFIX_PATH "${TERRALIB_3RDPARTY_DIR};${Qt5_DIR};${TERRAME_DEPENDENCIES_DIR}" CACHE PATH "Where are the dependencies of TerraME?" FORCE) -set(TERRAME_VERSION_STATUS "rc4-dev" CACHE STRING "Define name of installer" FORCE) +set(TERRAME_VERSION_STATUS "rc4" CACHE STRING "Define name of installer" FORCE) set(TERRAME_BUILD_AS_BUNDLE $ENV{_TERRAME_BUILD_AS_BUNDLE} CACHE BOOL "If on, tells that the build will generate a bundle" FORCE) set(TERRAME_CREATE_INSTALLER $ENV{_TERRAME_CREATE_INSTALLER} CACHE BOOL "Create the installer" FORCE) diff --git a/build/scripts/mac/terrame-conf.cmake b/build/scripts/mac/terrame-conf.cmake index 0bd03556..3841f7c4 100755 --- a/build/scripts/mac/terrame-conf.cmake +++ b/build/scripts/mac/terrame-conf.cmake @@ -31,7 +31,7 @@ set(TERRALIB_DIR "$ENV{_TERRALIB_MODULES_DIR}" CACHE PATH "TerraLib directory" F set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE) set(CMAKE_INSTALL_PREFIX "$ENV{_TERRAME_INSTALL_PATH}" CACHE PATH "Where to install TerraME?" FORCE) set(CMAKE_PREFIX_PATH "${TERRALIB_3RDPARTY_DIR};${Qt5_DIR};${TERRAME_DEPENDENCIES_DIR}" CACHE PATH "Where are the dependencies of TerraME?" FORCE) -set(TERRAME_VERSION_STATUS "rc4-dev" CACHE STRING "Define name of installer" FORCE) +set(TERRAME_VERSION_STATUS "rc4" CACHE STRING "Define name of installer" FORCE) set(TERRAME_BUILD_AS_BUNDLE $ENV{_TERRAME_BUILD_AS_BUNDLE} CACHE BOOL "If on, tells that the build will generate a bundle" FORCE) set(TERRAME_CREATE_INSTALLER $ENV{_TERRAME_CREATE_INSTALLER} CACHE BOOL "Create the installer" FORCE) diff --git a/build/scripts/win/terrame-conf.cmake b/build/scripts/win/terrame-conf.cmake index e763c1a9..3e513960 100644 --- a/build/scripts/win/terrame-conf.cmake +++ b/build/scripts/win/terrame-conf.cmake @@ -24,7 +24,7 @@ set(CMAKE_BUILD_TYPE "Release" CACHE PATH "Build Type" FORCE) set(CMAKE_INSTALL_PREFIX "$ENV{_TERRAME_INSTALL_PATH}" CACHE PATH "Where to install TerraME?" FORCE) set(CMAKE_PREFIX_PATH "$ENV{_TERRALIB_3RDPARTY_DIR};$ENV{_Qt5_DIR}/lib/cmake;$ENV{_TERRAME_DEPENDS_DIR};$ENV{_MSYS_DIR}" CACHE PATH "Where are the dependencies of TerraME?" FORCE) -set(TERRAME_VERSION_STATUS "rc4-dev" CACHE STRING "Define name of installer" FORCE) +set(TERRAME_VERSION_STATUS "rc4" CACHE STRING "Define name of installer" FORCE) set(TERRAME_BUILD_AS_BUNDLE $ENV{_TERRAME_BUILD_AS_BUNDLE} CACHE BOOL "If on, tells that the build will generate a bundle" FORCE) set(TERRAME_CREATE_INSTALLER $ENV{_TERRAME_CREATE_INSTALLER} CACHE BOOL "Create the installer" FORCE) diff --git a/packages/base/tests/functional/basics/Package.lua b/packages/base/tests/functional/basics/Package.lua index 8c561e44..2c8b091f 100644 --- a/packages/base/tests/functional/basics/Package.lua +++ b/packages/base/tests/functional/basics/Package.lua @@ -63,7 +63,7 @@ return{ packageInfo = function(unitTest) local r = packageInfo() - unitTest:assertEquals(r.version, "2.0.0-rc4-dev") + unitTest:assertEquals(r.version, "2.0.0-rc4") unitTest:assertEquals(r.package, "base") unitTest:assertEquals(r.url, "http://www.terrame.org") unitTest:assertType(r.data, "Directory") diff --git a/test/log/basic-version.log b/test/log/basic-version.log index f1105dbf..ca5cc6b1 100644 --- a/test/log/basic-version.log +++ b/test/log/basic-version.log @@ -1,5 +1,5 @@ TerraME - Terra Modeling Environment -Version: 2.0.0-rc4-dev +Version: 2.0.0-rc4 Location (TME_PATH): /Applications/terrame.app/Contents/MacOS Compiled with: Lua 5.3.2 From ec3bda63e747974d3747b7a332b78a8368c156c4 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Tue, 11 Jul 2017 11:43:12 -0300 Subject: [PATCH 10/36] Corrections #1839. --- packages/gis/lua/Project.lua | 12 +-------- .../gis/tests/functional/basic/Project.lua | 7 +++-- packages/gis/tests/postgis/basic/Layer.lua | 27 ++++++++++--------- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/packages/gis/lua/Project.lua b/packages/gis/lua/Project.lua index 4291b967..2a01386b 100644 --- a/packages/gis/lua/Project.lua +++ b/packages/gis/lua/Project.lua @@ -46,7 +46,7 @@ metaTableProject_ = { -- @arg data.directory An optional Directory where shapefile(s) and/or tiff file(s) are stored. When -- using this argument, all such files will be added to the project using the respective file names without -- extension as layer names. This argument can also be a string that will be converted to a Directory. --- @arg data.clean An optional boolean value indicating whether the argument file should be cleaned +-- @arg data.clean An optional boolean value indicating whether the argument file should be removed -- if it already exists. -- The default value is false. -- @arg data.... Names of layers to be created from files. Each argument that has a string as value @@ -90,20 +90,11 @@ function Project(data) data.layers = {} if data.file:exists() and data.clean then - local proj = Project{file = data.file} data.file:delete() if data.file:exists() then customError("File '"..data.file.."' could not be removed.") -- SKIP end - - if data.author == "No author" and proj.author ~= "No author" then - data.author = proj.author - end - - if data.title == "No title" and proj.title ~= "No title" then - data.title = proj.title - end end if data.directory then @@ -170,4 +161,3 @@ function Project(data) return data end - diff --git a/packages/gis/tests/functional/basic/Project.lua b/packages/gis/tests/functional/basic/Project.lua index 7e3e9a20..1209c646 100644 --- a/packages/gis/tests/functional/basic/Project.lua +++ b/packages/gis/tests/functional/basic/Project.lua @@ -57,8 +57,8 @@ return { clean = true } - unitTest:assertEquals(proj1.author, proj3clean.author) - unitTest:assertEquals(proj1.title, proj3clean.title) + unitTest:assertEquals("No author", proj3clean.author) + unitTest:assertEquals("No title", proj3clean.title) unitTest:assertEquals(proj3clean.file, File("amazonia.tview")) file:deleteIfExists() @@ -133,6 +133,7 @@ return { unitTest:assertType(proj5.limit, "Layer") unitTest:assertEquals(proj5.limit.rep, "polygon") unitTest:assertEquals(proj5.limit.source, "shp") + unitTest:assertEquals(proj5.limit.epsg, 29192) local cl = Layer{ project = proj5, @@ -146,6 +147,7 @@ return { unitTest:assertType(cl, "Layer") unitTest:assertEquals(cl.rep, "polygon") unitTest:assertEquals(cl.source, "shp") + unitTest:assertEquals(cl.epsg, 29192) proj5 = Project{ file = file:name(true), @@ -172,6 +174,7 @@ return { unitTest:assertType(cover, "Layer") unitTest:assertEquals(cover.rep, "raster") unitTest:assertEquals(cover.source, "tif") + unitTest:assertEquals(cover.epsg, proj5.cells.epsg) unitTest:assertType(proj5.river, "Layer") unitTest:assertEquals(proj5.river.rep, "line") diff --git a/packages/gis/tests/postgis/basic/Layer.lua b/packages/gis/tests/postgis/basic/Layer.lua index fd630cb5..fb676d3b 100644 --- a/packages/gis/tests/postgis/basic/Layer.lua +++ b/packages/gis/tests/postgis/basic/Layer.lua @@ -123,7 +123,7 @@ return { user = "postgres" } - local l1 = Layer{ + local cl1 = Layer{ project = proj, source = "postgis", clean = true, @@ -135,14 +135,14 @@ return { table = tName1 } - unitTest:assertEquals(l1.name, clName1) + unitTest:assertEquals(cl1.name, clName1) local clName2 = "Another_Sampa_Cells" local tName2 = "add_cellslayer_basic_another" pgData.table = tName2 - local l2 = Layer{ + local cl2 = Layer{ project = proj, source = "postgis", input = layerName1, @@ -154,14 +154,14 @@ return { table = tName2 } - unitTest:assertEquals(l2.name, clName2) + unitTest:assertEquals(cl2.name, clName2) local clName3 = "Other_Sampa_Cells" local tName3 = "add_cellslayer_basic_from_db" pgData.table = tName3 - local l3 = Layer{ + local cl3 = Layer{ project = proj, source = "postgis", input = clName2, @@ -173,7 +173,7 @@ return { table = tName3 } - unitTest:assertEquals(l3.name, clName3) + unitTest:assertEquals(cl3.name, clName3) local newDbName = "new_pg_db_30032017" pgData.database = newDbName @@ -208,8 +208,9 @@ return { local tName4 = string.lower(clName1) pgData.table = tName4 + local cl4 local unnecessaryArgument = function() - Layer{ + cl4 = Layer{ project = proj, source = "postgis", input = layerName1, @@ -284,12 +285,14 @@ return { -- } File(projName):delete() - l1:delete() --- layer1:delete() -- layer1 should not be deleted. What must be deleted is the exported data. --- layer2:delete() -- layer2 was read from a pg database. it does not have an encoding --- layer3:delete() -- same for layer3 + cl1:delete() + cl2:delete() + cl3:delete() + cl4:delete() + layer2:delete() + layer3:delete() layer4:delete() --- layer5:delete() -- same here + layer5:delete() end, delete = function(unitTest) local projName = "layer_delete_pgis.tview" From 91885df5ea00cf324c88287d0e3b3cd97784c420 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Tue, 11 Jul 2017 16:14:28 -0300 Subject: [PATCH 11/36] Small correction in jenkins. --- jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh index f375b0ef..d51f87e8 100755 --- a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh @@ -22,7 +22,7 @@ # indirect, special, incidental, or consequential damages arising out of the use # of this software and its documentation. -# +# ## It prepares a entire TerraME build process. Firstly, it prepares environment, cloning both TerraME and TerraLib. ## After that, It copies required scripts to respective folders. Once done, it compiles TerraLib. # @@ -62,7 +62,7 @@ if [ ! -z "$ghprbActualCommit" ]; then else # Just clone git clone https://github.com/terrame/terrame.git $_TERRAME_GIT_DIR --quiet - rm -rf $_TERRALIB_GIT_DIR $_TERRALIB_BUILD_BASE/solution + rm -rf $_TERRALIB_GIT_DIR $_TERRALIB_BUILD_BASE/solution fi echo "### TerraLib ###" @@ -79,6 +79,7 @@ cp -r $_TERRAME_GIT_DIR/repository/* $_TERRAME_REPOSITORY_DIR cp -r $_TERRAME_GIT_DIR/test/* $_TERRAME_EXECUTION_DIR # Copying TerraME test and config file to Test folder cp $_TERRAME_GIT_DIR/jenkins/all/*.lua $_TERRAME_TEST_DIR +cp $_TERRAME_GIT_DIR/jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh $_TERRAME_TEST_DIR # Copying TerraME TerraLib compilation scripts to TerraLib solution folder cp $_TERRAME_GIT_DIR/build/scripts/linux/terralib-conf.* . # Copying TerraME compilation scripts to TerraME Solution folder From 5c978eaf98ffbfed58f49af70aa4cb176f5c7589 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Tue, 11 Jul 2017 16:26:17 -0300 Subject: [PATCH 12/36] Close #1916 - URI and space in the file path in tview files. --- packages/gis/lua/TerraLib.lua | 8 +++- packages/gis/tests/functional/basic/Layer.lua | 37 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/packages/gis/lua/TerraLib.lua b/packages/gis/lua/TerraLib.lua index 1886d0d7..73959f2b 100644 --- a/packages/gis/lua/TerraLib.lua +++ b/packages/gis/lua/TerraLib.lua @@ -1716,6 +1716,10 @@ local function saveLayerAs(fromData, toData, attrs, values) return true end +local function fixSpaceInPath(path) + return string.gsub(path, "%%20", " ") +end + TerraLib_ = { type_ = "TerraLib", @@ -1828,12 +1832,12 @@ TerraLib_ = { info.source = "postgis" info.encoding = binding.CharEncoding.getEncodingName(layer:getEncoding()) elseif type == "OGR" then - info.file = connInfo:host()..connInfo:path() + info.file = fixSpaceInPath(connInfo:host()..connInfo:path()) local file = File(info.file) info.source = file:extension() info.encoding = binding.CharEncoding.getEncodingName(layer:getEncoding()) elseif type == "GDAL" then - info.file = connInfo:host()..connInfo:path() + info.file = fixSpaceInPath(connInfo:host()..connInfo:path()) local file = File(info.file) info.source = file:extension() elseif type == "WFS" then diff --git a/packages/gis/tests/functional/basic/Layer.lua b/packages/gis/tests/functional/basic/Layer.lua index e47e6102..9ed812cf 100644 --- a/packages/gis/tests/functional/basic/Layer.lua +++ b/packages/gis/tests/functional/basic/Layer.lua @@ -232,6 +232,8 @@ return { unitTest:assertEquals(getn(clSet), 104) local filePath6 = "sampabox.shp" + File(filePath6):deleteIfExists() + local boxDefaultError = function() Layer{ project = proj, @@ -267,12 +269,43 @@ return { input = layerName1, file = filePath7, name = "cells7", + clean = true, resoltion = 200, resolution = 0.7 } end unitTest:assertWarning(unnecessaryArgument, unnecessaryArgumentMsg("resoltion", "resolution")) + local dir = Directory("a b") + dir:create() + local filePath8 = tostring(dir).."/cells8.shp" + + local cl8 = Layer{ + project = proj, + input = layerName1, + file = filePath8, + name = "cells8", + clean = true, + resolution = 0.7 + } + + unitTest:assertEquals(filePath8, cl8.file) + + local dir2 = Directory("a b c") + dir2:create() + local filePath9 = tostring(dir2).."/cells9.shp" + + local cl9 = Layer{ + project = proj, + input = layerName1, + file = filePath9, + name = "cells9", + clean = true, + resolution = 0.7 + } + + unitTest:assertEquals(filePath9, cl9.file) + projName:delete() File(filePath1):delete() File(filePath2):delete() @@ -281,6 +314,10 @@ return { File(filePath5):delete() File(filePath6):delete() File(filePath7):delete() + File(filePath8):delete() + File(filePath9):delete() + dir:delete() + dir2:delete() end, delete = function(unitTest) local projName = File("cellular_layer_del.tview") From ece3d59da7ff7b81f41a045763d298fc804f1ed6 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Wed, 12 Jul 2017 10:05:04 -0300 Subject: [PATCH 13/36] Reviewing jenkins scripts and configuration. --- .../linux/terrame-build-linux-ubuntu-14.04.sh | 4 +--- .../terrame-code-analysis-linux-ubuntu-14.04.sh | 6 ++---- jenkins/linux/terrame-doc-linux-ubuntu-14.04.sh | 2 -- .../terrame-installer-linux-ubuntu-14.04.sh | 4 +--- ...terrame-repository-test-linux-ubuntu-14.04.sh | 4 +--- .../terrame-terralib-build-linux-ubuntu-14.04.sh | 13 ++++++++++--- .../terrame-test-execution-linux-ubuntu-14.04.sh | 5 +---- .../linux/terrame-unittest-linux-ubuntu-14.04.sh | 16 +++++++--------- 8 files changed, 23 insertions(+), 31 deletions(-) diff --git a/jenkins/linux/terrame-build-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-build-linux-ubuntu-14.04.sh index 6bd6e0f6..753c792f 100755 --- a/jenkins/linux/terrame-build-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-build-linux-ubuntu-14.04.sh @@ -22,7 +22,7 @@ # indirect, special, incidental, or consequential damages arising out of the use # of this software and its documentation. -# +# ## It performs TerraME compilation. It does not create installer or even build as bundle. # ## USAGE: @@ -30,8 +30,6 @@ ## # -cd $_TERRAME_BUILD_BASE/solution - # Turning OFF installer flags export _TERRAME_CREATE_INSTALLER="OFF" export _TERRAME_BUILD_AS_BUNDLE="OFF" diff --git a/jenkins/linux/terrame-code-analysis-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-code-analysis-linux-ubuntu-14.04.sh index 2ec0e6f9..45267246 100755 --- a/jenkins/linux/terrame-code-analysis-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-code-analysis-linux-ubuntu-14.04.sh @@ -22,8 +22,8 @@ # indirect, special, incidental, or consequential damages arising out of the use # of this software and its documentation. -# -## It performs a TerraME code analysis of any package. For TerraME purporses, "base" and "gis" internal packages. +# +## It performs a TerraME code analysis of any package. For TerraME purporses, "base" and "gis" internal packages. ## It may be useful for TerraME external packages. # ## USAGE: @@ -38,8 +38,6 @@ export TME_PATH="$_TERRAME_INSTALL_PATH/bin" export PATH=$PATH:$TME_PATH export LD_LIBRARY_PATH=$TME_PATH -cd $_TERRAME_TEST_DIR - # TerraME command arguments. Used for packages like "gis", "sci", "calibration" etc. TERRAME_COMMANDS="" terrame -version diff --git a/jenkins/linux/terrame-doc-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-doc-linux-ubuntu-14.04.sh index 32d7c077..1df9cb61 100755 --- a/jenkins/linux/terrame-doc-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-doc-linux-ubuntu-14.04.sh @@ -38,8 +38,6 @@ export TME_PATH=$_TERRAME_INSTALL_PATH/bin export PATH=$PATH:$TME_PATH export LD_LIBRARY_PATH=$TME_PATH -cd $_TERRAME_TEST_DIR - TERRAME_COMMANDS="" terrame -version if [ "$1" != "" ] && [ "$1" != "base" ]; then diff --git a/jenkins/linux/terrame-installer-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-installer-linux-ubuntu-14.04.sh index 92050644..d20a772f 100755 --- a/jenkins/linux/terrame-installer-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-installer-linux-ubuntu-14.04.sh @@ -22,7 +22,7 @@ # indirect, special, incidental, or consequential damages arising out of the use # of this software and its documentation. -# +# ## It performs a TerraME Installer generation # ## USAGE: @@ -32,8 +32,6 @@ export _TERRAME_CREATE_INSTALLER="ON" export _TERRAME_BUILD_AS_BUNDLE="OFF" -cd $_TERRAME_OUT_DIR/.. - # Copying Generated documentation to Git directory cp -rap $_TERRAME_INSTALL_PATH/bin/packages/base/doc $_TERRAME_GIT_DIR/packages/base/doc cp -rap $_TERRAME_INSTALL_PATH/bin/packages/gis/doc $_TERRAME_GIT_DIR/packages/gis/doc diff --git a/jenkins/linux/terrame-repository-test-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-repository-test-linux-ubuntu-14.04.sh index 813dcc71..1e1ab810 100755 --- a/jenkins/linux/terrame-repository-test-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-repository-test-linux-ubuntu-14.04.sh @@ -22,7 +22,7 @@ # indirect, special, incidental, or consequential damages arising out of the use # of this software and its documentation. -# +# ## It performs a TerraME Repository Tests. # ## USAGE: @@ -33,8 +33,6 @@ export TME_PATH="$_TERRAME_INSTALL_PATH/bin" export PATH=$PATH:$TME_PATH export LD_LIBRARY_PATH=$TME_PATH -cd $_TERRAME_REPOSITORY_DIR - terrame -version terrame -color test.lua 2> /dev/null diff --git a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh index d51f87e8..68f5b78b 100755 --- a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh @@ -71,17 +71,24 @@ git clone -b $_TERRALIB_BRANCH https://gitlab.dpi.inpe.br/rodrigo.avancini/terra # Creating TerraME Test folders and TerraLib solution mkdir $_TERRAME_REPOSITORY_DIR $_TERRAME_TEST_DIR $_TERRAME_EXECUTION_DIR $_TERRALIB_BUILD_BASE/solution $_TERRAME_BUILD_BASE/solution -cd $_TERRALIB_BUILD_BASE/solution +# Copying TerraLib compilation scripts to TerraLib Solution folder +cp $_TERRAME_GIT_DIR/build/scripts/linux/terralib-conf.* $_TERRALIB_BUILD_BASE/solution # Copying TerraME Git Repository to Test Repository Folder cp -r $_TERRAME_GIT_DIR/repository/* $_TERRAME_REPOSITORY_DIR +cp $_TERRAME_GIT_DIR/jenkins/linux/terrame-repository-test-linux-ubuntu-14.04.sh $_TERRAME_REPOSITORY_DIR + # Copying TerraME Git Test Execution to Test Execution Folder cp -r $_TERRAME_GIT_DIR/test/* $_TERRAME_EXECUTION_DIR +cp $_TERRAME_GIT_DIR/jenkins/linux/terrame-test-execution-linux-ubuntu-14.04.sh $_TERRAME_EXECUTION_DIR + # Copying TerraME test and config file to Test folder cp $_TERRAME_GIT_DIR/jenkins/all/*.lua $_TERRAME_TEST_DIR cp $_TERRAME_GIT_DIR/jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh $_TERRAME_TEST_DIR -# Copying TerraME TerraLib compilation scripts to TerraLib solution folder -cp $_TERRAME_GIT_DIR/build/scripts/linux/terralib-conf.* . +cp $_TERRAME_GIT_DIR/jenkins/linux/terrame-code-analysis-linux-ubuntu-14.04.sh $_TERRAME_TEST_DIR +cp $_TERRAME_GIT_DIR/jenkins/linux/terrame-doc-linux-ubuntu-14.04.sh $_TERRAME_TEST_DIR +cp $_TERRAME_GIT_DIR/jenkins/linux/terrame-syntaxcheck-cpp-linux-ubuntu-14.04.sh $_TERRAME_TEST_DIR + # Copying TerraME compilation scripts to TerraME Solution folder cp $_TERRAME_GIT_DIR/build/scripts/linux/terrame-conf.* $_TERRAME_BUILD_BASE/solution diff --git a/jenkins/linux/terrame-test-execution-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-test-execution-linux-ubuntu-14.04.sh index 3514e097..cde31a6d 100755 --- a/jenkins/linux/terrame-test-execution-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-test-execution-linux-ubuntu-14.04.sh @@ -22,7 +22,7 @@ # indirect, special, incidental, or consequential damages arising out of the use # of this software and its documentation. -# +# ## It performs a TerraME test execution. # ## USAGE: @@ -34,9 +34,6 @@ export TME_PATH=$_TERRAME_INSTALL_PATH/bin export PATH=$PATH:$TME_PATH export LD_LIBRARY_PATH=$TME_PATH -# Copying TerraME configuration -cd $_TERRAME_EXECUTION_DIR - terrame -version terrame -color run.lua 2> /dev/null RESULT=$? diff --git a/jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh index 9b8aaf29..124d99a8 100755 --- a/jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh @@ -22,8 +22,8 @@ # indirect, special, incidental, or consequential damages arising out of the use # of this software and its documentation. -# -## It performs a TerraME functional test of any package. For TerraME purporses, "base" and "gis" internal packages. +# +## It performs a TerraME functional test of any package. For TerraME purporses, "base" and "gis" internal packages. ## It may be useful for TerraME external packages. # ## USAGE: @@ -38,10 +38,6 @@ export TME_PATH=$_TERRAME_INSTALL_PATH/bin export PATH=$PATH:$TME_PATH export LD_LIBRARY_PATH=$TME_PATH -cd $_TERRAME_TEST_DIR - -terrame -version - # You may use $ghprbActualCommit for handling if job has triggered by CI event or daily timer. # In this way, if you need a specific configuration for CI execution, use this flag # @@ -57,14 +53,16 @@ terrame -version # # CI execution config # fi +terrame -version + TERRAME_COMMANDS="" # Extra commands if package is gis if [ "$1" != "" ] && [ "$1" != "base" ]; then TERRAME_COMMANDS="-package $1" - # if [ ! -z "$ghprbActualCommit" ]; then + if [ ! -z "$ghprbActualCommit" ]; then # # Temp code to ensure unittest gis does not take too long to execute. Only CI trigger - # echo -e '\ndirectory = {"functional", "shapefile", "postgis", "tif", "geojson", "asc", "wms", "nc"}' >> test.lua - # fi + echo -e '\ndirectory = {"functional", "shapefile", "postgis", "tif", "geojson", "asc", "wms", "nc"}' >> test.lua + fi fi # Executing unittest From efc34cea7014f495cf35fc4dbe08c23b8fd8c7aa Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Wed, 12 Jul 2017 10:40:28 -0300 Subject: [PATCH 14/36] Small change #1839. --- packages/gis/tests/functional/basic/Project.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/gis/tests/functional/basic/Project.lua b/packages/gis/tests/functional/basic/Project.lua index 1209c646..0dbe7693 100644 --- a/packages/gis/tests/functional/basic/Project.lua +++ b/packages/gis/tests/functional/basic/Project.lua @@ -157,7 +157,7 @@ return { firebreak = filePath("emas-firebreak.shp", "gis"), river = filePath("emas-river.shp", "gis"), limit = filePath("emas-limit.shp", "gis"), - cells = "emas.shp" + cells = File("emas.shp") } local cover = Layer{ @@ -201,7 +201,7 @@ return { title = "Emas database", firebreak = filePath("emas-firebreak.shp", "gis"), river = filePath("emas-river.shp", "gis"), - cells = "emas.shp" + cells = File("emas.shp") } unitTest:assertType(proj5.firebreak, "Layer") From 6d1c306cee00f41727166794428b2a6de5bbf485 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Wed, 12 Jul 2017 10:45:48 -0300 Subject: [PATCH 15/36] Reviewing jenkins. --- jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh index 68f5b78b..7eeaa4c6 100755 --- a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh @@ -46,7 +46,7 @@ _TERRALIB_BRANCH=release-5.2 # Removing TerraLib Mod Binding Lua in order to re-generate folder if there is -rm -rf $_TERRALIB_OUT_DIR/terralib_mod_binding_lua $_TERRALIB_INSTALL_PATH $_TERRAME_GIT_DIR $_TERRAME_BUILD_BASE/solution +rm -rf $_TERRALIB_OUT_DIR/terralib_mod_binding_lua $_TERRALIB_INSTALL_PATH $_TERRAME_ROOT_BUILD_DIR rm -rf $_TERRAME_REPOSITORY_DIR $_TERRAME_TEST_DIR $_TERRAME_EXECUTION_DIR echo "### TerraME ###" From f224874f72f18a3398b54a9e9101c952618f848c Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Wed, 12 Jul 2017 12:01:02 -0300 Subject: [PATCH 16/36] Reviewing jenkins. --- jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh index 7eeaa4c6..68f5b78b 100755 --- a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh @@ -46,7 +46,7 @@ _TERRALIB_BRANCH=release-5.2 # Removing TerraLib Mod Binding Lua in order to re-generate folder if there is -rm -rf $_TERRALIB_OUT_DIR/terralib_mod_binding_lua $_TERRALIB_INSTALL_PATH $_TERRAME_ROOT_BUILD_DIR +rm -rf $_TERRALIB_OUT_DIR/terralib_mod_binding_lua $_TERRALIB_INSTALL_PATH $_TERRAME_GIT_DIR $_TERRAME_BUILD_BASE/solution rm -rf $_TERRAME_REPOSITORY_DIR $_TERRAME_TEST_DIR $_TERRAME_EXECUTION_DIR echo "### TerraME ###" From 6c799367aa45dc97234aeb7ff4d703a11f177291 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Wed, 12 Jul 2017 13:39:23 -0300 Subject: [PATCH 17/36] Reviewing jenkins. --- jenkins/linux/terrame-3rdparty-linux-ubuntu-14.04.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jenkins/linux/terrame-3rdparty-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-3rdparty-linux-ubuntu-14.04.sh index 70eed8a4..6eb6ad1b 100755 --- a/jenkins/linux/terrame-3rdparty-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-3rdparty-linux-ubuntu-14.04.sh @@ -26,11 +26,11 @@ # if [ -z "$_TERRALIB_TARGET_3RDPARTY_DIR" ]; then - export _TERRALIB_TARGET_3RDPARTY_DIR="$HOME/MyDevel/terrame/daily/terralib/3rdparty/5.2" + export _TERRALIB_TARGET_3RDPARTY_DIR="$HOME/MyDevel/terrame/terralib/3rdparty/5.2" fi if [ -z "$_TERRAME_TARGET_3RDPARTY_DIR" ]; then - export _TERRAME_TARGET_3RDPARTY_DIR="$HOME/MyDevel/terrame/daily/terrame/3rdparty" + export _TERRAME_TARGET_3RDPARTY_DIR="$HOME/MyDevel/terrame/3rdparty" fi if [ -z "$_TERRALIB_3RDPARTY_NAME" ]; then From 7e7dc98ad1f1892818b0f8797a127c913b0a80db Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Wed, 12 Jul 2017 14:24:03 -0300 Subject: [PATCH 18/36] Reviewing jenkins. --- jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh index 68f5b78b..52d302a5 100755 --- a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh @@ -64,7 +64,7 @@ else git clone https://github.com/terrame/terrame.git $_TERRAME_GIT_DIR --quiet rm -rf $_TERRALIB_GIT_DIR $_TERRALIB_BUILD_BASE/solution fi - +rm -rf $_TERRALIB_GIT_DIR $_TERRALIB_BUILD_BASE/solution echo "### TerraLib ###" git clone -b $_TERRALIB_BRANCH https://gitlab.dpi.inpe.br/rodrigo.avancini/terralib.git $_TERRALIB_GIT_DIR --quiet From 91d6119cabc571e5501365f5a3f496ea63e9173f Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Wed, 12 Jul 2017 14:34:13 -0300 Subject: [PATCH 19/36] Reviewing jenkins. --- jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh index 52d302a5..0109e8d3 100755 --- a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh @@ -63,8 +63,10 @@ else # Just clone git clone https://github.com/terrame/terrame.git $_TERRAME_GIT_DIR --quiet rm -rf $_TERRALIB_GIT_DIR $_TERRALIB_BUILD_BASE/solution + mkdir $_TERRALIB_GIT_DIR fi rm -rf $_TERRALIB_GIT_DIR $_TERRALIB_BUILD_BASE/solution +mkdir $_TERRALIB_GIT_DIR echo "### TerraLib ###" git clone -b $_TERRALIB_BRANCH https://gitlab.dpi.inpe.br/rodrigo.avancini/terralib.git $_TERRALIB_GIT_DIR --quiet From 71b2ca0c067965853e21f59f3cb2a7da365cfed6 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Wed, 12 Jul 2017 14:50:24 -0300 Subject: [PATCH 20/36] Reviewing jenkins. --- jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh index 0109e8d3..af934d2d 100755 --- a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh @@ -62,16 +62,16 @@ if [ ! -z "$ghprbActualCommit" ]; then else # Just clone git clone https://github.com/terrame/terrame.git $_TERRAME_GIT_DIR --quiet - rm -rf $_TERRALIB_GIT_DIR $_TERRALIB_BUILD_BASE/solution + rm -rf $_TERRALIB_GIT_DIR $_TERRALIB_BUILD_BASE/solution/* mkdir $_TERRALIB_GIT_DIR fi -rm -rf $_TERRALIB_GIT_DIR $_TERRALIB_BUILD_BASE/solution +rm -rf $_TERRALIB_GIT_DIR $_TERRALIB_BUILD_BASE/solution/* mkdir $_TERRALIB_GIT_DIR echo "### TerraLib ###" git clone -b $_TERRALIB_BRANCH https://gitlab.dpi.inpe.br/rodrigo.avancini/terralib.git $_TERRALIB_GIT_DIR --quiet # Creating TerraME Test folders and TerraLib solution -mkdir $_TERRAME_REPOSITORY_DIR $_TERRAME_TEST_DIR $_TERRAME_EXECUTION_DIR $_TERRALIB_BUILD_BASE/solution $_TERRAME_BUILD_BASE/solution +mkdir $_TERRAME_REPOSITORY_DIR $_TERRAME_TEST_DIR $_TERRAME_EXECUTION_DIR $_TERRAME_BUILD_BASE/solution # Copying TerraLib compilation scripts to TerraLib Solution folder cp $_TERRAME_GIT_DIR/build/scripts/linux/terralib-conf.* $_TERRALIB_BUILD_BASE/solution From 9a7f1bb025671f4ba84fecd7d0cdab6019e05384 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Wed, 12 Jul 2017 15:01:45 -0300 Subject: [PATCH 21/36] Reviewing jenkins. --- jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh index af934d2d..9a9ebce3 100755 --- a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh @@ -67,6 +67,7 @@ else fi rm -rf $_TERRALIB_GIT_DIR $_TERRALIB_BUILD_BASE/solution/* mkdir $_TERRALIB_GIT_DIR +ls $_TERRALIB_BUILD_BASE echo "### TerraLib ###" git clone -b $_TERRALIB_BRANCH https://gitlab.dpi.inpe.br/rodrigo.avancini/terralib.git $_TERRALIB_GIT_DIR --quiet From 0307cf2845bb8bfac338cf6c1c698a99cf282587 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Wed, 12 Jul 2017 15:24:01 -0300 Subject: [PATCH 22/36] Reviewing jenkins. --- jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh index 9a9ebce3..adfa4a3a 100755 --- a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh @@ -65,9 +65,7 @@ else rm -rf $_TERRALIB_GIT_DIR $_TERRALIB_BUILD_BASE/solution/* mkdir $_TERRALIB_GIT_DIR fi -rm -rf $_TERRALIB_GIT_DIR $_TERRALIB_BUILD_BASE/solution/* -mkdir $_TERRALIB_GIT_DIR -ls $_TERRALIB_BUILD_BASE + echo "### TerraLib ###" git clone -b $_TERRALIB_BRANCH https://gitlab.dpi.inpe.br/rodrigo.avancini/terralib.git $_TERRALIB_GIT_DIR --quiet From 4c45cf2e3d2ae70490c6a49e75cab0fc2faa7589 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Wed, 12 Jul 2017 15:52:50 -0300 Subject: [PATCH 23/36] Reviewing jenkins. --- .../linux/terrame-terralib-build-linux-ubuntu-14.04.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh index adfa4a3a..14c154ee 100755 --- a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh @@ -84,11 +84,11 @@ cp -r $_TERRAME_GIT_DIR/test/* $_TERRAME_EXECUTION_DIR cp $_TERRAME_GIT_DIR/jenkins/linux/terrame-test-execution-linux-ubuntu-14.04.sh $_TERRAME_EXECUTION_DIR # Copying TerraME test and config file to Test folder -cp $_TERRAME_GIT_DIR/jenkins/all/*.lua $_TERRAME_TEST_DIR -cp $_TERRAME_GIT_DIR/jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh $_TERRAME_TEST_DIR -cp $_TERRAME_GIT_DIR/jenkins/linux/terrame-code-analysis-linux-ubuntu-14.04.sh $_TERRAME_TEST_DIR -cp $_TERRAME_GIT_DIR/jenkins/linux/terrame-doc-linux-ubuntu-14.04.sh $_TERRAME_TEST_DIR -cp $_TERRAME_GIT_DIR/jenkins/linux/terrame-syntaxcheck-cpp-linux-ubuntu-14.04.sh $_TERRAME_TEST_DIR +cp --verbose $_TERRAME_GIT_DIR/jenkins/all/*.lua $_TERRAME_TEST_DIR +cp --verbose $_TERRAME_GIT_DIR/jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh $_TERRAME_TEST_DIR +cp --verbose $_TERRAME_GIT_DIR/jenkins/linux/terrame-code-analysis-linux-ubuntu-14.04.sh $_TERRAME_TEST_DIR +cp --verbose $_TERRAME_GIT_DIR/jenkins/linux/terrame-doc-linux-ubuntu-14.04.sh $_TERRAME_TEST_DIR +cp --verbose $_TERRAME_GIT_DIR/jenkins/linux/terrame-syntaxcheck-cpp-linux-ubuntu-14.04.sh $_TERRAME_TEST_DIR # Copying TerraME compilation scripts to TerraME Solution folder cp $_TERRAME_GIT_DIR/build/scripts/linux/terrame-conf.* $_TERRAME_BUILD_BASE/solution From 177c19972fd3cd06452eef5241a4c8975774a78e Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Wed, 12 Jul 2017 16:06:50 -0300 Subject: [PATCH 24/36] Reviewing jenkins. --- jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh index 14c154ee..36c81f8c 100755 --- a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh @@ -73,7 +73,8 @@ git clone -b $_TERRALIB_BRANCH https://gitlab.dpi.inpe.br/rodrigo.avancini/terra mkdir $_TERRAME_REPOSITORY_DIR $_TERRAME_TEST_DIR $_TERRAME_EXECUTION_DIR $_TERRAME_BUILD_BASE/solution # Copying TerraLib compilation scripts to TerraLib Solution folder -cp $_TERRAME_GIT_DIR/build/scripts/linux/terralib-conf.* $_TERRALIB_BUILD_BASE/solution +cp --verbose $_TERRAME_GIT_DIR/build/scripts/linux/terralib-conf.* $_TERRALIB_BUILD_BASE/solution +cp --verbose $_TERRAME_GIT_DIR/jenkins/linux/terrame-build-linux-ubuntu-14.04.sh $_TERRALIB_BUILD_BASE/solution # Copying TerraME Git Repository to Test Repository Folder cp -r $_TERRAME_GIT_DIR/repository/* $_TERRAME_REPOSITORY_DIR @@ -91,7 +92,7 @@ cp --verbose $_TERRAME_GIT_DIR/jenkins/linux/terrame-doc-linux-ubuntu-14.04.sh $ cp --verbose $_TERRAME_GIT_DIR/jenkins/linux/terrame-syntaxcheck-cpp-linux-ubuntu-14.04.sh $_TERRAME_TEST_DIR # Copying TerraME compilation scripts to TerraME Solution folder -cp $_TERRAME_GIT_DIR/build/scripts/linux/terrame-conf.* $_TERRAME_BUILD_BASE/solution +cp --verbose $_TERRAME_GIT_DIR/build/scripts/linux/terrame-conf.* $_TERRAME_BUILD_BASE/solution # Compile TerraLib ./terralib-conf.sh From ac2a8848f1fb23825fecffd5c85097862fde424c Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Wed, 12 Jul 2017 16:35:47 -0300 Subject: [PATCH 25/36] Reviewing jenkins. --- jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh index 36c81f8c..bd5fbc56 100755 --- a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh @@ -74,7 +74,6 @@ mkdir $_TERRAME_REPOSITORY_DIR $_TERRAME_TEST_DIR $_TERRAME_EXECUTION_DIR $_TERR # Copying TerraLib compilation scripts to TerraLib Solution folder cp --verbose $_TERRAME_GIT_DIR/build/scripts/linux/terralib-conf.* $_TERRALIB_BUILD_BASE/solution -cp --verbose $_TERRAME_GIT_DIR/jenkins/linux/terrame-build-linux-ubuntu-14.04.sh $_TERRALIB_BUILD_BASE/solution # Copying TerraME Git Repository to Test Repository Folder cp -r $_TERRAME_GIT_DIR/repository/* $_TERRAME_REPOSITORY_DIR @@ -93,6 +92,7 @@ cp --verbose $_TERRAME_GIT_DIR/jenkins/linux/terrame-syntaxcheck-cpp-linux-ubunt # Copying TerraME compilation scripts to TerraME Solution folder cp --verbose $_TERRAME_GIT_DIR/build/scripts/linux/terrame-conf.* $_TERRAME_BUILD_BASE/solution +cp --verbose $_TERRAME_GIT_DIR/jenkins/linux/terrame-build-linux-ubuntu-14.04.sh $_TERRAME_BUILD_BASE/solution # Compile TerraLib ./terralib-conf.sh From 3be3befd3dced625b43343a0fa1a73392e19dfb5 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Wed, 12 Jul 2017 17:00:39 -0300 Subject: [PATCH 26/36] Reviewing jenkins. --- jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh | 6 +++--- jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh index bd5fbc56..8284e0b3 100755 --- a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh @@ -54,9 +54,9 @@ echo "### TerraME ###" if [ ! -z "$ghprbActualCommit" ]; then mkdir -p $_TERRAME_GIT_DIR cd $_TERRAME_GIT_DIR - git init - git config remote.origin.url https://github.com/terrame/terrame.git - git fetch --tags --progress https://github.com/TerraME/terrame.git +refs/pull/*:refs/remotes/origin/pr/* --quiet > /dev/null +# git init +# git config remote.origin.url https://github.com/terrame/terrame.git +# git fetch --tags --progress https://github.com/TerraME/terrame.git +refs/pull/*:refs/remotes/origin/pr/* --quiet > /dev/null git checkout -f $ghprbActualCommit --quiet > /dev/null cd - else diff --git a/jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh index 124d99a8..ffe96807 100755 --- a/jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh @@ -61,7 +61,7 @@ if [ "$1" != "" ] && [ "$1" != "base" ]; then TERRAME_COMMANDS="-package $1" if [ ! -z "$ghprbActualCommit" ]; then # # Temp code to ensure unittest gis does not take too long to execute. Only CI trigger - echo -e '\ndirectory = {"functional", "shapefile", "postgis", "tif", "geojson", "asc", "wms", "nc"}' >> test.lua + echo -e '\ndirectory = {"functional", "shapefile", "postgis", "tif", "geojson", "asc", "wms", "nc"}' > test.lua fi fi From cd6bc8dc35495dad5638e91c9a8b846666321e38 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Thu, 13 Jul 2017 08:47:32 -0300 Subject: [PATCH 27/36] Reviewing jenkins. --- jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh index 8284e0b3..ab32f0db 100755 --- a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh @@ -54,9 +54,6 @@ echo "### TerraME ###" if [ ! -z "$ghprbActualCommit" ]; then mkdir -p $_TERRAME_GIT_DIR cd $_TERRAME_GIT_DIR -# git init -# git config remote.origin.url https://github.com/terrame/terrame.git -# git fetch --tags --progress https://github.com/TerraME/terrame.git +refs/pull/*:refs/remotes/origin/pr/* --quiet > /dev/null git checkout -f $ghprbActualCommit --quiet > /dev/null cd - else @@ -95,6 +92,7 @@ cp --verbose $_TERRAME_GIT_DIR/build/scripts/linux/terrame-conf.* $_TERRAME_BUIL cp --verbose $_TERRAME_GIT_DIR/jenkins/linux/terrame-build-linux-ubuntu-14.04.sh $_TERRAME_BUILD_BASE/solution # Compile TerraLib +cd $_TERRALIB_BUILD_BASE/solution ./terralib-conf.sh # Returns a TerraLib compilation execution code in order to Jenkins be able to set build status From 45cb91254c177532a4f8d19a536d07d721165889 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Thu, 13 Jul 2017 09:12:40 -0300 Subject: [PATCH 28/36] Reviewing jenkins. --- jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh index ab32f0db..8787dabd 100755 --- a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh @@ -54,6 +54,9 @@ echo "### TerraME ###" if [ ! -z "$ghprbActualCommit" ]; then mkdir -p $_TERRAME_GIT_DIR cd $_TERRAME_GIT_DIR + git init + git config remote.origin.url https://github.com/TerraME/terrame.git + git fetch --tags https://github.com/TerraME/terrame.git +refs/pull/*:refs/remotes/origin/pr/* --quiet > /dev/null git checkout -f $ghprbActualCommit --quiet > /dev/null cd - else From 729b10ba41a4a94f5c7608a8fc5959b4d23ab46e Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Thu, 13 Jul 2017 09:21:46 -0300 Subject: [PATCH 29/36] Reviewing jenkins. --- ...rrame-terralib-build-linux-ubuntu-14.04.sh | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh index 8787dabd..771057fc 100755 --- a/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-terralib-build-linux-ubuntu-14.04.sh @@ -42,29 +42,29 @@ ## ./terrame-terralib-build-linux-ubuntu-14.04.sh # -# Constants -_TERRALIB_BRANCH=release-5.2 +# # Constants +# _TERRALIB_BRANCH=release-5.2 -# Removing TerraLib Mod Binding Lua in order to re-generate folder if there is -rm -rf $_TERRALIB_OUT_DIR/terralib_mod_binding_lua $_TERRALIB_INSTALL_PATH $_TERRAME_GIT_DIR $_TERRAME_BUILD_BASE/solution -rm -rf $_TERRAME_REPOSITORY_DIR $_TERRAME_TEST_DIR $_TERRAME_EXECUTION_DIR +# # Removing TerraLib Mod Binding Lua in order to re-generate folder if there is +# rm -rf $_TERRALIB_OUT_DIR/terralib_mod_binding_lua $_TERRALIB_INSTALL_PATH $_TERRAME_GIT_DIR $_TERRAME_BUILD_BASE/solution +# rm -rf $_TERRAME_REPOSITORY_DIR $_TERRAME_TEST_DIR $_TERRAME_EXECUTION_DIR -echo "### TerraME ###" -# Identifying when PR to clone respective changes -if [ ! -z "$ghprbActualCommit" ]; then - mkdir -p $_TERRAME_GIT_DIR - cd $_TERRAME_GIT_DIR - git init - git config remote.origin.url https://github.com/TerraME/terrame.git - git fetch --tags https://github.com/TerraME/terrame.git +refs/pull/*:refs/remotes/origin/pr/* --quiet > /dev/null - git checkout -f $ghprbActualCommit --quiet > /dev/null - cd - -else - # Just clone - git clone https://github.com/terrame/terrame.git $_TERRAME_GIT_DIR --quiet - rm -rf $_TERRALIB_GIT_DIR $_TERRALIB_BUILD_BASE/solution/* - mkdir $_TERRALIB_GIT_DIR -fi +# echo "### TerraME ###" +# # Identifying when PR to clone respective changes +# if [ ! -z "$ghprbActualCommit" ]; then + # mkdir -p $_TERRAME_GIT_DIR + # cd $_TERRAME_GIT_DIR + # git init + # git config remote.origin.url https://github.com/TerraME/terrame.git + # git fetch --tags https://github.com/TerraME/terrame.git +refs/pull/*:refs/remotes/origin/pr/* --quiet > /dev/null + # git checkout -f $ghprbActualCommit --quiet > /dev/null + # cd - +# else + # # Just clone + # git clone https://github.com/terrame/terrame.git $_TERRAME_GIT_DIR --quiet + # rm -rf $_TERRALIB_GIT_DIR $_TERRALIB_BUILD_BASE/solution/* + # mkdir $_TERRALIB_GIT_DIR +# fi echo "### TerraLib ###" git clone -b $_TERRALIB_BRANCH https://gitlab.dpi.inpe.br/rodrigo.avancini/terralib.git $_TERRALIB_GIT_DIR --quiet @@ -95,7 +95,6 @@ cp --verbose $_TERRAME_GIT_DIR/build/scripts/linux/terrame-conf.* $_TERRAME_BUIL cp --verbose $_TERRAME_GIT_DIR/jenkins/linux/terrame-build-linux-ubuntu-14.04.sh $_TERRAME_BUILD_BASE/solution # Compile TerraLib -cd $_TERRALIB_BUILD_BASE/solution ./terralib-conf.sh # Returns a TerraLib compilation execution code in order to Jenkins be able to set build status From a3d40cc9b67fb6074e3c8118eec35c4d0faacc44 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Thu, 13 Jul 2017 10:02:12 -0300 Subject: [PATCH 30/36] Close #1922 - Ignore .tview on git/test/packages. --- .gitignore | 1 + test/packages/buildunnecfiles/data/myfile.tview | 0 test/packages/project/data/cabecadeboi.tview | 1 - test/packages/project/data/myproject.tview | 1 - test/packages/project/data/myproject2.tview | 1 - 5 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 test/packages/buildunnecfiles/data/myfile.tview delete mode 100644 test/packages/project/data/cabecadeboi.tview delete mode 100644 test/packages/project/data/myproject.tview delete mode 100644 test/packages/project/data/myproject2.tview diff --git a/.gitignore b/.gitignore index 218ec11f..da5667d4 100644 --- a/.gitignore +++ b/.gitignore @@ -40,5 +40,6 @@ installer/setup packages/*/doc test/packages/*/doc packages/*/data/*.tview +test/packages/**/*.tview !test/log/*.log terrameVersion.h diff --git a/test/packages/buildunnecfiles/data/myfile.tview b/test/packages/buildunnecfiles/data/myfile.tview deleted file mode 100644 index e69de29b..00000000 diff --git a/test/packages/project/data/cabecadeboi.tview b/test/packages/project/data/cabecadeboi.tview deleted file mode 100644 index d9b6915f..00000000 --- a/test/packages/project/data/cabecadeboi.tview +++ /dev/null @@ -1 +0,0 @@ -Cabeca de Boi databaseCarneiro, T.elevationCreated on TerraMEfile:///Applications/terrame.app/Contents/MacOS/packages/terralib/data/cabecadeboi-elevation.tifcellsCreated on TerraMEfile:///Users/pedro/github/terrame-pedro/test/packages/project/data/cabecadeboi.shpboxCreated on TerraMEfile:///Applications/terrame.app/Contents/MacOS/packages/terralib/data/cabecadeboi-box.shpelevationNOT_VISIBLELATIN1cabecadeboi-elevation.tif252042df-4402-499f-9aaf-d286868d51352311ABSTRACT_LAYER_RENDERER0boxNOT_VISIBLELATIN1cabecadeboi-boxc49e650d-37bb-482b-b926-e9d0a4549def2311ABSTRACT_LAYER_RENDERER0cellsNOT_VISIBLELATIN1cabecadeboia974f77d-8562-4901-911c-46e67b2a483b2311ABSTRACT_LAYER_RENDERER0 \ No newline at end of file diff --git a/test/packages/project/data/myproject.tview b/test/packages/project/data/myproject.tview deleted file mode 100644 index 17bef229..00000000 --- a/test/packages/project/data/myproject.tview +++ /dev/null @@ -1 +0,0 @@ -No titleNo authorsetoresCreated on TerraMEfile:///Applications/terrame.app/Contents/MacOS/packages/terralib/data/itaituba-census.shpcellsCreated on TerraMEfile:///Users/pedro/github/terrame-pedro/test/packages/project/data/itaituba.shpcellsNOT_VISIBLELATIN1itaitubaf30c3f25-3786-41d1-a9cf-18e50dc1b5ec29191ABSTRACT_LAYER_RENDERER0setoresNOT_VISIBLELATIN1itaituba-census8b1c1689-a9f3-44c3-9e48-f92a7bf0cd9429191ABSTRACT_LAYER_RENDERER0 \ No newline at end of file diff --git a/test/packages/project/data/myproject2.tview b/test/packages/project/data/myproject2.tview deleted file mode 100644 index 94c92de5..00000000 --- a/test/packages/project/data/myproject2.tview +++ /dev/null @@ -1 +0,0 @@ -No titleNo authorsetoresCreated on TerraMEfile:///Applications/terrame.app/Contents/MacOS/packages/terralib/data/itaituba-census.shpcellsCreated on TerraMEfile:///Users/pedro/github/terrame-pedro/test/packages/project/data/itaituba.shpcellsNOT_VISIBLELATIN1itaituba9e3867be-ed5f-48ab-9314-296ba900af3329191ABSTRACT_LAYER_RENDERER0setoresNOT_VISIBLELATIN1itaituba-census445dda0c-a55d-4b99-bebd-c8873e5b830f29191ABSTRACT_LAYER_RENDERER0 \ No newline at end of file From 0977da4a6244974bc8aa01493f5fcab5d772b94d Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Thu, 13 Jul 2017 12:02:24 -0300 Subject: [PATCH 31/36] Small correction #1922. --- test/packages/buildunnecfiles/data/myfile.tview | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/packages/buildunnecfiles/data/myfile.tview diff --git a/test/packages/buildunnecfiles/data/myfile.tview b/test/packages/buildunnecfiles/data/myfile.tview new file mode 100644 index 00000000..175079ac --- /dev/null +++ b/test/packages/buildunnecfiles/data/myfile.tview @@ -0,0 +1 @@ +No titleNo authorSampaCreated on TerraMEfile%3A%2F%2FD%3A%2Fterrame%2Fbuild-cmake%2Finstall%2Fbin%2Fpackages%2Fgis%2Fdata%2Ftest%2Fsampa.shpAnother_Sampa_CellsCreated on TerraMEfile%3A%2F%2Fd%3A%2Fterrame%2Ftests%2Fanother_sampa_cells.shpcells3Created on TerraMEfile%3A%2F%2Fd%3A%2Fterrame%2Ftests%2Fsampabox.shpSPCellsCreated on TerraMEfile%3A%2F%2Fd%3A%2Fterrame%2Ftests%2FcsSp.shpCBERSCreated on TerraMEfile%3A%2F%2FD%3A%2Fterrame%2Fbuild-cmake%2Finstall%2Fbin%2Fpackages%2Fgis%2Fdata%2Ftest%2Fcbers_rgb342_crop1.tifMGCreated on TerraMEfile%3A%2F%2FD%3A%2Fterrame%2Fbuild-cmake%2Finstall%2Fbin%2Fpackages%2Fgis%2Fdata%2Ftest%2FMG_cities.shpcells7Created on TerraMEfile%3A%2F%2Fd%3A%2Fterrame%2Ftests%2Fcells7.shpcells8Created on TerraMEfile%3A%2F%2Fd%3A%2Fterrame%2Ftests%2Fa%2520b%2Fcells8.shpSampa_CellsCreated on TerraMEfile%3A%2F%2Fd%3A%2Fterrame%2Ftests%2Fsampa_cells.shpSampa_Cells_BoxCreated on TerraMEfile%3A%2F%2Fd%3A%2Fterrame%2Ftests%2FSampa_Cells_Box.shpMG_CellsCreated on TerraMEfile%3A%2F%2Fd%3A%2Fterrame%2Ftests%2Fmg_cells.shpSampaNOT_VISIBLELATIN1sampa128328aa-1ad0-4186-9914-3d1cd14df59d4019+proj=longlat +ellps=GRS80 +no_defs ABSTRACT_LAYER_RENDERER0Sampa_CellsNOT_VISIBLELATIN1sampa_cellscda2c4ba-f9f0-4491-a6e3-11b5fcd7d8724019+proj=longlat +ellps=GRS80 +no_defs ABSTRACT_LAYER_RENDERER0Another_Sampa_CellsNOT_VISIBLELATIN1another_sampa_cells7e8ba44b-2fcc-4d25-a465-f7af68de87314036+proj=longlat +ellps=GRS67 +no_defs ABSTRACT_LAYER_RENDERER0MG_CellsNOT_VISIBLELATIN1mg_cellsfe5dfd0b-6e58-4672-930c-497843906c6e4036+proj=longlat +ellps=GRS67 +no_defs ABSTRACT_LAYER_RENDERER0CBERSNOT_VISIBLELATIN1cbers_rgb342_crop1.tifaad0e9aa-7379-4d5e-b83d-7b8c8ea4bc8f29182+proj=utm +zone=22 +south +ellps=GRS67 +towgs84=-57,1,-41,0,0,0,0 +units=m +no_defs ABSTRACT_LAYER_RENDERER0MGNOT_VISIBLELATIN1MG_citiesac5c4af3-e7e9-4dff-a0f4-dac77c1df02f4036+proj=longlat +ellps=GRS67 +no_defs ABSTRACT_LAYER_RENDERER0cells8NOT_VISIBLELATIN1cells8bd0ee970-5afe-46b4-a967-e083a1e5c1a14019+proj=longlat +ellps=GRS80 +no_defs ABSTRACT_LAYER_RENDERER0cells7NOT_VISIBLELATIN1cells7b8579f31-d2ef-4494-9920-125364eb52674019+proj=longlat +ellps=GRS80 +no_defs ABSTRACT_LAYER_RENDERER0SPCellsNOT_VISIBLELATIN1csSpa9b60478-1179-42ce-9648-b7cbd2f4fdfe4019+proj=longlat +ellps=GRS80 +no_defs ABSTRACT_LAYER_RENDERER0cells3NOT_VISIBLELATIN1sampabox9c2fa25c-69ee-479e-a83b-8cb9c6d82e544019+proj=longlat +ellps=GRS80 +no_defs ABSTRACT_LAYER_RENDERER0Sampa_Cells_BoxNOT_VISIBLELATIN1Sampa_Cells_Boxd67825ef-907a-4c52-b9d3-1e533d0a7d7f4019+proj=longlat +ellps=GRS80 +no_defs ABSTRACT_LAYER_RENDERER0 \ No newline at end of file From d6c7ad217e4feeb30992b0867282ec34b03951e8 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Thu, 13 Jul 2017 12:02:24 -0300 Subject: [PATCH 32/36] Small correction #1922. --- .gitignore | 1 + test/packages/buildunnecfiles/data/myfile.tview | 1 + 2 files changed, 2 insertions(+) create mode 100644 test/packages/buildunnecfiles/data/myfile.tview diff --git a/.gitignore b/.gitignore index da5667d4..63168d62 100644 --- a/.gitignore +++ b/.gitignore @@ -41,5 +41,6 @@ packages/*/doc test/packages/*/doc packages/*/data/*.tview test/packages/**/*.tview +!test/packages/buildunnecfiles/data/myfile.tview !test/log/*.log terrameVersion.h diff --git a/test/packages/buildunnecfiles/data/myfile.tview b/test/packages/buildunnecfiles/data/myfile.tview new file mode 100644 index 00000000..175079ac --- /dev/null +++ b/test/packages/buildunnecfiles/data/myfile.tview @@ -0,0 +1 @@ +No titleNo authorSampaCreated on TerraMEfile%3A%2F%2FD%3A%2Fterrame%2Fbuild-cmake%2Finstall%2Fbin%2Fpackages%2Fgis%2Fdata%2Ftest%2Fsampa.shpAnother_Sampa_CellsCreated on TerraMEfile%3A%2F%2Fd%3A%2Fterrame%2Ftests%2Fanother_sampa_cells.shpcells3Created on TerraMEfile%3A%2F%2Fd%3A%2Fterrame%2Ftests%2Fsampabox.shpSPCellsCreated on TerraMEfile%3A%2F%2Fd%3A%2Fterrame%2Ftests%2FcsSp.shpCBERSCreated on TerraMEfile%3A%2F%2FD%3A%2Fterrame%2Fbuild-cmake%2Finstall%2Fbin%2Fpackages%2Fgis%2Fdata%2Ftest%2Fcbers_rgb342_crop1.tifMGCreated on TerraMEfile%3A%2F%2FD%3A%2Fterrame%2Fbuild-cmake%2Finstall%2Fbin%2Fpackages%2Fgis%2Fdata%2Ftest%2FMG_cities.shpcells7Created on TerraMEfile%3A%2F%2Fd%3A%2Fterrame%2Ftests%2Fcells7.shpcells8Created on TerraMEfile%3A%2F%2Fd%3A%2Fterrame%2Ftests%2Fa%2520b%2Fcells8.shpSampa_CellsCreated on TerraMEfile%3A%2F%2Fd%3A%2Fterrame%2Ftests%2Fsampa_cells.shpSampa_Cells_BoxCreated on TerraMEfile%3A%2F%2Fd%3A%2Fterrame%2Ftests%2FSampa_Cells_Box.shpMG_CellsCreated on TerraMEfile%3A%2F%2Fd%3A%2Fterrame%2Ftests%2Fmg_cells.shpSampaNOT_VISIBLELATIN1sampa128328aa-1ad0-4186-9914-3d1cd14df59d4019+proj=longlat +ellps=GRS80 +no_defs ABSTRACT_LAYER_RENDERER0Sampa_CellsNOT_VISIBLELATIN1sampa_cellscda2c4ba-f9f0-4491-a6e3-11b5fcd7d8724019+proj=longlat +ellps=GRS80 +no_defs ABSTRACT_LAYER_RENDERER0Another_Sampa_CellsNOT_VISIBLELATIN1another_sampa_cells7e8ba44b-2fcc-4d25-a465-f7af68de87314036+proj=longlat +ellps=GRS67 +no_defs ABSTRACT_LAYER_RENDERER0MG_CellsNOT_VISIBLELATIN1mg_cellsfe5dfd0b-6e58-4672-930c-497843906c6e4036+proj=longlat +ellps=GRS67 +no_defs ABSTRACT_LAYER_RENDERER0CBERSNOT_VISIBLELATIN1cbers_rgb342_crop1.tifaad0e9aa-7379-4d5e-b83d-7b8c8ea4bc8f29182+proj=utm +zone=22 +south +ellps=GRS67 +towgs84=-57,1,-41,0,0,0,0 +units=m +no_defs ABSTRACT_LAYER_RENDERER0MGNOT_VISIBLELATIN1MG_citiesac5c4af3-e7e9-4dff-a0f4-dac77c1df02f4036+proj=longlat +ellps=GRS67 +no_defs ABSTRACT_LAYER_RENDERER0cells8NOT_VISIBLELATIN1cells8bd0ee970-5afe-46b4-a967-e083a1e5c1a14019+proj=longlat +ellps=GRS80 +no_defs ABSTRACT_LAYER_RENDERER0cells7NOT_VISIBLELATIN1cells7b8579f31-d2ef-4494-9920-125364eb52674019+proj=longlat +ellps=GRS80 +no_defs ABSTRACT_LAYER_RENDERER0SPCellsNOT_VISIBLELATIN1csSpa9b60478-1179-42ce-9648-b7cbd2f4fdfe4019+proj=longlat +ellps=GRS80 +no_defs ABSTRACT_LAYER_RENDERER0cells3NOT_VISIBLELATIN1sampabox9c2fa25c-69ee-479e-a83b-8cb9c6d82e544019+proj=longlat +ellps=GRS80 +no_defs ABSTRACT_LAYER_RENDERER0Sampa_Cells_BoxNOT_VISIBLELATIN1Sampa_Cells_Boxd67825ef-907a-4c52-b9d3-1e533d0a7d7f4019+proj=longlat +ellps=GRS80 +no_defs ABSTRACT_LAYER_RENDERER0 \ No newline at end of file From 8412add3224d121a131b6c0a6651424eae51e672 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Thu, 13 Jul 2017 12:11:17 -0300 Subject: [PATCH 33/36] Small correction #1922. --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 63168d62..da5667d4 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,5 @@ packages/*/doc test/packages/*/doc packages/*/data/*.tview test/packages/**/*.tview -!test/packages/buildunnecfiles/data/myfile.tview !test/log/*.log terrameVersion.h From 435831ac53e3450f1a56ead07111c3fe4662dbfa Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Thu, 13 Jul 2017 12:19:15 -0300 Subject: [PATCH 34/36] Small correction #1922. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index da5667d4..63168d62 100644 --- a/.gitignore +++ b/.gitignore @@ -41,5 +41,6 @@ packages/*/doc test/packages/*/doc packages/*/data/*.tview test/packages/**/*.tview +!test/packages/buildunnecfiles/data/myfile.tview !test/log/*.log terrameVersion.h From 76b49ef65d3402aee77a42ccf7ab4262fbd49185 Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Thu, 13 Jul 2017 14:17:50 -0300 Subject: [PATCH 35/36] Rollback #1922. --- .gitignore | 2 -- test/packages/project/data/cabecadeboi.tview | 0 test/packages/project/data/myproject.tview | 0 test/packages/project/data/myproject2.tview | 0 4 files changed, 2 deletions(-) create mode 100644 test/packages/project/data/cabecadeboi.tview create mode 100644 test/packages/project/data/myproject.tview create mode 100644 test/packages/project/data/myproject2.tview diff --git a/.gitignore b/.gitignore index 63168d62..218ec11f 100644 --- a/.gitignore +++ b/.gitignore @@ -40,7 +40,5 @@ installer/setup packages/*/doc test/packages/*/doc packages/*/data/*.tview -test/packages/**/*.tview -!test/packages/buildunnecfiles/data/myfile.tview !test/log/*.log terrameVersion.h diff --git a/test/packages/project/data/cabecadeboi.tview b/test/packages/project/data/cabecadeboi.tview new file mode 100644 index 00000000..e69de29b diff --git a/test/packages/project/data/myproject.tview b/test/packages/project/data/myproject.tview new file mode 100644 index 00000000..e69de29b diff --git a/test/packages/project/data/myproject2.tview b/test/packages/project/data/myproject2.tview new file mode 100644 index 00000000..e69de29b From 791e6a1383a23d4e93b07fa1cf0745589c9d6ebe Mon Sep 17 00:00:00 2001 From: Rodrigo Avancini Date: Thu, 13 Jul 2017 14:47:34 -0300 Subject: [PATCH 36/36] Reviewing jenkins. --- jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh b/jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh index ffe96807..2cac38af 100755 --- a/jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh +++ b/jenkins/linux/terrame-unittest-linux-ubuntu-14.04.sh @@ -59,10 +59,10 @@ TERRAME_COMMANDS="" # Extra commands if package is gis if [ "$1" != "" ] && [ "$1" != "base" ]; then TERRAME_COMMANDS="-package $1" - if [ ! -z "$ghprbActualCommit" ]; then +# if [ ! -z "$ghprbActualCommit" ]; then # # Temp code to ensure unittest gis does not take too long to execute. Only CI trigger - echo -e '\ndirectory = {"functional", "shapefile", "postgis", "tif", "geojson", "asc", "wms", "nc"}' > test.lua - fi +# echo -e '\ndirectory = {"functional", "shapefile", "postgis", "tif", "geojson", "asc", "wms", "nc"}' > test.lua +# fi fi # Executing unittest