From 0f537c7bbc9a7c2ad84435afaea53fd9e91bcabb Mon Sep 17 00:00:00 2001 From: Urs Wolfer Date: Wed, 30 Mar 2016 20:01:33 +0200 Subject: [PATCH 1/2] Add support for running (single) tests with 'run-server.sh' - include 'web-component-tester' bower dependency as test-dependency - remove special handling for serving folder 'bower_components' - add support for passing parameters from 'run-server.sh' to 'server.go' Change-Id: Ia74b3013e07b6304a4df568b081254909749efc5 --- lib/js/BUCK | 83 +++++++++++++++++++++++++++++++++++++ polygerrit-ui/app/BUCK | 1 + polygerrit-ui/run-server.sh | 9 ++-- polygerrit-ui/server.go | 2 - 4 files changed, 89 insertions(+), 6 deletions(-) diff --git a/lib/js/BUCK b/lib/js/BUCK index 282e51e1ea..86d69e62a4 100644 --- a/lib/js/BUCK +++ b/lib/js/BUCK @@ -75,6 +75,30 @@ npm_binary( # Use the same procedure as for adding dependencies, except just change the # version number of the existing bower_component rather than adding a new rule. +bower_component( + name = 'accessibility-developer-tools', + package = 'accessibility-developer-tools', + version = '2.10.0', + license = 'DO_NOT_DISTRIBUTE', + sha1 = 'bc1a5e56ff1bed7a7a6ef22a4b4e8300e4822aa5', +) + +bower_component( + name = 'async', + package = 'async', + version = '1.5.2', + license = 'DO_NOT_DISTRIBUTE', + sha1 = '1ec975d3b3834646a7e3d4b7e68118b90ed72508', +) + +bower_component( + name = 'chai', + package = 'chai', + version = '3.5.0', + license = 'DO_NOT_DISTRIBUTE', + sha1 = '849ad3ee7c77506548b7b5db603a4e150b9431aa', +) + bower_component( name = 'fetch', package = 'fetch', @@ -266,6 +290,22 @@ bower_component( sha1 = '5a68250d6d9abcd576f116dc4fc7312426323883', ) +bower_component( + name = 'lodash', + package = 'lodash', + version = '3.10.1', + license = 'DO_NOT_DISTRIBUTE', + sha1 = '2f207a8293c4c554bf6cf071241f7a00dc513d3a', +) + +bower_component( + name = 'mocha', + package = 'mocha', + version = '2.4.5', + license = 'DO_NOT_DISTRIBUTE', + sha1 = 'efbb1675710c0ba94a44eb7a4d27040229283197', +) + bower_component( name = 'moment', package = 'moment/moment', @@ -328,6 +368,30 @@ bower_component( sha1 = 'a3b598c06cbd7f441402e666ff748326030905d6', ) +bower_component( + name = 'sinon-chai', + package = 'sinon-chai', + version = '2.8.0', + license = 'DO_NOT_DISTRIBUTE', + sha1 = '0464b5d944fdf8116bb23e0b02ecfbac945b3517', +) + +bower_component( + name = 'sinonjs', + package = 'sinonjs', + version = '1.17.1', + license = 'DO_NOT_DISTRIBUTE', + sha1 = 'a26a6aab7358807de52ba738770f6ac709afd240', +) + +bower_component( + name = 'stacky', + package = 'stacky', + version = '1.3.2', + license = 'DO_NOT_DISTRIBUTE', + sha1 = 'd6c07a0112ab2e9677fe085933744466a89232fb', +) + bower_component( name = 'test-fixture', package = 'polymerelements/test-fixture', @@ -344,6 +408,25 @@ bower_component( sha1 = '92f06d8417a51f1f75c94b7a19616e19695cc6db', ) +bower_component( + name = 'web-component-tester', + package = 'web-component-tester', + version = '4.2.2', + deps = [ + ':accessibility-developer-tools', + ':async', + ':chai', + ':lodash', + ':mocha', + ':sinon-chai', + ':sinonjs', + ':stacky', + ':test-fixture', + ], + license = 'DO_NOT_DISTRIBUTE', + sha1 = '54556000c33d9ed7949aa546c1b4a1531491a5f0', +) + bower_component( name = 'webcomponentsjs', package = 'webcomponentsjs', diff --git a/polygerrit-ui/app/BUCK b/polygerrit-ui/app/BUCK index dbc3feed1b..c4901db27b 100644 --- a/polygerrit-ui/app/BUCK +++ b/polygerrit-ui/app/BUCK @@ -56,6 +56,7 @@ bower_components( '//polygerrit-ui:polygerrit_components', '//lib/js:iron-test-helpers', '//lib/js:test-fixture', + '//lib/js:web-component-tester', ], ) diff --git a/polygerrit-ui/run-server.sh b/polygerrit-ui/run-server.sh index 70ee3cb8ea..d76f3ba43f 100755 --- a/polygerrit-ui/run-server.sh +++ b/polygerrit-ui/run-server.sh @@ -23,8 +23,9 @@ if [[ ! -f .buckconfig ]]; then exit 1 fi -cd polygerrit-ui +buck build //polygerrit-ui/app:polygerrit_tests +cd polygerrit-ui/app rm -rf bower_components -buck build //polygerrit-ui:polygerrit_components -unzip -q ../buck-out/gen/polygerrit-ui/polygerrit_components/polygerrit_components.bower_components.zip -exec go run server.go +unzip -q ../../buck-out/gen/polygerrit-ui/app/test_components/test_components.bower_components.zip +cd .. +exec go run server.go "$@" diff --git a/polygerrit-ui/server.go b/polygerrit-ui/server.go index 59a09b088c..66f9e55c84 100644 --- a/polygerrit-ui/server.go +++ b/polygerrit-ui/server.go @@ -42,8 +42,6 @@ func main() { if *prod { http.Handle("/", http.FileServer(http.Dir("dist"))) } else { - http.Handle("/bower_components/", - http.StripPrefix("/bower_components/", http.FileServer(http.Dir("bower_components")))) http.Handle("/", http.FileServer(http.Dir("app"))) } From ceb5db093e2ad92140bdbcad14dc5a64aa1b1d4b Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 29 Mar 2016 18:56:38 +0200 Subject: [PATCH 2/2] PolyGerrit: explain how to run a single test file. Change-Id: Ie3bd69af72560db5a34351d4f25fa779e52da2a1 --- polygerrit-ui/README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/polygerrit-ui/README.md b/polygerrit-ui/README.md index bef92b6101..4ec5411405 100644 --- a/polygerrit-ui/README.md +++ b/polygerrit-ui/README.md @@ -13,7 +13,7 @@ brew install node All other platforms: [download from nodejs.org](https://nodejs.org/en/download/). -## Optional: installing [go] (https://golang.org/) +## Optional: installing [go](https://golang.org/) This is only required for running the ```run-server.sh``` script for testing. See below. @@ -25,7 +25,7 @@ sudo apt-get install golang brew install go ``` -All other platforms: [download from golang.org] (https//golang.org/) +All other platforms: [download from golang.org](https//golang.org/) # Add [go] to your path @@ -38,7 +38,7 @@ PATH=$PATH:/usr/local/go/bin To test the local UI against gerrit-review.googlesource.com: ```sh -./run-server.sh +./polygerrit-ui/run-server.sh ``` Then visit http://localhost:8081 @@ -89,6 +89,14 @@ If you need to pass additional arguments to `wct`: WCT_ARGS='-p --some-flag="foo bar"' buck test --no-results-cache --include web ``` +For interactively working on a single test file, do the following: + +```sh +./polygerrit-ui/run-server.sh +``` + +Then visit http://localhost:8081/elements/foo/bar_test.html + ## Style guide We follow the [Google JavaScript Style Guide](https://google.github.io/styleguide/javascriptguide.xml)