diff --git a/Makefile b/Makefile index 890328f900a55..89ed54ce763c0 100644 --- a/Makefile +++ b/Makefile @@ -93,12 +93,8 @@ node_modules: package.json | node-version @$(NPM) install @touch node_modules -# run `make test` in all discovered Makefiles test: build - @npm run test-client - @npm run test-server - @npm run test-test - @$(BIN)/run-all-tests + @$(NPM) test lint: node_modules/eslint node_modules/eslint-plugin-react node_modules/babel-eslint mixedindentlint @$(NPM) run lint diff --git a/bin/run-all-tests b/bin/run-all-tests deleted file mode 100755 index 75b8b63bb8aab..0000000000000 --- a/bin/run-all-tests +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash - -BASEDIR=$(dirname $0) -FAILED=0 -FAILED_ROUTES=() -RED='\033[0;31m' -BLUE='\033[0;34m' -NO_COLOR='\033[0m' - -if [ "${MULTICORE}" = 1 ]; then - CORES=${CORES:-} -else - CORES=1 -fi - - -# print as many equal signs as the terminal is wide -print_horizontal_rule() { - printf "%$(tput cols)s\n" | tr " " "=" -} - - -__count_core_items() { - echo $(cat /proc/cpuinfo | grep "$1" | sort -u | wc -l) -} - -get_cores__linux() { - local cpus=$(__count_core_items "physical id") - local cores=$(__count_core_items "core id") - echo $((cpus * cores)) -} - -get_core_count() { - if [ -z "${CORES}" ]; then - local cores=1 - # OSX - which sysctl &>/dev/null && cores=$(sysctl -n hw.physicalcpu) - # Unix - test -f /proc/cpuinfo && cores=$(get_cores__linux) - echo $cores - else - echo ${CORES} - fi -} - -__print_usage() { - printf "$BLUE" - echo " -*----------------------------------------------------------------------------------------* -| Experimental parallel testing available | -| Usage: | -| export MULTICORE=1 to enable experimental parallel testing. | -| export CORES=4 to control the number of cores used. Leave unset to utilize all cores. | -*----------------------------------------------------------------------------------------* -" - printf "$NO_COLOR" -} - -run_test_fast() { - echo > .test.log - local cores=$(get_core_count) - echo "Using $cores cores" 1>&2 - __print_usage - xargs -P"${cores}" -I % /bin/bash -c '"$1"/run-tests "$2" || (echo "$2" >> .test.log && false)' -- "${BASEDIR}" % - local exitcode=$? - if [ "$exitcode" -ne 0 ]; then - printf "$RED" - echo "These tests have failed:" - cat .test.log | xargs -I % dirname % | xargs /bin/bash -c 'echo $(cd $(dirname "$1") && pwd)/$(basename "$1")' -- - printf "$NO_COLOR" - echo - else - echo "ALL SYSTEMS GO" - fi - rm -f .test.log - exit "$exitcode" -} - -__cleanup() { - echo Cleaning up - rm -f .test.log -} - -trap __cleanup SIGINT SIGTERM - -# Run all tests -find {$BASEDIR/../client,$BASEDIR/../server} -name Makefile | run_test_fast diff --git a/bin/run-tests b/bin/run-tests deleted file mode 100755 index 7ada85b924865..0000000000000 --- a/bin/run-tests +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -NODE_ENV="test" - -RESULT=0 -for makefile in "$@"; do - cat "$makefile" | grep test: > /dev/null - if [[ $? -eq 0 ]]; then - make -C "$(dirname "$makefile")" --no-print-directory test 2>&1; - RESULT=$(($RESULT+$?)); - fi -done -exit $RESULT; diff --git a/circle.yml b/circle.yml index 409d1b621f2ec..abdc10d8b41e8 100644 --- a/circle.yml +++ b/circle.yml @@ -13,26 +13,12 @@ test: - client/**/*.jsx - server/**/*.js - server/**/*.jsx - - NODE_ENV=test ./bin/run-tests: + - MOCHA_FILE=./test-results-client.xml npm run test-client -- -R mocha-junit-reporter -t $CIRCLE_NODE_TOTAL -i $CIRCLE_NODE_INDEX: parallel: true - files: - - client/**/Makefile - - server/**/Makefile - - MOCHA_FILE=./test-results-client.xml npm run test-client -- --reporter=mocha-junit-reporter: + - MOCHA_FILE=./test-results-server.xml npm run test-server -- -R mocha-junit-reporter -t $CIRCLE_NODE_TOTAL -i $CIRCLE_NODE_INDEX: parallel: true - files: - - client/**/test/*.js - - client/**/test/*.jsx - - MOCHA_FILE=./test-results-server.xml npm run test-server -- --reporter=mocha-junit-reporter: + - MOCHA_FILE=./test-results-test.xml npm run test-test -- -R mocha-junit-reporter -t $CIRCLE_NODE_TOTAL -i $CIRCLE_NODE_INDEX: parallel: true - files: - - server/**/test/*.js - - server/**/test/*.jsx - - MOCHA_FILE=./test-results-test.xml npm run test-test -- --reporter=mocha-junit-reporter: - parallel: true - files: - - test/test/**/test/*.js - - test/test/**/test/*.jsx post: - mkdir -p $CIRCLE_TEST_REPORTS/junit/ && find . -type f -regex "./test-results.*\.xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;: parallel: true diff --git a/client/components/button-group/makefile b/client/components/button-group/makefile deleted file mode 100644 index e4d7be5fa9312..0000000000000 --- a/client/components/button-group/makefile +++ /dev/null @@ -1,10 +0,0 @@ -REPORTER ?= spec -NODE_BIN := $(shell npm bin) -MOCHA ?= ../../../node_modules/.bin/mocha -BASE_DIR := $(NODE_BIN)/../.. -NODE_PATH := test:$(BASE_DIR)/client - -test: - @NODE_ENV=test NODE_PATH=$(NODE_PATH) $(MOCHA) --compilers jsx:babel/register --reporter $(REPORTER) - -.PHONY: test diff --git a/client/components/button-group/test/test.js b/client/components/button-group/test/index.js similarity index 84% rename from client/components/button-group/test/test.js rename to client/components/button-group/test/index.js index 6c74bd240cd70..21226cc26a9db 100644 --- a/client/components/button-group/test/test.js +++ b/client/components/button-group/test/index.js @@ -1,6 +1,3 @@ - -require( 'lib/react-test-env-setup' )(); - /** * External dependencies */ @@ -11,10 +8,11 @@ import sinon from 'sinon'; describe( 'ButtonGroup', function() { let sandbox, ButtonGroup, Button; + beforeEach( function() { sandbox = sinon.sandbox.create(); - sandbox.stub( console, 'error'); - sandbox.stub( console, 'log'); + sandbox.stub( console, 'error' ); + sandbox.stub( console, 'log' ); ButtonGroup = require( '../index' ); Button = require( 'components/button' ); @@ -22,7 +20,7 @@ describe( 'ButtonGroup', function() { afterEach( function() { sandbox.restore(); - }) + } ); it( 'should have ButtonGroup class', function() { const buttonGroup = shallow( ); @@ -35,9 +33,8 @@ describe( 'ButtonGroup', function() { } ); it( 'should throw an error if any of the children is not a