PhantomJS 1.8 is now the minimum required version
Showing
4 changed files
with
55 additions
and
25 deletions
... | @@ -8,6 +8,10 @@ This version is yet to be released, and will possibly be tagged as 2.0 as not-so | ... | @@ -8,6 +8,10 @@ This version is yet to be released, and will possibly be tagged as 2.0 as not-so |
8 | 8 | ||
9 | ### Important Changes & Caveats | 9 | ### Important Changes & Caveats |
10 | 10 | ||
11 | #### Minimum PhantomJS version | ||
12 | |||
13 | **PhantomJS 1.8.1 or later is required for 1.1.** | ||
14 | |||
11 | #### Testing framework refactoring | 15 | #### Testing framework refactoring |
12 | 16 | ||
13 | A new `Tester.begin()` method has been introduced to help organizing tests better: | 17 | A new `Tester.begin()` method has been introduced to help organizing tests better: |
... | @@ -64,6 +68,7 @@ Last, all the casper test suites have been upgraded to use the new testing featu | ... | @@ -64,6 +68,7 @@ Last, all the casper test suites have been upgraded to use the new testing featu |
64 | 68 | ||
65 | ### Bugfixes & enhancements | 69 | ### Bugfixes & enhancements |
66 | 70 | ||
71 | - heavy lifint of casperjs bootstrap script | ||
67 | - closed [#392](https://github.com/n1k0/casperjs/issues/392) - `--direct` & `--log-level` options available for the `casperjs` executable | 72 | - closed [#392](https://github.com/n1k0/casperjs/issues/392) - `--direct` & `--log-level` options available for the `casperjs` executable |
68 | - closed [#350](https://github.com/n1k0/casperjs/issues/350) - Add a Casper.waitForSelectorTextChange() method | 73 | - closed [#350](https://github.com/n1k0/casperjs/issues/350) - Add a Casper.waitForSelectorTextChange() method |
69 | - fixed [#387](https://github.com/n1k0/casperjs/issues/387) - Setting viewport isn't quite synchronous | 74 | - fixed [#387](https://github.com/n1k0/casperjs/issues/387) - Setting viewport isn't quite synchronous | ... | ... |
... | @@ -34,13 +34,6 @@ | ... | @@ -34,13 +34,6 @@ |
34 | // phantom check | 34 | // phantom check |
35 | if (!phantom) { | 35 | if (!phantom) { |
36 | console.error('CasperJS needs to be executed in a PhantomJS environment http://phantomjs.org/'); | 36 | console.error('CasperJS needs to be executed in a PhantomJS environment http://phantomjs.org/'); |
37 | phantom.exit(1); | ||
38 | } | ||
39 | |||
40 | // required version check | ||
41 | if (phantom.version.major === 1 && phantom.version.minor < 7) { | ||
42 | console.error('CasperJS needs at least PhantomJS v1.7 or later.'); | ||
43 | phantom.exit(1); | ||
44 | } | 37 | } |
45 | 38 | ||
46 | // Common polyfills | 39 | // Common polyfills |
... | @@ -75,6 +68,29 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); | ... | @@ -75,6 +68,29 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); |
75 | return; | 68 | return; |
76 | } | 69 | } |
77 | 70 | ||
71 | function __die(message) { | ||
72 | console.error(message); | ||
73 | phantom.exit(1); | ||
74 | } | ||
75 | |||
76 | function __terminate(message) { | ||
77 | console.log(message); | ||
78 | phantom.exit(); | ||
79 | } | ||
80 | |||
81 | (function(version) { | ||
82 | // required version check | ||
83 | if (version.major !== 1) { | ||
84 | return __die('CasperJS needs PhantomJS v1.x'); | ||
85 | } | ||
86 | if (version.minor < 8) { | ||
87 | return __die('CasperJS needs at least PhantomJS v1.8 or later.'); | ||
88 | } | ||
89 | if (version.patch < 1) { | ||
90 | return __die('CasperJS needs at least PhantomJS v1.8.1 or later.'); | ||
91 | } | ||
92 | })(phantom.version); | ||
93 | |||
78 | // Hooks in default phantomjs error handler to print a hint when a possible | 94 | // Hooks in default phantomjs error handler to print a hint when a possible |
79 | // casperjs command misuse is detected. | 95 | // casperjs command misuse is detected. |
80 | phantom.onError = function onPhantomError(msg, trace) { | 96 | phantom.onError = function onPhantomError(msg, trace) { |
... | @@ -124,17 +140,19 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); | ... | @@ -124,17 +140,19 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); |
124 | return fs.isDirectory(path); | 140 | return fs.isDirectory(path); |
125 | }).pop(); | 141 | }).pop(); |
126 | } catch (e) { | 142 | } catch (e) { |
127 | console.error("Couldn't find nor compute phantom.casperPath, exiting."); | 143 | return __die("Couldn't find nor compute phantom.casperPath, exiting."); |
128 | phantom.exit(1); | ||
129 | } | 144 | } |
130 | } | 145 | } |
131 | 146 | ||
132 | // Patched require to allow loading of native casperjs modules. | 147 | /** |
133 | // Every casperjs native module have to first call this function in order to | 148 | * Patched require to allow loading of native casperjs modules. |
134 | // load a native casperjs module: | 149 | * Every casperjs native module have to first call this function in order to |
135 | // | 150 | * load a native casperjs module: |
136 | // var require = patchRequire(require); | 151 | * |
137 | // var utils = require('utils'); | 152 | * var require = patchRequire(require); |
153 | * var utils = require('utils'); | ||
154 | * | ||
155 | */ | ||
138 | function patchRequire(require) { | 156 | function patchRequire(require) { |
139 | if (require.patched) { | 157 | if (require.patched) { |
140 | return require; | 158 | return require; |
... | @@ -168,6 +186,7 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); | ... | @@ -168,6 +186,7 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); |
168 | 186 | ||
169 | /** | 187 | /** |
170 | * Initializes the CasperJS Command Line Interface. | 188 | * Initializes the CasperJS Command Line Interface. |
189 | * | ||
171 | */ | 190 | */ |
172 | function initCasperCli() { | 191 | function initCasperCli() { |
173 | var baseTestsPath = fs.pathJoin(phantom.casperPath, 'tests'); | 192 | var baseTestsPath = fs.pathJoin(phantom.casperPath, 'tests'); |
... | @@ -190,11 +209,13 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); | ... | @@ -190,11 +209,13 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); |
190 | } else if (phantom.casperArgs.args.length === 0 || !!phantom.casperArgs.options.help) { | 209 | } else if (phantom.casperArgs.args.length === 0 || !!phantom.casperArgs.options.help) { |
191 | var phantomVersion = [phantom.version.major, phantom.version.minor, phantom.version.patch].join('.'); | 210 | var phantomVersion = [phantom.version.major, phantom.version.minor, phantom.version.patch].join('.'); |
192 | var f = require("utils").format; | 211 | var f = require("utils").format; |
193 | console.log(f('CasperJS version %s at %s, using PhantomJS version %s', | 212 | return __terminate([ |
213 | f('CasperJS version %s at %s, using PhantomJS version %s', | ||
194 | phantom.casperVersion.toString(), | 214 | phantom.casperVersion.toString(), |
195 | phantom.casperPath, phantomVersion)); | 215 | phantom.casperPath, |
196 | console.log(fs.read(fs.pathJoin(phantom.casperPath, 'bin', 'usage.txt'))); | 216 | phantomVersion) |
197 | return phantom.exit(0); | 217 | , fs.read(fs.pathJoin(phantom.casperPath, 'bin', 'usage.txt')) |
218 | ].join('\n')); | ||
198 | } | 219 | } |
199 | 220 | ||
200 | if (!phantom.casperScript) { | 221 | if (!phantom.casperScript) { |
... | @@ -202,8 +223,7 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); | ... | @@ -202,8 +223,7 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); |
202 | } | 223 | } |
203 | 224 | ||
204 | if (!fs.isFile(phantom.casperScript)) { | 225 | if (!fs.isFile(phantom.casperScript)) { |
205 | console.error('Unable to open file: ' + phantom.casperScript); | 226 | return __die('Unable to open file: ' + phantom.casperScript); |
206 | return phantom.exit(1); | ||
207 | } | 227 | } |
208 | 228 | ||
209 | // filter out the called script name from casper args | 229 | // filter out the called script name from casper args |
... | @@ -255,10 +275,11 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); | ... | @@ -255,10 +275,11 @@ CasperError.prototype = Object.getPrototypeOf(new Error()); |
255 | initCasperCli(); | 275 | initCasperCli(); |
256 | } | 276 | } |
257 | 277 | ||
278 | // casper loading status flag | ||
258 | phantom.casperLoaded = true; | 279 | phantom.casperLoaded = true; |
259 | 280 | ||
260 | // passed casperjs script execution | 281 | // passed casperjs script execution |
261 | if (!phantom.injectJs(phantom.casperScript)) { | 282 | if (phantom.casperScript && !phantom.injectJs(phantom.casperScript)) { |
262 | throw new CasperError('Unable to load script ' + phantom.casperScript + '; check file syntax'); | 283 | return __die('Unable to load script ' + phantom.casperScript + '; check file syntax'); |
263 | } | 284 | } |
264 | })(window, phantom); | 285 | })(window, phantom); | ... | ... |
... | @@ -9,8 +9,11 @@ def test_cmd(cmd): | ... | @@ -9,8 +9,11 @@ def test_cmd(cmd): |
9 | try: | 9 | try: |
10 | return subprocess.check_output([__file__] + cmd.split(' ')) | 10 | return subprocess.check_output([__file__] + cmd.split(' ')) |
11 | except subprocess.CalledProcessError as err: | 11 | except subprocess.CalledProcessError as err: |
12 | sys.stderr.write('FAIL: %s\n' % ' '.join(err.cmd)) | 12 | sys.stderr.write('FAIL: %s\n' % err) |
13 | sys.stderr.write(' %s\n' % err.output) | 13 | sys.stderr.write(' return code: %d\n' % err.returncode) |
14 | sys.stderr.write(' args: %s\n' % ','.join(err.args)) | ||
15 | sys.stderr.write(' cmd: %s\n' % ' '.join(err.cmd)) | ||
16 | sys.stderr.write(' output: %s\n' % err.output) | ||
14 | sys.exit(1) | 17 | sys.exit(1) |
15 | 18 | ||
16 | def resolve(path): | 19 | def resolve(path): | ... | ... |
... | @@ -2,6 +2,7 @@ | ... | @@ -2,6 +2,7 @@ |
2 | Usage: casperjs [options] script.[js|coffee] [script argument [script argument ...]] | 2 | Usage: casperjs [options] script.[js|coffee] [script argument [script argument ...]] |
3 | casperjs [options] test [test path [test path ...]] | 3 | casperjs [options] test [test path [test path ...]] |
4 | casperjs [options] selftest | 4 | casperjs [options] selftest |
5 | casperjs [options] __selfcommandtest | ||
5 | 6 | ||
6 | Options: | 7 | Options: |
7 | 8 | ... | ... |
-
Please register or sign in to post a comment