From 3535a8d2d9691cd60c1571fc76878b865d50174e Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Nov 30 2015 00:22:28 +0000 Subject: Enable tests --- diff --git a/nodejs-millstone-internet.patch b/nodejs-millstone-internet.patch new file mode 100644 index 0000000..fbb2594 --- /dev/null +++ b/nodejs-millstone-internet.patch @@ -0,0 +1,417 @@ +commit 71526cbb0cbf25c38bc3f1772fd5cc06badc8159 +Author: Tom Hughes +Date: Mon Nov 30 00:10:47 2015 +0000 + + Patch out tests that rely on internet access + +diff --git a/test/corrupt-zip.test.js b/test/corrupt-zip.test.js +index ff6b211..aa349b8 100644 +--- a/test/corrupt-zip.test.js ++++ b/test/corrupt-zip.test.js +@@ -14,44 +14,3 @@ var existsSync = require('fs').existsSync || require('path').existsSync; + beforeEach(function(){ + rm(path.join(__dirname, '/tmp/millstone-test')); + }) +- +- +-// NOTE: watch out, this zip has both a csv and shape in it and uses +-// non-ascii characters - idea being to be the basis for other tests +-// https://github.com/mapbox/millstone/issues/85 +-it('correctly handles re-downloading a zip that is invalid in its cached state', function(done) { +- var mml = JSON.parse(fs.readFileSync(path.join(__dirname, 'corrupt-zip/project.mml'))); +- +- var cache = '/tmp/millstone-test'; +- var options = { +- mml: mml, +- base: path.join(__dirname, 'corrupt-zip'), +- cache: cache +- }; +- +- try { +- fs.mkdirSync(options.cache, 0777); +- } catch (e) {} +- +- // write bogus data over the zip archive to simulate a corrupt cache +- if (!existsSync('/tmp/millstone-test/29f2b277-Cle%CC%81ment/')) fs.mkdirSync('/tmp/millstone-test/29f2b277-Cle%CC%81ment/') +- fs.writeFileSync('/tmp/millstone-test/29f2b277-Cle%CC%81ment/29f2b277-Cle%CC%81ment.zip',''); +- +- millstone.resolve(options, function(err, resolved) { +- assert.equal(err,undefined,err); +- assert.equal(resolved.Stylesheet[0].id, 'style.mss'); +- assert.equal(resolved.Stylesheet[0].data, '#polygon { }'); +- var expected = [ +- { +- "name": "corrupt-zip", +- "Datasource": { +- "file": path.join(__dirname, 'corrupt-zip/layers/corrupt-zip/29f2b277-Cle%CC%81ment.shp'), +- "type": "shape" +- }, +- "srs": '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' +- } +- ]; +- assert.deepEqual(resolved.Layer, expected); +- done(); +- }); +-}); +diff --git a/test/image-noext.test.js b/test/image-noext.test.js +index 0fe4416..aa349b8 100644 +--- a/test/image-noext.test.js ++++ b/test/image-noext.test.js +@@ -14,26 +14,3 @@ var existsSync = require('fs').existsSync || require('path').existsSync; + beforeEach(function(){ + rm(path.join(__dirname, '/tmp/millstone-test')); + }) +- +-it('correctly handles images with no extension', function(done) { +- var mml = JSON.parse(fs.readFileSync(path.join(__dirname, 'image-noext/project.mml'))); +- +- var cache = '/tmp/millstone-test'; +- var options = { +- mml: mml, +- base: path.join(__dirname, 'image-noext'), +- cache: cache +- }; +- +- try { +- fs.mkdirSync(options.cache, 0777); +- } catch (e) {} +- +- millstone.resolve(options, function(err, resolved) { +- assert.equal(err,undefined,err); +- assert.equal(resolved.Stylesheet[0].id, 'style.mss'); +- assert.equal(resolved.Stylesheet[0].data, "Map {background-image: url('/tmp/millstone-test/2b2cf79a-images/2b2cf79a-images.jpeg');}"); +- assert.ok(existsSync('/tmp/millstone-test/2b2cf79a-images/2b2cf79a-images.jpeg')); +- done(); +- }); +-}); +diff --git a/test/macosx-zipped.test.js b/test/macosx-zipped.test.js +index 231eff9..0d91b4f 100644 +--- a/test/macosx-zipped.test.js ++++ b/test/macosx-zipped.test.js +@@ -14,28 +14,3 @@ var existsSync = require('fs').existsSync || require('path').existsSync; + before(function(){ + rm('/tmp/millstone-test'); + }); +- +-it('correctly handles mac os x zipped archives with the lame __MACOSX/ subfolder', function(done) { +- var mml = JSON.parse(fs.readFileSync(path.join(__dirname, 'macosx-zipped/project.mml'))); +- +- var options = { +- mml: mml, +- base: path.join(__dirname, 'macosx-zipped'), +- cache: '/tmp/millstone-test' +- }; +- +- millstone.resolve(options, function(err, resolved) { +- assert.equal(err,undefined,err); +- assert.deepEqual(resolved.Layer, [ +- { +- "name": "points", +- "Datasource": { +- "file": path.join(__dirname, 'macosx-zipped/layers/points/9afe4795-crashes_2007_2009.shp'), +- "type": "shape" +- }, +- "srs": "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" +- } +- ]); +- done(); +- }); +-}); +\ No newline at end of file +diff --git a/test/markers.test.js b/test/markers.test.js +index 7d7e8fc..1e585b7 100644 +--- a/test/markers.test.js ++++ b/test/markers.test.js +@@ -13,60 +13,3 @@ var existsSync = require('fs').existsSync || require('path').existsSync; + before(function(){ + rm('/tmp/millstone-test'); + }); +- +- +-it('correctly localizes remote image/svg files', function(done) { +- var mml = JSON.parse(fs.readFileSync(path.join(__dirname, 'markers/project.mml'))); +- +- var options = { +- mml: mml, +- base: path.join(__dirname, 'markers'), +- cache: '/tmp/millstone-test' +- }; +- +- millstone.resolve(options, function(err, resolved) { +- assert.equal(err,undefined,err); +- assert.equal(resolved.Stylesheet[0].id, 'style.mss'); +- assert.equal(resolved.Stylesheet[0].data, '// a url like https:example.com in the comments\n#points { one/marker-file: url(\'/tmp/millstone-test/e33af80e-Cup_of_coffee.svg\'); two/marker-file: url(\'/tmp/millstone-test/e33af80e-Cup_of_coffee.svg\'); four/marker-file: url("/tmp/millstone-test/c953e0d1-pin-m-fast-food+AA0000.png"); five/marker-file:url("/tmp/millstone-test/7b9b9979-fff&text=x/7b9b9979-fff&text=x.png"); }\n'); +- assert.deepEqual(resolved.Layer, [ +- { +- "name": "points", +- "Datasource": { +- "file": path.join(__dirname, 'markers/layers/points.csv'), +- "type": "csv" +- }, +- "srs": "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" +- } +- ]); +- done(); +- }); +-}); +- +-it('correctly localizes zipped json', function(done) { +- var mml = JSON.parse(fs.readFileSync(path.join(__dirname, 'zipped-json/project.mml'))); +- +- var options = { +- mml: mml, +- base: path.join(__dirname, 'zipped-json'), +- cache: '/tmp/millstone-test' +- }; +- +- millstone.resolve(options, function(err, resolved) { +- assert.equal(err,undefined,err); +- assert.equal(resolved.Stylesheet[0].id, 'style.mss'); +- assert.equal(resolved.Stylesheet[0].data, '#polygon { }'); +- var expected = [ +- { +- "name": "polygons-zipped", +- "Datasource": { +- "file": path.join(__dirname, 'zipped-json/layers/polygons-zipped/7e482cc8-polygons.json.json'), +- "type": "ogr", +- "layer_by_index":0 +- }, +- "srs": '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' +- } +- ]; +- assert.deepEqual(resolved.Layer, expected); +- done(); +- }); +-}); +diff --git a/test/multi-shape-zip.test.js b/test/multi-shape-zip.test.js +index 20d3789..aa349b8 100644 +--- a/test/multi-shape-zip.test.js ++++ b/test/multi-shape-zip.test.js +@@ -14,35 +14,3 @@ var existsSync = require('fs').existsSync || require('path').existsSync; + beforeEach(function(){ + rm(path.join(__dirname, '/tmp/millstone-test')); + }) +- +-// https://github.com/mapbox/millstone/issues/99 +-it('correctly handles a zipfile containing multiple shapefiles without corrupting data', function(done) { +- var mml = JSON.parse(fs.readFileSync(path.join(__dirname, 'multi-shape-zip/project.mml'))); +- +- var cache = '/tmp/millstone-test'; +- var options = { +- mml: mml, +- base: path.join(__dirname, 'multi-shape-zip'), +- cache: cache +- }; +- +- try { +- fs.mkdirSync(options.cache, 0777); +- } catch (e) {} +- +- millstone.resolve(options, function(err, resolved) { +- assert.equal(err,undefined,err); +- var expected = [ +- { +- "name": "multi-shape-zip", +- "Datasource": { +- "file": path.join(__dirname, 'multi-shape-zip/layers/multi-shape-zip/134ecf39-PLATES_PlateBoundary_ArcGIS.shp'), +- "type": "shape" +- }, +- "srs": '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' +- } +- ]; +- assert.deepEqual(resolved.Layer, expected); +- done(); +- }); +-}); +diff --git a/test/test.js b/test/test.js +index 272fb71..4c128a7 100644 +--- a/test/test.js ++++ b/test/test.js +@@ -125,187 +125,6 @@ describe('isRelative', function() { + + }); + +- +-it('correctly caches remote files', function(done) { +- var mml = JSON.parse(fs.readFileSync(path.join(__dirname, 'cache/cache.mml'))); +- +- // Set absolute paths dynamically at test time. +- mml.Layer[2].Datasource.file = path.join(__dirname, 'data/absolute.json'); +- mml.Layer[3].Datasource.file = path.join(__dirname, 'data/absolute/absolute.shp'); +- +- var options = { +- mml: mml, +- base: path.join(__dirname, 'cache'), +- cache: path.join(__dirname, 'tmp') +- }; +- +- // Cleanup from old test runs +- try { +- fs.unlinkSync(path.join(__dirname, 'cache/layers/absolute-json.json')); +- rm(path.join(__dirname, 'cache/layers/absolute-shp')); +- fs.unlinkSync(path.join(__dirname, 'cache/layers/polygons.json')); +- fs.unlinkSync(path.join(__dirname, 'cache/layers/csv.csv')); +- rm(path.join(__dirname, 'cache/layers/zip-no-ext')); +- } catch (e) {} +- +- // Copy "cached" files to mock request headers +- try { +- fs.mkdirSync(options.cache, 0777); +- fs.mkdirSync(path.join(options.cache, '9368bdd9-zip_no_ext'),0777); +- } catch(e) { console.log("mkdirSync failed with: " + e ); } +- var files = ['9368bdd9-zip_no_ext/9368bdd9-zip_no_ext', '9368bdd9-zip_no_ext/.9368bdd9-zip_no_ext']; +- for (var i = 0; i < files.length; i++) { +- var newFile = fs.createWriteStream(path.join(options.cache, files[i])); +- var oldFile = fs.createReadStream(path.join(__dirname, 'data', files[i])); +- oldFile.pipe(newFile); +- } +- +- millstone.resolve(options, function(err, resolved) { +- if (err) throw err; +- assert.deepEqual(resolved.Stylesheet, [ +- { id:'cache-inline.mss', data:'Map { background-color:#fff }' }, +- { id:'cache-local.mss', data: '#world { polygon-fill: #fff }\n' }, +- { id:'cache-url.mss', data:'#world { line-width:1; }\n' } +- ]); +- var expected = [ +- { +- "name": "local-json", +- "Datasource": { +- "file": path.join(__dirname, 'cache/layers/local.json'), +- "type": "ogr", +- "layer_by_index":0 +- }, +- "srs": "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" +- }, +- { +- "name": "local-shp", +- "Datasource": { +- "file": path.join(__dirname, 'cache/layers/local/local.shp'), +- "type": "shape" +- }, +- "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" +- }, +- { +- "name": "absolute-json", +- "Datasource": { +- "file": path.join(__dirname, 'cache/layers/absolute-json.json'), +- "type": "ogr", +- "layer_by_index":0 +- }, +- "srs": "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" +- }, +- { +- "name": "absolute-shp", +- "Datasource": { +- "file": path.join(__dirname, 'cache/layers/absolute-shp/absolute.shp'), +- "type": "shape" +- }, +- "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" +- }, +- { +- "name": "polygons", +- "Datasource": { +- "file": path.join(__dirname, 'cache/layers/polygons.json'), +- "type": "ogr", +- "layer_by_index":0 +- }, +- "srs": "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" +- }, +- { +- "name": "stations", +- "Datasource": { +- "file": path.join(__dirname, 'cache/layers/stations/87c0c757-stations.shp'), +- "type": "shape" +- }, +- "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" +- }, +- { +- "name": "csv", +- "Datasource": { +- "file": path.join(__dirname, 'cache/layers/csv.csv'), +- "type": "csv" +- }, +- "srs": "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" +- }, +- { +- "name": 'sqlite', +- "Datasource": { +- "file": path.join(__dirname, 'cache/layers/countries.sqlite'), +- "type": 'sqlite', +- "table": 'countries', +- }, +- "srs": "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" +- }, +- { +- "name": 'sqlite-attach', +- "Datasource": { +- "file": path.join(__dirname, 'cache/layers/countries.sqlite'), +- "type": 'sqlite', +- "table": 'countries', +- "attachdb": 'data@' + path.join(__dirname, 'cache/layers/data.sqlite'), +- }, +- "srs": "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" +- }, +- { +- "name": 'zip-no-ext', +- "Datasource": { +- "file": path.join(__dirname, 'cache/layers/zip-no-ext/9368bdd9-zip_no_ext.shp'), +- "type": 'shape' +- }, +- "srs": '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' +- } +- ]; +- for (var i=0;i<=10;i++) { +- assert.deepEqual(resolved.Layer[i], expected[i]); +- } +- +- // Check that URLs are downloaded and symlinked. +- assert.ok(existsSync(path.join(__dirname, 'tmp/5c505ff4-polygons.json'))); +- assert.ok(existsSync(path.join(__dirname, 'tmp/87c0c757-stations/87c0c757-stations.shp'))); +- assert.ok(fs.lstatSync(path.join(__dirname, 'cache/layers/polygons.json')).isSymbolicLink()); +- assert.ok(fs.lstatSync(path.join(__dirname, 'cache/layers/stations')).isDirectory()); +- assert.equal( +- fs.readFileSync(path.join(__dirname, 'tmp/5c505ff4-polygons.json'), 'utf8'), +- fs.readFileSync(path.join(__dirname, 'cache/layers/polygons.json'), 'utf8') +- ); +- assert.equal( +- fs.readFileSync(path.join(__dirname, 'tmp/87c0c757-stations/87c0c757-stations.shp'), 'utf8'), +- fs.readFileSync(path.join(__dirname, 'cache/layers/stations/87c0c757-stations.shp'), 'utf8') +- ); +- +- // Check that absolute paths are symlinked correctly. +- assert.ok(fs.lstatSync(path.join(__dirname, 'cache/layers/absolute-json.json')).isSymbolicLink()); +- assert.ok(fs.lstatSync(path.join(__dirname, 'cache/layers/absolute-shp')).isDirectory()); +- assert.equal( +- fs.readFileSync(path.join(__dirname, 'cache/layers/absolute-json.json'), 'utf8'), +- fs.readFileSync(path.join(__dirname, 'data/absolute.json'), 'utf8') +- ); +- assert.equal( +- fs.readFileSync(path.join(__dirname, 'cache/layers/absolute-shp/absolute.shp'), 'utf8'), +- fs.readFileSync(path.join(__dirname, 'data/absolute/absolute.shp'), 'utf8') +- ); +- +- millstone.flush({ +- layer: 'stations', +- url: 'http://mapbox.github.com/millstone/test/stations.zip', +- base: options.base, +- cache: options.cache +- }, function(err) { +- assert.equal(err, undefined); +- +- // Polygons layer and cache should still exist. +- assert.ok(existsSync(path.join(__dirname, 'cache/layers/polygons.json'))); +- assert.ok(existsSync(path.join(__dirname, 'tmp/5c505ff4-polygons.json'))); +- +- // Stations layer and cache should be gone. +- assert.ok(!existsSync(path.join(__dirname, 'layers/stations'))); +- assert.ok(!existsSync(path.join(__dirname, 'tmp/87c0c757-stations'))); +- +- done(); +- }); +- }); +-}); +- + describe('util', function() { + + var copypath = path.join(__dirname, 'copypath'); diff --git a/nodejs-millstone.spec b/nodejs-millstone.spec index 99aca48..f3676a8 100644 --- a/nodejs-millstone.spec +++ b/nodejs-millstone.spec @@ -1,19 +1,20 @@ -%global enable_tests 0 +%bcond_with internet Name: nodejs-millstone Version: 0.6.16 -Release: 3%{?dist} +Release: 4%{?dist} Summary: Prepares data sources in an MML file for consumption in Mapnik License: BSD URL: https://github.com/mapbox/millstone -Source0: http://registry.npmjs.org/millstone/-/millstone-%{version}.tgz +Source0: https://registry.npmjs.org/millstone/-/millstone-%{version}.tgz +# Remove tests that need internet access +Patch0: nodejs-millstone-internet.patch BuildArch: noarch ExclusiveArch: %{nodejs_arches} noarch BuildRequires: nodejs-packaging -%if 0%{?enable_tests} BuildRequires: npm(mocha) BuildRequires: npm(generic-pool) BuildRequires: npm(mime) @@ -22,7 +23,6 @@ BuildRequires: npm(srs) >= 0.4.1 BuildRequires: npm(step) BuildRequires: npm(underscore) BuildRequires: npm(zipfile) >= 0.5.5 -%endif %description As of carto 0.2.0, the Carto module expects all data sources and @@ -36,6 +36,9 @@ flush can be used to clear the cache of a specific resource. %prep %setup -q -n package +%if ! %{with internet} +%patch0 -p1 +%endif %nodejs_fixdep generic-pool "^2.0.3" %nodejs_fixdep mkdirp "^0.3.5" %nodejs_fixdep request "^2.25.0" @@ -55,19 +58,21 @@ cp -pr package.json bin lib %{buildroot}/%{nodejs_sitelib}/millstone %nodejs_symlink_deps -%if 0%{?enable_tests} %check %nodejs_symlink_deps --check -NODE_PATH=lib %{nodejs_sitelib}/mocha/bin/mocha -R spec --timeout 10000 -%endif +%{nodejs_sitelib}/mocha/bin/mocha -R spec --timeout 10000 %files -%doc LICENSE README.md CHANGELOG.md architecture.txt +%doc README.md CHANGELOG.md architecture.txt +%license LICENSE %{nodejs_sitelib}/millstone %changelog +* Mon Nov 30 2015 Tom Hughes - 0.6.16-4 +- Enable tests + * Sun Nov 29 2015 Tom Hughes - 0.6.16-3 - Update srs dependency