]> source.dussan.org Git - svg.js.git/commitdiff
halt dev of chrome base solution
authordotnetCarpenter <jon.ronnenberg@gmail.com>
Sat, 8 Oct 2016 19:18:25 +0000 (17:18 -0200)
committerdotnetCarpenter <jon.ronnenberg@gmail.com>
Sat, 8 Oct 2016 19:18:25 +0000 (17:18 -0200)
.config/chrome_linux.js [new file with mode: 0644]
.config/karma.conf.js [new file with mode: 0644]
.config/pretest.js [new file with mode: 0644]
dist/svg.js
karma.conf.js [deleted file]
package.json
spec/pretest.js [deleted file]

diff --git a/.config/chrome_linux.js b/.config/chrome_linux.js
new file mode 100644 (file)
index 0000000..5820a19
--- /dev/null
@@ -0,0 +1,42 @@
+'use strict'
+
+if(process.platform === 'linux') {
+       const child_process = require('child_process') 
+       const exec = child_process.exec
+       const execSync = bind2(child_process.execSync, { encoding: 'utf8' })//spawnSync
+       const browsers = ['google-chrome', 'chromium-browser']
+
+       const findBrowser = msg => {
+               console.log(msg)
+               const browserString = /\/(.*)$/
+               const browser = msg.match(browserString)
+               console.log(browsers)
+               if(browsers[browser]) browsers[browser] = true
+       }
+
+       const tryCompose = (f, parameter) => {
+               //FIXME:
+               const x = f.splice(0, 1)[0]
+               if(Array.isArray(f) && f.length > 0) return tryCompose(f, parameter)
+               //
+
+               try {
+                       return x(parameter)
+               }
+               catch(e) {
+                       console.warn(e.message)
+               }
+       }
+       
+       tryCompose([findBrowser, execSync], 'which google-chrome')
+       //findBrowser(execSync('which chromium-browser'))
+
+       if(browsers[0]) return
+       if(!browsers[0] && browsers[1]) exec('export CHROME_BIN=chromium-browser')
+       if(browsers.every(b => !b)) console.warn('You need to install either Chrome or Chromium to run the test suite.')
+       
+}
+
+function bind2(f, bound) {
+       return (parameter) => f(parameter, bound)
+}
\ No newline at end of file
diff --git a/.config/karma.conf.js b/.config/karma.conf.js
new file mode 100644 (file)
index 0000000..2a7dae4
--- /dev/null
@@ -0,0 +1,91 @@
+// Karma configuration
+// Generated on Tue Oct 04 2016 13:53:46 GMT+0200 (CEST)
+
+module.exports = function(config) {
+  config.set({
+
+    // base path that will be used to resolve all patterns (eg. files, exclude)
+    basePath: '../',
+
+
+    // frameworks to use
+    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
+    frameworks: ['jasmine'],
+
+
+    // list of files / patterns to load in the browser
+    files: [
+      '.config/pretest.js',
+      {
+        pattern: 'spec/fixture.css',
+        included: false,
+        served: true
+      },
+      {
+        pattern: 'spec/fixture.svg',
+        included: false,
+        served: true
+      },
+      'dist/svg.js',
+      'spec/spec/**/*.js'
+    ],
+
+
+    // list of files to exclude
+    exclude: [],
+
+
+    // preprocess matching files before serving them to the browser
+    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
+    preprocessors: {},
+
+
+    // test results reporter to use
+    // possible values: 'dots', 'progress'
+    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
+    reporters: ['progress'],
+
+
+    // web server port
+    port: 9876,
+
+
+    // enable / disable colors in the output (reporters and logs)
+    colors: true,
+
+
+    // level of logging
+    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
+    logLevel: config.LOG_INFO,
+
+
+    // enable / disable watching file and executing tests whenever any file changes
+    autoWatch: false,
+
+
+    // start these browsers
+    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
+    browsers: ['Chrome'],
+
+
+    customLaunchers: {
+        Chrome_travis_ci: {
+            base: 'Chrome',
+            flags: ['--no-sandbox']
+        }
+    },
+
+
+    // Continuous Integration mode
+    // if true, Karma captures browsers, runs the tests and exits
+    singleRun: false,
+
+    // Concurrency level
+    // how many browser should be started simultaneous
+    concurrency: Infinity
+  })
+
+  if(process.env.TRAVIS){
+    config.browsers = ['Chrome_travis_ci'];
+  }
+}
diff --git a/.config/pretest.js b/.config/pretest.js
new file mode 100644 (file)
index 0000000..1ccaf89
--- /dev/null
@@ -0,0 +1,20 @@
+'use strict'
+
+function get(uri) {
+       var xhr = new XMLHttpRequest()
+       xhr.open('GET', uri, false)
+       xhr.send()
+       if(xhr.status !== 200)
+               console.error('SVG.js fixture could not be loaded. Tests will fail.')
+       return xhr.responseText
+}
+
+function main() {
+       var style = document.createElement("style")
+       document.head.appendChild(style)
+       style.sheet.insertRule( get('/base/spec/fixture.css'), 0 )
+
+       document.body.innerHTML = get('/base/spec/fixture.svg')
+}
+
+main()
index 595da340c12e6c827417ebb9facaf238189b2624..4cda13a6c98e12539bcad88dc7c914f4ab10c22a 100644 (file)
@@ -6,7 +6,7 @@
 * @copyright Wout Fierens <wout@woutfierens.com>
 * @license MIT
 *
