Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
caf73290
...
caf73290c1995111ef59fc2124815c0b2d51c6e8
authored
2013-03-10 15:31:07 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'master' into skip
2 parents
939cee41
583d1e7b
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
5 deletions
.jshintignore
bin/bootstrap.js
modules/casper.js
modules/tester.js
tests/clitests/error/syntax.js
tests/clitests/runtests.py
.jshintignore
View file @
caf7329
...
...
@@ -5,3 +5,4 @@ modules/querystring.js
samples/**
tests/**
tmp
./*.js
...
...
bin/bootstrap.js
View file @
caf7329
...
...
@@ -69,12 +69,16 @@ CasperError.prototype = Object.getPrototypeOf(new Error());
}
function
__die
(
message
)
{
if
(
message
)
{
console
.
error
(
message
);
}
phantom
.
exit
(
1
);
}
function
__terminate
(
message
)
{
if
(
message
)
{
console
.
log
(
message
);
}
phantom
.
exit
();
}
...
...
@@ -90,13 +94,17 @@ CasperError.prototype = Object.getPrototypeOf(new Error());
}
})(
phantom
.
version
);
// Hooks in default phantomjs error handler to print a hint when a possible
// casperjs command misuse is detected.
// Hooks in default phantomjs error handler
phantom
.
onError
=
function
onPhantomError
(
msg
,
trace
)
{
phantom
.
defaultErrorHandler
.
apply
(
phantom
,
arguments
);
// print a hint when a possible casperjs command misuse is detected
if
(
msg
.
indexOf
(
"ReferenceError: Can't find variable: casper"
)
===
0
)
{
console
.
error
(
'Hint: you may want to use the `casperjs test` command.'
);
}
// exits on syntax error
if
(
msg
.
indexOf
(
'SyntaxError: Parse error'
)
===
0
)
{
__die
();
}
};
// Patching fs
...
...
modules/casper.js
View file @
caf7329
...
...
@@ -375,7 +375,6 @@ Casper.prototype.checkStep = function checkStep(self, onComplete) {
}
}
catch
(
error
)
{
self
.
emit
(
'complete.error'
,
error
);
throw
error
;
}
};
...
...
@@ -1387,7 +1386,6 @@ Casper.prototype.runStep = function runStep(step) {
}
}
catch
(
err
)
{
this
.
emit
(
'step.error'
,
err
);
throw
err
;
}
if
(
!
skipLog
)
{
this
.
emit
(
'step.complete'
,
stepResult
);
...
...
modules/tester.js
View file @
caf7329
...
...
@@ -285,7 +285,7 @@ Tester.prototype.assertTrue = function assert(subject, message, context) {
}
},
context
||
{});
if
(
!
result
.
success
&&
result
.
doThrow
)
{
throw
new
AssertionError
(
message
,
result
);
throw
new
AssertionError
(
message
||
result
.
standard
,
result
);
}
return
this
.
processAssertionResult
(
result
);
};
...
...
tests/clitests/error/syntax.js
0 → 100644
View file @
caf7329
qsfjdhf
!
è
r
è"è
qwnfkmsghfkswjdgfjksn
tests/clitests/runtests.py
View file @
caf7329
...
...
@@ -81,6 +81,20 @@ class CasperExecTest(unittest.TestCase):
self
.
assertCommandOutputEquals
(
script_path
,
'it works'
)
@timeout
(
20
)
def
test_syntax_error
(
self
):
script_path
=
os
.
path
.
join
(
TEST_ROOT
,
'error'
,
'syntax.js'
)
self
.
assertCommandOutputContains
(
script_path
,
[
'SyntaxError: Parse error'
,
],
failing
=
True
)
@timeout
(
20
)
def
test_syntax_error_in_test
(
self
):
script_path
=
os
.
path
.
join
(
TEST_ROOT
,
'error'
,
'syntax.js'
)
self
.
assertCommandOutputContains
(
'test
%
s'
%
script_path
,
[
'SyntaxError: Parse error'
,
],
failing
=
True
)
@timeout
(
20
)
def
test_simple_test_script
(
self
):
script_path
=
os
.
path
.
join
(
TEST_ROOT
,
'tester'
,
'mytest.js'
)
self
.
assertCommandOutputContains
(
'test '
+
script_path
,
[
...
...
Please
register
or
sign in
to post a comment