summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMike Morris <michael.patrick.morris@gmail.com>2014-07-07 17:25:15 -0700
committerMike Morris <michael.patrick.morris@gmail.com>2014-07-07 17:25:15 -0700
commit6f112849bebbacedb9c5fed51c349c386ae9738c (patch)
tree79da070516fae713fff01865cf9d91476a50a3a3 /bin
parent9b61e39ef33463ffa7cb2e987c39565f092e1890 (diff)
downloadqtlocation-mapboxgl-6f112849bebbacedb9c5fed51c349c386ae9738c.tar.gz
first attempt at testing malformed style parsing
Diffstat (limited to 'bin')
-rwxr-xr-xbin/build-style.js1
-rw-r--r--bin/fuzz-style.js24
-rw-r--r--bin/package.json11
3 files changed, 30 insertions, 6 deletions
diff --git a/bin/build-style.js b/bin/build-style.js
index c69fcb8b40..9b931c8112 100755
--- a/bin/build-style.js
+++ b/bin/build-style.js
@@ -4,7 +4,6 @@
var path = require('path');
var fs = require('fs');
var mkdirp = require('./mkdirp');
-var name = 'style';
var data = JSON.stringify(require(path.join(process.cwd(), process.argv[2])));
var out_path = path.join(process.argv[3], 'bin/style.min.js');
diff --git a/bin/fuzz-style.js b/bin/fuzz-style.js
new file mode 100644
index 0000000000..8dae68e4a3
--- /dev/null
+++ b/bin/fuzz-style.js
@@ -0,0 +1,24 @@
+#!/usr/bin/env node
+'use strict';
+
+var fuzzer = require('fuzzer');
+var path = require('path');
+var fs = require('fs');
+var mkdirp = require('./mkdirp');
+var json = require(path.join(process.cwd(), process.argv[2]));
+
+fuzzer.seed(0);
+
+json.constants = Object.keys(json.constants).reduce(function(obj, key, index) {
+ var value = json.constants[key];
+ if (typeof value === 'string') {
+ obj[key] = fuzzer.mutate.string(value);
+ }
+ return obj;
+}, {});
+
+var data = JSON.stringify(json);
+
+var out_path = path.join(process.argv[3], 'bin/style-fuzzed.min.js');
+mkdirp.sync(path.dirname(out_path));
+fs.writeFileSync(out_path, data);
diff --git a/bin/package.json b/bin/package.json
index 4431471e99..0eefafd26a 100644
--- a/bin/package.json
+++ b/bin/package.json
@@ -1,7 +1,8 @@
{
- "name": "llmr-native",
- "version": "0.0.1",
- "dependencies": {
- "glsl-optimizer": "git://github.com/kkaefer/glsl-optimizer.git#amalgamation"
- }
+ "name": "llmr-native",
+ "version": "0.0.1",
+ "dependencies": {
+ "fuzzer": "^0.2.0",
+ "glsl-optimizer": "git://github.com/kkaefer/glsl-optimizer.git#amalgamation"
+ }
}