← Back to team overview

yellow team mailing list archive

[Merge] lp:~teknico/juju-gui/run-tests-in-prod-too into lp:juju-gui

 

Nicola Larosa has proposed merging lp:~teknico/juju-gui/run-tests-in-prod-too into lp:juju-gui.

Requested reviews:
  Juju GUI Hackers (juju-gui)
Related bugs:
  Bug #1087107 in juju-gui: "Tests should be runnable on the production build of the code"
  https://bugs.launchpad.net/juju-gui/+bug/1087107

For more details, see:
https://code.launchpad.net/~teknico/juju-gui/run-tests-in-prod-too/+merge/139002

Make tests runnable in production.

Allow tests to run in the production environment, by executing
the "make test-prod" command. They currently fail, and wil be
fixed in a future branch.

https://codereview.appspot.com/6868092/

-- 
https://code.launchpad.net/~teknico/juju-gui/run-tests-in-prod-too/+merge/139002
Your team Juju GUI Hackers is requested to review the proposed merge of lp:~teknico/juju-gui/run-tests-in-prod-too into lp:juju-gui.
=== modified file 'Makefile'
--- Makefile	2012-12-10 14:36:06 +0000
+++ Makefile	2012-12-10 15:18:19 +0000
@@ -112,7 +112,8 @@
 	@echo "prod: run the production environment (aggregated, compressed files)"
 	@echo "clean: remove the generated build directories"
 	@echo "clean-all: remove build, deps and doc directories"
-	@echo "test: run tests in the browser"
+	@echo "test-debug: run tests in the browser from the debug environment"
+	@echo "test-prod: run tests in the browser from the production environment"
 	@echo "prep: beautify and lint the source"
 	@echo "doc: generate Sphinx and YuiDoc documentation"
 	@echo "help: this description"
@@ -278,8 +279,13 @@
 
 prep: beautify lint
 
-test: build-debug
-	test-server.sh
+test-debug: build-debug
+	test-server.sh debug
+
+test-prod: build-prod
+	test-server.sh prod
+
+test: test-debug
 
 server:
 	@echo "Deprecated. Please run either 'make prod' or 'make debug',"
@@ -377,10 +383,11 @@
 # appcache, and this provides the correct order.
 appcache-force: appcache-touch appcache
 
-.PHONY: test lint beautify server clean prep jshint gjslint appcache \
-	appcache-touch appcache-force yuidoc spritegen yuidoc-lint \
-	build-files javascript-libraries build build-debug help \
-	build-prod clean clean-deps clean-docs clean-all devel debug \
-	prod link-debug-files link-prod-files doc dist undocumented
+.PHONY: appcache appcache-force appcache-touch beautify build \
+	build-debug build-files build-prod clean clean clean-all \
+	clean-deps clean-docs debug devel doc dist gjslint help \
+	javascript-libraries jshint link-debug-files link-prod-files \
+	lint prep prod server spritegen test test-debug test-prod \
+	undocumented yuidoc yuidoc-lint
 
 .DEFAULT_GOAL := all

=== modified file 'test-server.js'
--- test-server.js	2012-12-05 15:26:20 +0000
+++ test-server.js	2012-12-10 15:18:19 +0000
@@ -1,29 +1,31 @@
 'use strict';
 
+// process.argv[2] will be 'debug' or 'prod'
+
 var express = require('express'),
     server = express(),
     fs = require('fs'),
     path = require('path');
 
-
 server.configure(function() {
   server.use(express.logger('dev'));
   // 'static' is a reserved word so dot notation is not used to
   // avoid annoying the linter.
   server.use(express['static'](__dirname));
   // fallback to looking in assets
-  server.use('/juju-ui', express['static'](__dirname + '/build-debug/juju-ui'));
+  server.use('/juju-ui', express['static'](
+      __dirname + '/build-' + process.argv[2] + '/juju-ui'));
   server.use(express.bodyParser());
   server.use(express.methodOverride());
 });
 
 server.get('/juju-ui/:file', function(req, res) {
   var fileName = req.params.file;
-  res.sendfile('build-debug/juju-ui/' + fileName);
+  res.sendfile('build-' + process.argv[2] + '/juju-ui/' + fileName);
 });
 
 var port = 8084;
 
 server.listen(port, function() {
-  console.log('Server listening on ' + port);
+  console.log(process.argv[2] + ' server listening on ' + port);
 });

=== modified file 'test-server.sh'
--- test-server.sh	2012-10-10 20:58:47 +0000
+++ test-server.sh	2012-12-10 15:18:19 +0000
@@ -2,7 +2,7 @@
 
 set -m
 
-node ./test-server.js &
+node ./test-server.js $1 &
 sleep 2
 xdg-open http://localhost:8084/test/
 fg %1


Follow ups