8000 WIP: add E2E test suite unrelated to docs examples by caitp · Pull Request #9557 · angular/angular.js · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

WIP: add E2E test suite unrelated to docs examples #9557

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
WIP: statSync can throw.
  • Loading branch information
caitp committed Oct 20, 2014
commit d71f56d23db99e5454f28edb30bc255e92d131fb
6 changes: 5 additions & 1 deletion test/e2e/tests/sample/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<!DOCTYPE html>
<html ng-app="test">
<p>Hello!</p>
<div ng-controller="TestCtrl">
<p>{{text}}</p>
</div>

<script src="angular.js"></script>
<script src="script.js"></script>
</html>
3 changes: 0 additions & 3 deletions test/e2e/tests/sample/sample.json

This file was deleted.

4 changes: 4 additions & 0 deletions test/e2e/tests/sample/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
angular.module("test", []).
controller("TestCtrl", function($scope) {
$scope.text = "Hello, world!";
});
4 changes: 3 additions & 1 deletion test/e2e/tools/fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var fs = require('fs');
var path = require('path');
var $ = require('cheerio');
var util = require('./util');

var root = path.resolve(__dirname, '..');
var tests = path.resolve(root, 'tests');
Expand Down Expand Up @@ -36,7 +37,8 @@ function generateFixture(test, query) {
else if (src === 'angular.js' && angular === null) angular = script;
if (firstScript === null) firstScript = script;
if (src) {
if (fs.statSync(path.resolve(build, src))) {
var s = util.stat(path.resolve(build, src));
if (s && s.isFile()) {
$(script).attr('src', rewriteAngularSrc(src, query));
}
}
Expand Down
43 changes: 29 additions & 14 deletions test/e2e/tools/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,35 @@ var url = require('url');
var root = path.resolve(__dirname, '..');
var tests = path.resolve(root, 'tests');

module.exports = {
testExists: function(testname) {
testname = path.resolve(tests, testname);
return fs.statSync(testname).isDirectory();
},

rewriteTestFile: function(testname, testfile) {
var i = 0;
while (testfile[i] === '/') ++i;
testfile = testfile.slice(i);
var stat = fs.statSync(path.resolve(tests, testname, testfile));
if (stat && stat.isFile() || stat.isDirectory()) {
return ['/test/e2e/tests', testname, testfile].join('/');
function stat(path) {
try {
return fs.statSync(path);
} catch (e) {
// Ignore ENOENT.
if (e.code !== 'ENOENT') {
throw e;
}
return false;
}
}

function testExists(testname) {
var s = stat(path.resolve(tests, testname));
return s && s.isDirectory();
}

function rewriteTestFile(testname, testfile) {
var i = 0;
while (testfile[i] === '/') ++i;
testfile = testfile.slice(i);
var s = stat(path.resolve(tests, testname, testfile));
if (s && s.isFile() || s.isDirectory()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parenthesis missing: s && (s.isFile() || s.isDirectory())

return ['/test/e2e/tests', testname, testfile].join('/');
}
return false;
}

module.exports = {
stat: stat,
testExists: testExists,
rewriteTestFile: rewriteTestFile
};
0