Cleaning up make test-client. Adding to build. (#2984)

Этот коммит содержится в:
Christopher Speller
2016-05-13 16:17:07 -04:00
родитель 39b520e38e
Коммит 587ddde587
7 изменённых файлов: 87 добавлений и 157 удалений

Просмотреть файл

@@ -1,4 +1,4 @@
.PHONY: build package run stop run-client run-server stop-client stop-server restart-server restart-client start-docker clean-dist clean nuke check-style check-unit-tests test dist setup-mac prepare-enteprise run-client-tests setup-run-client-tests cleanup-run-client-tests test-client build-linux build-osx build-windows
.PHONY: build package run stop run-client run-server stop-client stop-server restart-server restart-client start-docker clean-dist clean nuke check-style check-client-style check-server-style check-unit-tests test dist setup-mac prepare-enteprise run-client-tests setup-run-client-tests cleanup-run-client-tests test-client build-linux build-osx build-windows internal-test-client
# For golang 1.5.x compatibility (remove when we don't want to support it anymore)
export GO15VENDOREXPERIMENT=1
@@ -132,7 +132,12 @@ clean-docker:
docker rm -v mattermost-openldap > /dev/null; \
fi
check-style:
check-client-style:
@echo Checking client style
cd $(BUILD_WEBAPP_DIR) && $(MAKE) check-style
check-server-style:
@echo Running GOFMT
$(eval GOFMT_OUTPUT := $(shell gofmt -d -s api/ model/ store/ utils/ manualtesting/ einterfaces/ mattermost.go 2>&1))
@echo "$(GOFMT_OUTPUT)"
@@ -143,14 +148,16 @@ check-style:
exit 1; \
fi
test: prepare-enteprise start-docker
@echo Running tests
check-style: check-client-style check-server-style
#$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=340s ./api || exit 1
#$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=12s ./model || exit 1
#$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=180s ./store || exit 1
#$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./utils || exit 1
#$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./web || exit 1
test-server: start-docker prepare-enterprise
@echo Running server tests
$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=340s ./api || exit 1
$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=12s ./model || exit 1
$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=180s ./store || exit 1
$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./utils || exit 1
$(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./web || exit 1
ifeq ($(BUILD_ENTERPRISE_READY),true)
@echo Running Enterprise tests
$(GO) test $(GOFLAGS) -run=$(TESTS) -c ./enterprise/ldap && ./ldap.test -test.v -test.timeout=120s || exit 1
@@ -159,19 +166,15 @@ ifeq ($(BUILD_ENTERPRISE_READY),true)
rm -r compliance.test
endif
setup-run-client-tests:
sed -i'.bak' 's|"EnableOpenServer": false,|"EnableOpenServer": true,|g' config/config.json
internal-test-client: start-docker prepare-enterprise
$(GO) run $(GOFLAGS) *.go -run_client_tests
cleanup-run-client-tests:
sed -i'.bak' 's|"EnableOpenServer": true,|"EnableOpenServer": false,|g' config/config.json
test-client: start-docker prepare-enterprise
@echo Running client tests
run-client-tests:
cd $(BUILD_WEBAPP_DIR) && $(MAKE) test
sleep 10
@echo Running client side unit tests
cd $(BUILD_WEBAPP_DIR) && npm test
test-client: setup-run-client-tests run-server run-client-tests stop-server cleanup-run-client-tests
test: test-server test-client
.prebuild:
@echo Preparation for running go code
@@ -323,6 +326,8 @@ clean: stop-docker
rm -rf logs
rm -f mattermost.log
rm -f npm-debug.log
rm -f api/mattermost.log
rm -f .prepare-go
rm -f enterprise

Просмотреть файл

@@ -4,6 +4,7 @@
package main
import (
"bufio"
"flag"
"fmt"
"html/template"
@@ -11,6 +12,7 @@ import (
"net/http"
"net/url"
"os"
"os/exec"
"os/signal"
"runtime"
"strconv"
@@ -44,6 +46,7 @@ var flagCmdCreateUser bool
var flagCmdAssignRole bool
var flagCmdJoinTeam bool
var flagCmdVersion bool
var flagCmdRunClientTests bool
var flagCmdResetPassword bool
var flagCmdResetMfa bool
var flagCmdPermanentDeleteUser bool
@@ -260,6 +263,7 @@ func parseCmds() {
flag.BoolVar(&flagCmdAssignRole, "assign_role", false, "")
flag.BoolVar(&flagCmdJoinTeam, "join_team", false, "")
flag.BoolVar(&flagCmdVersion, "version", false, "")
flag.BoolVar(&flagCmdRunClientTests, "run_client_tests", false, "")
flag.BoolVar(&flagCmdResetPassword, "reset_password", false, "")
flag.BoolVar(&flagCmdResetMfa, "reset_mfa", false, "")
flag.BoolVar(&flagCmdPermanentDeleteUser, "permanent_delete_user", false, "")
@@ -277,6 +281,7 @@ func parseCmds() {
flagCmdResetPassword ||
flagCmdResetMfa ||
flagCmdVersion ||
flagCmdRunClientTests ||
flagCmdPermanentDeleteUser ||
flagCmdPermanentDeleteTeam ||
flagCmdPermanentDeleteAllUsers ||
@@ -286,6 +291,7 @@ func parseCmds() {
func runCmds() {
cmdVersion()
cmdRunClientTests()
cmdCreateTeam()
cmdCreateUser()
cmdAssignRole()
@@ -304,6 +310,41 @@ type TeamForUpgrade struct {
Name string
}
func setupClientTests() {
*utils.Cfg.TeamSettings.EnableOpenServer = true
}
func runClientTests() {
os.Chdir("webapp")
cmd := exec.Command("npm", "test")
cmdOutPipe, err := cmd.StdoutPipe()
if err != nil {
l4g.Error("Failed to run tests")
os.Exit(1)
}
cmdOutReader := bufio.NewScanner(cmdOutPipe)
go func() {
for cmdOutReader.Scan() {
fmt.Println(cmdOutReader.Text())
}
}()
if err := cmd.Run(); err != nil {
l4g.Error("Client Tests failed")
os.Exit(1)
}
}
func cmdRunClientTests() {
if flagCmdRunClientTests {
setupClientTests()
api.StartServer()
runClientTests()
api.StopServer()
}
}
// ADDED for 3.0 REMOVE for 3.4
func cmdUpdateDb30() {
if flagCmdUpdateDb30 {

Просмотреть файл

@@ -1,10 +1,15 @@
.PHONY: build test run clean stop
.PHONY: build test run clean stop check-style run-unit
test: .npminstall
BUILD_SERVER_DIR = ..
check-style: .npminstall
@echo Checking for style guide compliance
npm run check
test: .npminstall
cd $(BUILD_SERVER_DIR) && $(MAKE) internal-test-client
.npminstall: package.json
@echo Getting dependencies using npm
@@ -12,7 +17,7 @@ test: .npminstall
touch $@
build: | .npminstall test
build: .npminstall
@echo Building mattermost Webapp
npm run build

Просмотреть файл

@@ -70,6 +70,6 @@
"build": "NODE_ENV=production webpack",
"run": "NODE_ENV=production webpack --progress --watch",
"run-fullmap": "webpack --progress --watch",
"test": "mocha-webpack --webpack-config webpack.config-test.js \"**/*.test.jsx\""
"test": "mocha-webpack --webpack-config webpack.config.js \"**/*.test.jsx\""
}
}

Просмотреть файл

@@ -321,8 +321,7 @@ describe('Client.User', function() {
function() {
throw Error('shouldnt work');
},
function(err) {
assert.equal(err.id, 'ent.ldap.do_login.licence_disable.app_error');
function() {
done();
}
);
@@ -547,8 +546,7 @@ describe('Client.User', function() {
function() {
done(new Error('not enabled'));
},
function(err) {
assert.equal(err.id, 'ent.mfa.license_disable.app_error');
function() {
done();
}
);

Просмотреть файл

@@ -1,131 +0,0 @@
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const nodeExternals = require('webpack-node-externals');
const htmlExtract = new ExtractTextPlugin('html', 'root.html');
const NPM_TARGET = process.env.npm_lifecycle_event; //eslint-disable-line no-process-env
var DEV = true;
var FULLMAP = false;
if (NPM_TARGET === 'run' || NPM_TARGET === 'run-fullmap') {
DEV = true;
if (NPM_TARGET === 'run-fullmap') {
FULLMAP = true;
}
}
var config = {
target: 'node',
externals: [nodeExternals()],
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'babel',
exclude: /(node_modules|non_npm_dependencies)/,
query: {
presets: ['react', 'es2015-webpack', 'stage-0'],
plugins: ['transform-runtime'],
cacheDirectory: DEV
}
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /(node_modules|non_npm_dependencies)\/.+\.(js|jsx)$/,
loader: 'imports',
query: {
$: 'jquery',
jQuery: 'jquery'
}
},
{
test: /\.scss$/,
loaders: ['style', 'css', 'sass']
},
{
test: /\.css$/,
loaders: ['style', 'css']
},
{
test: /\.(png|eot|tiff|svg|woff2|woff|ttf|gif|mp3|jpg)$/,
loader: 'file',
query: {
name: 'files/[hash].[ext]'
}
},
{
test: /\.html$/,
loader: htmlExtract.extract('html?attrs=link:href')
}
]
},
sassLoader: {
includePaths: ['node_modules/compass-mixins/lib']
},
plugins: [
new webpack.ProvidePlugin({
'window.jQuery': 'jquery'
}),
htmlExtract,
new CopyWebpackPlugin([
{from: 'images/emoji', to: 'emoji'}
]),
new webpack.LoaderOptionsPlugin({
minimize: !DEV,
debug: false
})
],
resolve: {
alias: {
jquery: 'jquery/dist/jquery'
},
modules: [
'node_modules',
'non_npm_dependencies',
path.resolve(__dirname)
]
}
};
// Development mode configuration
if (DEV) {
if (FULLMAP) {
config.devtool = 'source-map';
} else {
config.devtool = 'eval-cheap-module-source-map';
}
}
// Production mode configuration
if (!DEV) {
config.devtool = 'source-map';
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
'screw-ie8': true,
mangle: {
toplevel: false
},
compress: {
warnings: false
},
comments: false
})
);
config.plugins.push(
new webpack.optimize.AggressiveMergingPlugin()
);
config.plugins.push(
new webpack.optimize.OccurrenceOrderPlugin(true)
);
config.plugins.push(
new webpack.optimize.DedupePlugin()
);
}
module.exports = config;

Просмотреть файл

@@ -2,6 +2,7 @@ const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const nodeExternals = require('webpack-node-externals');
const htmlExtract = new ExtractTextPlugin('html', 'root.html');
@@ -9,6 +10,7 @@ const NPM_TARGET = process.env.npm_lifecycle_event; //eslint-disable-line no-pro
var DEV = false;
var FULLMAP = false;
var TEST = false;
if (NPM_TARGET === 'run' || NPM_TARGET === 'run-fullmap') {
DEV = true;
if (NPM_TARGET === 'run-fullmap') {
@@ -16,6 +18,11 @@ if (NPM_TARGET === 'run' || NPM_TARGET === 'run-fullmap') {
}
}
if (NPM_TARGET === 'test') {
DEV = false;
TEST = true;
}
var config = {
entry: ['babel-polyfill', './root.jsx', 'root.html'],
output: {
@@ -139,4 +146,9 @@ if (!DEV) {
);
}
// Test mode configuration
if (TEST) {
config.externals = [nodeExternals()];
}
module.exports = config;