-* BUILT: Tue Oct 04 2016 15:03:44 GMT+0200 (CEST)
+* BUILT: Wed Oct 05 2016 15:27:51 GMT+0200 (CEST)
 */
 (function(root, factory) {
   if (typeof define === 'function' && define.amd) {
diff --git a/karma.conf.js b/karma.conf.js
deleted file mode 100644 (file)
index e2ecc37..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-// Karma configuration
-// Generated on Tue Oct 04 2016 13:53:46 GMT+0200 (CEST)
-
-module.exports = function(config) {
-  config.set({
-
-    // base path that will be used to resolve all patterns (eg. files, exclude)
-    basePath: '',
-
-
-    // frameworks to use
-    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
-    frameworks: ['jasmine'],
-
-
-    // list of files / patterns to load in the browser
-    files: [
-      'spec/pretest.js',
-      {
-        pattern: 'spec/fixture.css',
-        included: false,
-        served: true
-      },
-      {
-        pattern: 'spec/fixture.svg',
-        included: false,
-        served: true
-      },
-      'dist/svg.js',
-      'spec/spec/**/*.js'
-    ],
-
-
-    // list of files to exclude
-    exclude: [],
-
-
-    // preprocess matching files before serving them to the browser
-    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
-    preprocessors: {},
-
-
-    // test results reporter to use
-    // possible values: 'dots', 'progress'
-    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
-    reporters: ['progress'],
-
-
-    // web server port
-    port: 9876,
-
-
-    // enable / disable colors in the output (reporters and logs)
-    colors: true,
-
-
-    // level of logging
-    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
-    logLevel: config.LOG_INFO,
-
-
-    // enable / disable watching file and executing tests whenever any file changes
-    autoWatch: false,
-
-
-    // start these browsers
-    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
-    browsers: ['Chrome'],
-
-
-    customLaunchers: {
-        Chrome_travis_ci: {
-            base: 'Chrome',
-            flags: ['--no-sandbox']
-        }
-    },
-
-
-    // Continuous Integration mode
-    // if true, Karma captures browsers, runs the tests and exits
-    singleRun: false,
-
-    // Concurrency level
-    // how many browser should be started simultaneous
-    concurrency: Infinity
-  })
-
-  if(process.env.TRAVIS){
-    config.browsers = ['Chrome_travis_ci'];
-  }
-}
index 0158eae49147a82f77839ecf47d0656fcf889697..cee6ee668c711a4e5c45c46626af968f3d0d82e2 100644 (file)
@@ -50,7 +50,8 @@
   "typings": "./svg.js.d.ts",
   "scripts": {
     "build": "gulp",
-    "test": "karma start karma.conf.js --single-run"
+    "pretest": "node .config/chrome_linux.js",
+    "test": "karma start .config/karma.conf.js --single-run"
   },
   "devDependencies": {
     "del": "^2.2.0",
diff --git a/spec/pretest.js b/spec/pretest.js
deleted file mode 100644 (file)
index 1ccaf89..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-'use strict'
-
-function get(uri) {
-       var xhr = new XMLHttpRequest()
-       xhr.open('GET', uri, false)
-       xhr.send()
-       if(xhr.status !== 200)
-               console.error('SVG.js fixture could not be loaded. Tests will fail.')
-       return xhr.responseText
-}
-
-function main() {
-       var style = document.createElement("style")
-       document.head.appendChild(style)
-       style.sheet.insertRule( get('/base/spec/fixture.css'), 0 )
-
-       document.body.innerHTML = get('/base/spec/fixture.svg')
-}
-
-main()