← Back to team overview

yellow team mailing list archive

Make tests runnable in production. (issue 6868092)

 

Reviewers: mp+139002_code.launchpad.net,

Message:
Please take a look.

Description:
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://code.launchpad.net/~teknico/juju-gui/run-tests-in-prod-too/+merge/139002

(do not edit description out of merge proposal)


Please review this at https://codereview.appspot.com/6868092/

Affected files:
   M Makefile
   A [revision details]
   M test-server.js
   M test-server.sh


Index: Makefile
=== modified file 'Makefile'
--- Makefile	2012-12-10 14:36:06 +0000
+++ Makefile	2012-12-10 15:12:22 +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


Index: [revision details]
=== added file '[revision details]'
--- [revision details]	2012-01-01 00:00:00 +0000
+++ [revision details]	2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: benji.york@xxxxxxxxxxxxx-20121210143858-jcgkhuypin9yyuen
+New revision: nicola.larosa@xxxxxxxxxxxxx-20121210151449-b6jtwd9hh09uctqn

Index: test-server.js
=== modified file 'test-server.js'
--- test-server.js	2012-12-05 15:26:20 +0000
+++ test-server.js	2012-12-10 15:14:49 +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);
  });


Index: test-server.sh
=== modified file 'test-server.sh'
--- test-server.sh	2012-10-10 20:58:47 +0000
+++ test-server.sh	2012-12-07 17:57:27 +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





-- 
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.


References