Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Code coverage report

  • Loading branch information...
commit 9e7f4d203139e23972ac55aa660ad447dc8e563b 1 parent 52b228f
@arikon arikon authored
View
2  .gitignore
@@ -4,3 +4,5 @@
*.log
node_modules/
test-make-temp/
+lib-cov/
+coverage.html
View
42 GNUmakefile
@@ -0,0 +1,42 @@
+BEM = ./bin/bem
+MOCHA = ./node_modules/.bin/mocha
+JSCOV = ./node_modules/visionmedia-jscoverage/jscoverage
+
+.PHONY: all
+all:
+
+.PHONY: test
+test:
+ $(MOCHA)
+
+.PHONY: lib-cov
+lib-cov:
+ -rm -rf lib-cov
+ $(JSCOV) lib lib-cov
+
+.PHONY: test-cover
+test-cover: lib-cov test
+ COVER=1 $(MOCHA) --reporter html-cov > coverage.html
+ @echo
+ @echo Open ./coverage.html file in your browser
+
+.PHONY: test
+tests:
+ -rm -rf tests/level4
+ $(BEM) create level -o tests -l simple -T css -T js -t xsl level4
+ $(BEM) create block -l tests/level4 -T css -T js -t xsl first-block
+ $(BEM) create elem -l tests/level4 -b first-block -T css -T js -t xsl elem1
+ $(BEM) create mod -l tests/level4 -b first-block mod1
+ $(BEM) create mod -l tests/level4 -b first-block -v 1 mod1
+
+ -rm -rf tests/level5
+ $(BEM) create level -o tests -l tests/level2/.bem/level.js -t css -t css1 -n js -n js1 level5
+ $(BEM) create block -l tests/level5 first-block
+ $(BEM) create elem -l tests/level5 -b second-block -n css1 elem2
+ $(BEM) create mod -l tests/level5 -b second-block mod2
+ $(BEM) create mod -l tests/level5 -b second-block -e elem2 -v 221 -v 222 mod22
+
+ $(BEM) -d tests/decl.js -o tests -n bla -t deps.js -t ie.css -l tests/level1 -l tests/level2 -l tests/level3 -l tests/level4 -l tests/level5
+ $(BEM) build -d tests/bla.deps.js -o tests -n bla -t css -t js -l tests/level1 -l tests/level2 -l tests/level3 -l tests/level4 -l tests/level5
+
+ $(BEM) decl subtract -o tests/deps-subtract.deps.js -d tests/deps-subtract-1.deps.js -d tests/deps-subtract-2.deps.js
View
25 Makefile
@@ -1,25 +0,0 @@
-.PHONY: test
-test:
- -rm -rf tests/level4
- ./bin/bem create level -o tests -l simple -T css -T js -t xsl level4
- ./bin/bem create block -l tests/level4 -T css -T js -t xsl first-block
- ./bin/bem create elem -l tests/level4 -b first-block -T css -T js -t xsl elem1
- ./bin/bem create mod -l tests/level4 -b first-block mod1
- ./bin/bem create mod -l tests/level4 -b first-block -v 1 mod1
-
- -rm -rf tests/level5
- ./bin/bem create level -o tests -l tests/level2/.bem/level.js -t css -t css1 -n js -n js1 level5
- ./bin/bem create block -l tests/level5 first-block
- ./bin/bem create elem -l tests/level5 -b second-block -n css1 elem2
- ./bin/bem create mod -l tests/level5 -b second-block mod2
- ./bin/bem create mod -l tests/level5 -b second-block -e elem2 -v 221 -v 222 mod22
-
- ./bin/bem build -d tests/decl.js -o tests -n bla -t deps.js -t ie.css -l tests/level1 -l tests/level2 -l tests/level3 -l tests/level4 -l tests/level5
- ./bin/bem build -d tests/bla.deps.js -o tests -n bla -t css -t js -l tests/level1 -l tests/level2 -l tests/level3 -l tests/level4 -l tests/level5
-
- ./bin/bem decl subtract -o tests/deps-subtract.deps.js -d tests/deps-subtract-1.deps.js -d tests/deps-subtract-2.deps.js
-
-RSYNC_ARIKON=arikon.dev.tools.yandex.net:/home/arikon/projects/bem/bem-tools
-.PHONY: rsync-arikon
-rsync-arikon:
- rsync -az -e ssh --delete ./ $(RSYNC_ARIKON)
View
5 lib/util.js
@@ -290,12 +290,13 @@ exports.arrayReverse = function(arr) {
};
exports.getBemTechPath = function(name) {
- var bemTechs = PATH.unixToOs('bem/lib/techs'),
+ var bemLib = process.env.COVER? 'bem/lib-cov/' : 'bem/lib/';
+ bemTechs = PATH.unixToOs(bemLib + 'techs'),
path = PATH.join(bemTechs, name);
if(exports.isRequireable(path)) {
return path;
}
- return PATH.unixToOs('bem/lib/tech');
+ return PATH.unixToOs(bemLib + 'tech');
};
exports.stripModuleExt = function(path) {
View
4 package.json
@@ -44,11 +44,13 @@
"winston": ">= 0.5.0"
},
"devDependencies": {
+ "visionmedia-jscoverage": "*",
"mocha": "~1.0.0",
"chai": "~1.0.3"
},
"scripts": {
- "test": "./node_modules/.bin/mocha"
+ "test": "make test",
+ "test-cover": "make test-cover"
},
"engines": {
"node": ">= 0.6.0"
View
4 test/bem-make.js
@@ -6,8 +6,8 @@ var assert = require('assert'),
_ = require('underscore'),
QFS = require('q-fs'),
- BEMUTIL = require('../lib/util'),
- BEM = require('../lib/coa').api,
+ BEMUTIL = require(process.env.COVER? '../lib-cov/util' : '../lib/util'),
+ BEM = require(process.env.COVER? '../lib-cov/coa' : '../lib/coa').api,
projectPath = PATH.resolve('./test/data/make/project'),
referencePath = PATH.resolve('./test/data/make/reference-result'),
View
2  test/deps.js
@@ -1,5 +1,5 @@
var assert = require('chai').assert,
- DEPS = require('../lib/techs/deps.js.js'),
+ DEPS = require(process.env.COVER? '../lib-cov/techs/deps.js.js' : '../lib/techs/deps.js.js'),
Deps = DEPS.Deps,
DepsItem = DEPS.DepsItem;
View
13 test/legacy-tech.js
@@ -1,6 +1,6 @@
var assert = require('chai').assert,
- Tech = require('../lib/legacy-tech.js').Tech,
- PATH = require('../lib/path');
+ Tech = require(process.env.COVER? '../lib-cov/legacy-tech' : '../lib/legacy-tech').Tech,
+ PATH = require(process.env.COVER? '../lib-cov/path' : '../lib/path');
/**
* Mocha BDD interface.
@@ -15,9 +15,12 @@ var assert = require('chai').assert,
describe('legacy tech', function() {
+ var bemLib = process.env.COVER? 'bem/lib-cov/' : 'bem/lib/',
+ lib = process.env.COVER? '../lib-cov/' : '../lib/';
+
describe("new Tech('../lib/legacy-techs/css')", function() {
- var tech = new Tech(require.resolve('../lib/legacy-techs/css'));
+ var tech = new Tech(require.resolve(lib + 'legacy-techs/css'));
it(".getTechName() equals to 'css'", function() {
assert.equal(tech.getTechName(), 'css');
@@ -39,7 +42,7 @@ describe('legacy tech', function() {
describe("new Tech('../lib/legacy-techs/default', 'def')", function() {
- var tech = new Tech(require.resolve('../lib/legacy-techs/default'), 'def');
+ var tech = new Tech(require.resolve(lib + 'legacy-techs/default'), 'def');
it(".getTechName() equals to 'def'", function() {
assert.equal(tech.getTechName(), 'def');
@@ -54,7 +57,7 @@ describe('legacy tech', function() {
});
it(".getTechRelativePath() resolves to 'bem/lib/legacy-techs/default'", function() {
- assert.equal(tech.getTechRelativePath(), PATH.unixToOs('bem/lib/legacy-techs/default'));
+ assert.equal(tech.getTechRelativePath(), PATH.unixToOs(bemLib + 'legacy-techs/default'));
});
});
View
6 test/level.js
@@ -1,8 +1,8 @@
var assert = require('chai').assert,
UTIL = require('util'),
- PATH = require('../lib/path'),
- U = require('../lib/util'),
- createLevel = require('../lib/level').createLevel;
+ PATH = require(process.env.COVER? '../lib-cov/path' : '../lib/path'),
+ U = require(process.env.COVER? '../lib-cov/util' : '../lib/util'),
+ createLevel = require(process.env.COVER? '../lib-cov/level' : '../lib/level').createLevel;
/**
* Mocha BDD interface.
View
2  test/path.js
@@ -1,5 +1,5 @@
var assert = require('chai').assert,
- PATH = require('../lib/path');
+ PATH = require(process.env.COVER? '../lib-cov/path' : '../lib/path');
/**
* Mocha BDD interface.
View
22 test/tech.js
@@ -1,7 +1,7 @@
var Q = require('q'),
assert = require('chai').assert,
- PATH = require('../lib/path'),
- createTech = require('../lib/tech').createTech;
+ PATH = require(process.env.COVER? '../lib-cov/path' : '../lib/path'),
+ createTech = require(process.env.COVER? '../lib-cov/tech' : '../lib/tech').createTech;
/**
* Mocha BDD interface.
@@ -16,13 +16,15 @@ var Q = require('q'),
function testBaseTech(techPath, techAlias) {
- var techName = PATH.basename(techPath),
+ var bemLib = process.env.COVER? 'bem/lib-cov/' : 'bem/lib/',
+ techName = PATH.basename(techPath),
absTechPath = require.resolve(PATH.resolve(__dirname, techPath)),
- relTechPath = techPath;
+ relTechPath = techPath,
+ re = process.env.COVER? /^\.\.\/lib-cov\// : /^\.\.\/lib\//;
// NOTE: techPath will be always in unix format
- if(/^\.\.\/lib\//.test(techPath)) {
- relTechPath = techPath.replace(/^\.\.\/lib\//, 'bem/lib/');
+ if(re.test(techPath)) {
+ relTechPath = techPath.replace(re, bemLib);
// default tech identified by '' relative path
if(techName == 'tech') relTechPath = '';
@@ -148,9 +150,11 @@ function testBaseTech(techPath, techAlias) {
describe('tech', function() {
- testBaseTech('../lib/techs/js');
- testBaseTech('../lib/techs/css');
- testBaseTech('../lib/tech', 'def');
+ var lib = process.env.COVER? '../lib-cov/' : '../lib/';
+
+ testBaseTech(lib + 'techs/js');
+ testBaseTech(lib + 'techs/css');
+ testBaseTech(lib + 'tech', 'def');
testBaseTech('./data/techs/test.js');
});
View
10 test/util.js
@@ -1,6 +1,6 @@
var assert = require('chai').assert,
- U = require('../lib/util'),
- PATH = require('../lib/path');
+ U = require(process.env.COVER? '../lib-cov/util' : '../lib/util'),
+ PATH = require(process.env.COVER? '../lib-cov/path' : '../lib/path');
/**
* Mocha BDD interface.
@@ -15,14 +15,16 @@ var assert = require('chai').assert,
describe('util', function() {
+ var bemLib = process.env.COVER? 'bem/lib-cov/' : 'bem/lib/';
+
describe('getBemTechPath()', function() {
it("'css' resolves to 'bem/lib/techs/css'", function() {
- assert.equal(U.getBemTechPath('css'), PATH.unixToOs('bem/lib/techs/css'));
+ assert.equal(U.getBemTechPath('css'), PATH.unixToOs(bemLib + 'techs/css'));
});
it("'custom' resolves to 'bem/lib/tech'", function() {
- assert.equal(U.getBemTechPath('custom'), PATH.unixToOs('bem/lib/tech'));
+ assert.equal(U.getBemTechPath('custom'), PATH.unixToOs(bemLib + 'tech'));
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.