diff --git a/.gitignore b/.gitignore index a1b39709a..7904c7cc3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +built/ node_modules/ selenium/ testapp/inbrowsertest/ diff --git a/.npmignore b/.npmignore index 93e651f1f..a7bb2d306 100644 --- a/.npmignore +++ b/.npmignore @@ -1,5 +1,6 @@ debugging/ docs/ +lib/ scripts/ spec/ stress/ diff --git a/bin/protractor b/bin/protractor index 0bf1f145a..bb19c4124 100755 --- a/bin/protractor +++ b/bin/protractor @@ -2,4 +2,4 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'test'; -require('../lib/cli.js'); +require('../built/cli.js'); diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 000000000..844ac5adf --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,39 @@ +'use strict'; + +var gulp = require('gulp'); +var runSequence = require('run-sequence'); +var spawnSync = require('child_process').spawnSync; + +gulp.task('built:copy', function() { + var srcFiles = ['lib/**/*']; + var dist = 'built/'; + return gulp.src(srcFiles).pipe(gulp.dest(dist)); +}); + +gulp.task('webdriver:update', function() { + var child = spawnSync('bin/webdriver-manager', ['update']); + if (child.stdout != null) { + console.log(child.stdout.toString()); + } + if (child.status !== 0) { + throw new Error('webdriver-manager update: child error'); + } +}); + +gulp.task('jslint', function() { + var child = spawnSync('./node_modules/.bin/jshint', ['lib','spec', 'scripts']); + if (child != null && child.stdout != null ) { + console.log(child.stdout.toString()); + } + if (child.status !== 0) { + throw new Error('jslint: child error'); + } +}); + +gulp.task('pretest', function() { + runSequence( + ['webdriver:update', 'jslint'], + 'built:copy' + ); +}); +gulp.task('prepublish', ['built:copy']); diff --git a/package.json b/package.json index b16fa4e4c..fe9339ffe 100644 --- a/package.json +++ b/package.json @@ -27,11 +27,13 @@ "expect.js": "~0.3.1", "chai": "~3.4.1", "chai-as-promised": "~5.2.0", + "gulp": "^3.9.1", "jshint": "2.9.1", "mocha": "2.3.4", "express": "~4.13.3", "body-parser": "1.14.2", "rimraf": "~2.5.0", + "run-sequence": "^1.1.5", "lodash": "^2.4.1", "marked": "^0.3.3" }, @@ -45,7 +47,8 @@ }, "main": "lib/protractor.js", "scripts": { - "pretest": "./scripts/pretest.sh", + "prepublish": "gulp prepublish", + "pretest": "gulp pretest", "test": "node scripts/test.js", "start": "node testapp/scripts/web-server.js" }, diff --git a/scripts/interactive_tests/interactive_test.js b/scripts/interactive_tests/interactive_test.js index 2aac1ef81..a4342f764 100644 --- a/scripts/interactive_tests/interactive_test.js +++ b/scripts/interactive_tests/interactive_test.js @@ -1,7 +1,7 @@ var env = require('../../spec/environment.js'); var InteractiveTest = require('./interactive_test_util').InteractiveTest; var port = env.interactiveTestPort; -var test = new InteractiveTest('node lib/cli.js --elementExplorer true', port); +var test = new InteractiveTest('node built/cli.js --elementExplorer true', port); // Check state persists. test.addCommandExpectation('var x = 3'); diff --git a/scripts/interactive_tests/with_base_url.js b/scripts/interactive_tests/with_base_url.js index 3a7186b2c..cd82f7b62 100644 --- a/scripts/interactive_tests/with_base_url.js +++ b/scripts/interactive_tests/with_base_url.js @@ -2,7 +2,7 @@ var env = require('../../spec/environment.js'); var InteractiveTest = require('./interactive_test_util').InteractiveTest; var port = env.interactiveTestPort; var test = new InteractiveTest( - 'node lib/cli.js --baseUrl http://localhost:' + env.webServerDefaultPort + + 'node built/cli.js --baseUrl http://localhost:' + env.webServerDefaultPort + '/ng1 --elementExplorer true', port); // Check we automatically go to to baseUrl. diff --git a/scripts/pretest.sh b/scripts/pretest.sh deleted file mode 100755 index f09d412ab..000000000 --- a/scripts/pretest.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# When running `npm test`, this script is intended to run during pretest step. - -bin/webdriver-manager update # updates the local webdriver manager -node_modules/.bin/jshint lib spec scripts diff --git a/scripts/test.js b/scripts/test.js index 8858fa823..9558c107e 100755 --- a/scripts/test.js +++ b/scripts/test.js @@ -3,35 +3,35 @@ var Executor = require('./test/test_util').Executor; var passingTests = [ - 'node lib/cli.js spec/basicConf.js', - 'node lib/cli.js spec/multiConf.js', - 'node lib/cli.js spec/altRootConf.js', - 'node lib/cli.js spec/onCleanUpAsyncReturnValueConf.js', - 'node lib/cli.js spec/onCleanUpNoReturnValueConf.js', - 'node lib/cli.js spec/onCleanUpSyncReturnValueConf.js', - 'node lib/cli.js spec/onPrepareConf.js', - 'node lib/cli.js spec/onPrepareFileConf.js', - 'node lib/cli.js spec/onPreparePromiseConf.js', - 'node lib/cli.js spec/onPreparePromiseFileConf.js', - 'node lib/cli.js spec/mochaConf.js', - 'node lib/cli.js spec/withLoginConf.js', - 'node lib/cli.js spec/suitesConf.js --suite okmany', - 'node lib/cli.js spec/suitesConf.js --suite okspec', - 'node lib/cli.js spec/suitesConf.js --suite okmany,okspec', - 'node lib/cli.js spec/plugins/smokeConf.js', - 'node lib/cli.js spec/plugins/multiPluginConf.js', - 'node lib/cli.js spec/plugins/jasminePostTestConf.js', - 'node lib/cli.js spec/plugins/mochaPostTestConf.js', - 'node lib/cli.js spec/plugins/browserGetSyncedConf.js', - 'node lib/cli.js spec/plugins/browserGetUnsyncedConf.js', - 'node lib/cli.js spec/plugins/waitForAngularConf.js', - 'node lib/cli.js spec/interactionConf.js', - 'node lib/cli.js spec/directConnectConf.js', - 'node lib/cli.js spec/restartBrowserBetweenTestsConf.js', - 'node lib/cli.js spec/getCapabilitiesConf.js', - 'node lib/cli.js spec/controlLockConf.js', - 'node lib/cli.js spec/customFramework.js', - 'node lib/cli.js spec/angular2Conf.js', + 'node built/cli.js spec/basicConf.js', + 'node built/cli.js spec/multiConf.js', + 'node built/cli.js spec/altRootConf.js', + 'node built/cli.js spec/onCleanUpAsyncReturnValueConf.js', + 'node built/cli.js spec/onCleanUpNoReturnValueConf.js', + 'node built/cli.js spec/onCleanUpSyncReturnValueConf.js', + 'node built/cli.js spec/onPrepareConf.js', + 'node built/cli.js spec/onPrepareFileConf.js', + 'node built/cli.js spec/onPreparePromiseConf.js', + 'node built/cli.js spec/onPreparePromiseFileConf.js', + 'node built/cli.js spec/mochaConf.js', + 'node built/cli.js spec/withLoginConf.js', + 'node built/cli.js spec/suitesConf.js --suite okmany', + 'node built/cli.js spec/suitesConf.js --suite okspec', + 'node built/cli.js spec/suitesConf.js --suite okmany,okspec', + 'node built/cli.js spec/plugins/smokeConf.js', + 'node built/cli.js spec/plugins/multiPluginConf.js', + 'node built/cli.js spec/plugins/jasminePostTestConf.js', + 'node built/cli.js spec/plugins/mochaPostTestConf.js', + 'node built/cli.js spec/plugins/browserGetSyncedConf.js', + 'node built/cli.js spec/plugins/browserGetUnsyncedConf.js', + 'node built/cli.js spec/plugins/waitForAngularConf.js', + 'node built/cli.js spec/interactionConf.js', + 'node built/cli.js spec/directConnectConf.js', + 'node built/cli.js spec/restartBrowserBetweenTestsConf.js', + 'node built/cli.js spec/getCapabilitiesConf.js', + 'node built/cli.js spec/controlLockConf.js', + 'node built/cli.js spec/customFramework.js', + 'node built/cli.js spec/angular2Conf.js', 'node scripts/attachSession.js', 'node scripts/interactive_tests/interactive_test.js', 'node scripts/interactive_tests/with_base_url.js', @@ -51,14 +51,14 @@ passingTests.forEach(function(passing_test) { *************************/ // assert stacktrace shows line of failure -executor.addCommandlineTest('node lib/cli.js spec/errorTest/singleFailureConf.js') +executor.addCommandlineTest('node built/cli.js spec/errorTest/singleFailureConf.js') .expectExitCode(1) .expectErrors({ stackTrace: 'single_failure_spec1.js:5:32' }); // assert timeout works -executor.addCommandlineTest('node lib/cli.js spec/errorTest/timeoutConf.js') +executor.addCommandlineTest('node built/cli.js spec/errorTest/timeoutConf.js') .expectExitCode(1) .expectErrors({ message: 'Timeout - Async callback was not invoked within timeout ' + @@ -66,13 +66,13 @@ executor.addCommandlineTest('node lib/cli.js spec/errorTest/timeoutConf.js') }) .expectTestDuration(0, 100); -executor.addCommandlineTest('node lib/cli.js spec/errorTest/afterLaunchChangesExitCodeConf.js') +executor.addCommandlineTest('node built/cli.js spec/errorTest/afterLaunchChangesExitCodeConf.js') .expectExitCode(11) .expectErrors({ message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.' }); -executor.addCommandlineTest('node lib/cli.js spec/errorTest/multiFailureConf.js') +executor.addCommandlineTest('node built/cli.js spec/errorTest/multiFailureConf.js') .expectExitCode(1) .expectErrors([{ message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.', @@ -82,7 +82,7 @@ executor.addCommandlineTest('node lib/cli.js spec/errorTest/multiFailureConf.js' stacktrace: 'single_failure_spec2.js:5:32' }]); -executor.addCommandlineTest('node lib/cli.js spec/errorTest/shardedFailureConf.js') +executor.addCommandlineTest('node built/cli.js spec/errorTest/shardedFailureConf.js') .expectExitCode(1) .expectErrors([{ message: 'Expected \'Hiya\' to equal \'INTENTIONALLY INCORRECT\'.', @@ -92,14 +92,14 @@ executor.addCommandlineTest('node lib/cli.js spec/errorTest/shardedFailureConf.j stacktrace: 'single_failure_spec2.js:5:32' }]); -executor.addCommandlineTest('node lib/cli.js spec/errorTest/mochaFailureConf.js') +executor.addCommandlineTest('node built/cli.js spec/errorTest/mochaFailureConf.js') .expectExitCode(1) .expectErrors([{ message: 'expected \'My AngularJS App\' to equal \'INTENTIONALLY INCORRECT\'', stacktrace: 'mocha_failure_spec.js:11:20' }]); -executor.addCommandlineTest('node lib/cli.js spec/errorTest/pluginsFailingConf.js') +executor.addCommandlineTest('node built/cli.js spec/errorTest/pluginsFailingConf.js') .expectExitCode(1) .expectErrors([ {message: 'Expected true to be false'}, @@ -109,7 +109,7 @@ executor.addCommandlineTest('node lib/cli.js spec/errorTest/pluginsFailingConf.j {message: 'from teardown'} ]); -executor.addCommandlineTest('node lib/cli.js spec/errorTest/slowHttpAndTimeoutConf.js') +executor.addCommandlineTest('node built/cli.js spec/errorTest/slowHttpAndTimeoutConf.js') .expectExitCode(1) .expectErrors([ {message: 'The following tasks were pending[\\s\\S]*\\$http: slowcall'}, @@ -119,7 +119,7 @@ executor.addCommandlineTest('node lib/cli.js spec/errorTest/slowHttpAndTimeoutCo '*}'} ]); -executor.addCommandlineTest('node lib/cli.js spec/errorTest/slowHttpAndTimeoutConf.js ' + +executor.addCommandlineTest('node built/cli.js spec/errorTest/slowHttpAndTimeoutConf.js ' + '--untrackOutstandingTimeouts true') .expectExitCode(1) .expectErrors([