Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c551f64
Code coverage 1st attempt
digiguru Jul 10, 2013
271e93e
Moved coverage ref to under qunit
digiguru Jul 10, 2013
cadd828
Made tests run
digiguru Jul 10, 2013
10f7ca5
Allowed * to represent a file for code coverage
digiguru Jul 10, 2013
762852b
Ooops - faulty variable
digiguru Jul 10, 2013
59099da
Added cachebusting
digiguru Jul 10, 2013
946dc9a
Thats was a bad commit, sorry
digiguru Jul 10, 2013
8b19e39
Sadly cache busting in this mannor is incompatible with blanket io
digiguru Jul 10, 2013
8953ef4
Changed from github file to a CDN for blanket JS
digiguru Jul 11, 2013
8aab320
Merge branch 'master' of https://github.com/digiguru/brackets-xunit
digiguru Jul 12, 2013
aacf586
Resolved merge
digiguru Jul 12, 2013
4e95c7b
Done
digiguru Jul 12, 2013
7d85e6a
Added cache busting for files covered by code coverage
digiguru Jul 12, 2013
e610be3
Added a package file
digiguru Jul 12, 2013
dd1f003
Fixed failing test
digiguru Aug 14, 2013
d0e048d
Qunit now runs test on save and displays in a sliding window.
digiguru Aug 20, 2013
7fcf951
Don't include tests run
digiguru Aug 20, 2013
bc42cd3
Now with inline jasmine runner
digiguru Aug 20, 2013
3732f3c
Simplified the crazy faile waitings by rolling them into a deferred.
digiguru Aug 20, 2013
268b582
Made tests run on open. Fixed YUI tests
digiguru Aug 21, 2013
09f898d
Updated JSON
digiguru Aug 21, 2013
bcf12d9
Merge pull request #1 from digiguru/master
digiguru Aug 21, 2013
fb4943c
Removed references to depricated modules.
digiguru Nov 15, 2013
deaf29a
Changes for Directory.Create
digiguru Nov 15, 2013
5efc889
Renamed all references, and fixed depricated APIs
digiguru Nov 15, 2013
1b956e9
Update version and compatitibilty numbers.
digiguru Nov 15, 2013
defff9e
Fix for Jasmine
digiguru Dec 3, 2013
e2153f2
Merge pull request #1 from brackets-xunit/FileSystemAPI
digiguru Dec 3, 2013
618cd80
Removed symlinks (tempory bugfix for new registery)
digiguru Dec 6, 2013
cdd6f6d
Refactored code to split qunit from other tests.
digiguru Dec 6, 2013
e71cff5
Refactored the deferred objects so they read a little less like pyram…
digiguru Dec 6, 2013
ee864ad
Merge pull request #2 from brackets-xunit/FileSystemAPI
digiguru Dec 6, 2013
4b02afe
Error in CreateDirectory - sorry :(
digiguru Dec 6, 2013
a31b950
Slight cleanup - makes the code easier to read (i think). Added qunit…
digiguru Dec 8, 2013
253e5a1
Refactored Jasmine code to new format
digiguru Dec 8, 2013
92b0757
YUI refactored to new style
digiguru Dec 8, 2013
04e157d
Clearing out unsued spacing
digiguru Dec 26, 2013
98de4bd
Merge pull request #3 from brackets-xunit/FileSystemAPI
digiguru Feb 16, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
*~
*.DS_Store
*.DS_Store
tests/main.spec/require.js

tests/main.spec/main.spec8.js

tests/main.spec/main.spec9.js

tests/main.spec/main.spec7.js

tests/main.spec/main.spec6.js

tests/main.spec/jasmine-html.js

tests/main.spec/jasmine.css

tests/main.spec/jasmine.js

tests/main.spec/main.spec.html

tests/main.spec/main.spec0.js

tests/main.spec/main.spec1.js

tests/main.spec/main.spec2.js

tests/main.spec/main.spec3.js

tests/main.spec/main.spec4.js

tests/main.spec/main.spec5.js

samples/jasmine_test/*

samples/qunit_test/*

samples/yui_test/*
112 changes: 112 additions & 0 deletions FileProxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* brackets-xunit - a brackets extension to run various unit test frameworks
*/

/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global brackets, define, $, Mustache */
define(function (require, exports) {
'use strict';

var FileSystem = brackets.getModule("filesystem/FileSystem"),
FileUtils = brackets.getModule("file/FileUtils"),
getFileName = function (path) {
var startIndex = path.lastIndexOf("/") || path.lastIndexOf("!") || 0;
return path.substring(startIndex + 1);
},
getFileContents = function (readPath) {
var dfd = new $.Deferred();
require([readPath], function (text) {
dfd.resolve(text);
});
return dfd.promise();
},
copyFile = function (readPath, directory, data) {
//Should make a "Copy files"?
var dfd = new $.Deferred(),
me = this,
writeFile = FileSystem.getFileForPath(directory + "/" + me.getFileName(readPath)),
contents;

me.getFileContents(readPath)
.then(function(text) {
contents = text;
if(data) {
contents = Mustache.render(contents, data);
}
return FileUtils.writeText(writeFile, contents);
}).done(function() {
dfd.resolve(contents);
});

return dfd.promise();

},
saveText = function (inputText, writePath) {
var writeFile = FileSystem.getFileForPath(writePath);
return FileUtils.writeText(writeFile, inputText);
},
getTestFileInfo = function (entry, contents) {
var fileName = this.getFileName(entry.fullPath),
fileNameNoExt = fileName.substring(0, fileName.lastIndexOf('.')),
dirPath = entry.fullPath.substring(0, entry.fullPath.lastIndexOf('/') + 1);
return {
originalPath: dirPath,
testPath: dirPath + fileNameNoExt,
contents: contents
};
},
createDirectory = function (path) {
var dfd = new $.Deferred();
FileSystem.getDirectoryForPath(path).create(dfd.resolve, dfd.fail);
return dfd.promise();
},
parseIncludes = function (contents, dirPath, cache) {
var includes = '';
if (contents && contents.match(/brackets-xunit:\s*includes=/)) {
var includestr = contents.match(/brackets-xunit:\s*includes=[A-Za-z0-9,\._\-\/\*]*/)[0];
includestr = includestr.substring(includestr.indexOf('=') + 1);

var includedata = includestr.split(',');
var i;
for (i = 0; i < includedata.length; i++) {
var includeFile = includedata[i],
codeCoverage = '',
cacheBuster = cache ? '?u=' + cache : '';
if (includeFile[includeFile.length - 1] === "*") {
includeFile = includeFile.substring(0, includeFile.length - 1);
codeCoverage = ' data-cover';
//cacheBuster = '';
}
includes = includes + '<script src="' + dirPath + includeFile + cacheBuster + '"' + codeCoverage + '></script>\n';
}
}
return includes;
};
exports.getFileName = getFileName;
exports.getFileContents = getFileContents;
exports.copyFile = copyFile;
exports.saveText = saveText;
exports.getTestFileInfo = getTestFileInfo;
exports.createDirectory = createDirectory;
exports.parseIncludes = parseIncludes;
});
117 changes: 117 additions & 0 deletions MyStatusBar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* brackets-xunit - a brackets extension to run various unit test frameworks
*/

/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global brackets, define, $, Mustache */
define(function (require, exports) {
'use strict';

var _collapsed = false,
jsXunitTemplate = require("text!templates/panel.html?u=1"),
Resizer = brackets.getModule("utils/Resizer"),
StatusBar = brackets.getModule("widgets/StatusBar"),
PanelManager = brackets.getModule("view/PanelManager"),
$xunitResults = {};

function toggleCollapsed(collapsed) {
if (collapsed === undefined) {
collapsed = !_collapsed;
}

_collapsed = collapsed;
if (_collapsed) {
Resizer.hide($xunitResults);
} else {
//if (JSLINT.errors && JSLINT.errors.length) {
Resizer.show($xunitResults);
//}
}
}

function statusPassed(message) {
StatusBar.updateIndicator("XUNIT", true, "xunit-failed", 'Failed');
$("#XUNIT").text(message);
}
function statusFailed(message) {
StatusBar.updateIndicator("XUNIT", true, "xunit-complete", 'Complete');
$("#XUNIT").text(message);
}
function statusRunning(message) {
message = message || "running";
StatusBar.updateIndicator("XUNIT", true, "xunit-process", 'Running');
$("#XUNIT").text(message);
}
function statusCoverage(message) {
StatusBar.updateIndicator("XUNITCOVERAGE", true, "xunit-complete", 'Complete');
$("#XUNITCOVERAGE").text(message);
}


function initializePanel() {
console.log("initializePanel");
var xunitHtml = Mustache.render(jsXunitTemplate, {}),
xunitPanel = PanelManager.createBottomPanel("xunit.results", $(xunitHtml), 100);
$xunitResults = $("#xunit-results");

var xunitStatusHtml = $("<div id=\"xunit-status\" title=\"No xunit errors\">No tests</div>", {}),
xunitCoverageHtml = $("<div id=\"xunit-coverage\" title=\"No coverage\">No coverage</div>", {});
$(xunitStatusHtml).insertBefore("#jslint-status");
$(xunitCoverageHtml).insertBefore("#jslint-status");
StatusBar.addIndicator("XUNIT", $("#xunit-status"));
StatusBar.addIndicator("XUNITCOVERAGE", $("#xunit-coverage"));
StatusBar.updateIndicator("XUNIT", true, "xunit-disabled", 'Xunit');
StatusBar.updateIndicator("XUNITCOVERAGE", true, "xunit-disabled", 'Xunit');

//panel.show();

$("#xunit-results .close").click(function () {
toggleCollapsed(true);
});

$("#XUNIT, #XUNITCOVERAGE").click(function () {
/*if (!$(this).hasClass('xunit-disabled')) {
if (_xunit_panel_visible) {
//Resizer.hide($karmaResults);
_xunit_panel_visible = false;
//} else {
//showPanel();

}
}*/
toggleCollapsed();
});
toggleCollapsed(true);
}
function setReportWindow(url) {
$xunitResults.find("#winReport").attr("src", url);
}

exports.initializePanel = initializePanel;
exports.toggleCollapsed = toggleCollapsed;
exports.statusPassed = statusPassed;
exports.statusFailed = statusFailed;
exports.statusRunning = statusRunning;
exports.statusCoverage = statusCoverage;
exports.setReportWindow = setReportWindow;
});
104 changes: 104 additions & 0 deletions RunnerQunit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */
/*global define, $, setTimeout, clearTimeout */
define(function (require, exports, module) {
"use strict";




// Runs a QUnit test
function run(entry) {
var entry = ProjectManager.getSelectedItem();
if (entry === undefined) {
entry = DocumentManager.getCurrentDocument().file;
}
var dir = entry.fullPath.substring(0, entry.fullPath.lastIndexOf('/') + 1),
dirEntry = new NativeFileSystem.DirectoryEntry(dir),
fname = DocumentManager.getCurrentDocument().filename,
contents = DocumentManager.getCurrentDocument().getText(),
testName = entry.fullPath.substring(entry.fullPath.lastIndexOf("/") + 1),
testBase = testName.substring(0, testName.lastIndexOf('.')),
qunitReportEntry = new NativeFileSystem.FileEntry(dir + testBase + '/qUnitReport.html'),
useCodeCoverage = true,
includes = parseIncludes(contents, dir, new Date().getTime());
var data = { filename : entry.name,
title : 'QUnit test - ' + entry.name,
includes : includes + "<script src='qunit.js'></script>",
templatedir : moduledir,
contents : contents,
coverage: (useCodeCoverage ? "<script src='qunit.blanket.js'></script>" : "")
};
var template = require("text!templates/qunit.html");
var html = Mustache.render(template, data),
// write generated test report to file on disk
qunitJs = require("text!thirdparty/test/qunit.js"),
qunitJsEntry = new NativeFileSystem.FileEntry(dir + testBase + "/qunit.js"),
qunitJsBlanket = require("text!templates/qunit.blanket.js"),
qunitJsBlanketEntry = new NativeFileSystem.FileEntry(dir + testBase + "/qunit.blanket.js");
dirEntry.getDirectory(dir + testBase, {create: true}, function () {
FileUtils.writeText(qunitJsEntry, qunitJs).done(function () {
FileUtils.writeText(qunitJsBlanketEntry, qunitJsBlanket).done(function () {
FileUtils.writeText(qunitReportEntry, html).done(function () {
// launch new window with generated report
var urlToReport = qunitReportEntry.fullPath + (useCodeCoverage ? "?coverage=true" : ""),
$frame = $xunitResults.find("#winReport"),
inter;
window.reportComplete = function(result) {
if(result.status === "failed") {
statusFailed(result.message);
toggleCollapsed(false);
} else {
statusPassed(result.message);
}
};
window.reportUpdate = function(result) {
console.log("update", result);
statusRunning(result.message);
};
window.coverageComplete = function(result) {
statusCoverage(result.message);
};
$frame.attr("src", urlToReport);

});
});
});
});
}

function setDocumentToWatch(newDocumentToWatch) {
_cancelCompilation();

if (documentToWatch) {
$(documentToWatch).off("change.ContinuousCompilationController");
documentToWatch.releaseRef();
}

if (!newDocumentToWatch) {
documentToWatch = null;
} else {
if (newDocumentToWatch.getLanguage()._name !== "JavaScript") {
documentToWatch = null;
} else {
documentToWatch = newDocumentToWatch;
}
}

if (!documentToWatch) {
ContinuousCompilationController.setCodeMirrorToAddHighlightsTo(null);
ContinuousCompilationController.compileCodeAndDisplayErrors(null);
} else {
documentToWatch.addRef();
$(documentToWatch).on("change.ContinuousCompilationController", function () {
_runDelayedCompilationForDocument(documentToWatch);
});

documentToWatch._ensureMasterEditor();
ContinuousCompilationController.setCodeMirrorToAddHighlightsTo(documentToWatch._masterEditor._codeMirror);
_runDelayedCompilationForDocument(documentToWatch);
}
}


exports.setDocumentToWatch = setDocumentToWatch;
});
Loading