diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 8de3db2762..55fee1927d 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2014-09-26T16:56:14+10:00 from the rspec-dev repo. +# This file was generated on 2014-10-30T08:23:40-07:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/.travis.yml b/.travis.yml index 67cc663934..2367ca1b94 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# This file was generated on 2014-09-26T16:56:14+10:00 from the rspec-dev repo. +# This file was generated on 2014-10-30T08:23:40-07:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. language: ruby @@ -19,6 +19,7 @@ rvm: - 2.1.1 - 2.1.2 - 2.1.3 + - 2.1.4 - ruby-head - ree - jruby-18mode diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index d03e9f6f36..fb840d7aba 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,8 +1,8 @@ #!/bin/bash -# This file was generated on 2014-09-26T16:56:14+10:00 from the rspec-dev repo. +# This file was generated on 2014-10-30T08:23:40-07:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. -set -e -x +set -e source script/functions.sh if is_mri; then diff --git a/script/functions.sh b/script/functions.sh index daf776e19a..0ff87a8baf 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,80 +1,14 @@ -# This file was generated on 2014-09-26T16:56:14+10:00 from the rspec-dev repo. +# This file was generated on 2014-10-30T08:23:40-07:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. +source script/travis_functions.sh +source script/predicate_functions.sh + # idea taken from: http://blog.headius.com/2010/03/jruby-startup-time-tips.html export JRUBY_OPTS="${JRUBY_OPTS} -X-C" # disable JIT since these processes are so short lived SPECS_HAVE_RUN_FILE=specs.out MAINTENANCE_BRANCH=`cat maintenance-branch` -# Taken from: -# https://github.com/travis-ci/travis-build/blob/e9314616e182a23e6a280199cd9070bfc7cae548/lib/travis/build/script/templates/header.sh#L34-L53 -travis_retry() { - local result=0 - local count=1 - while [ $count -le 3 ]; do - [ $result -ne 0 ] && { - echo -e "\n\033[33;1mThe command \"$@\" failed. Retrying, $count of 3.\033[0m\n" >&2 - } - "$@" - result=$? - [ $result -eq 0 ] && break - count=$(($count + 1)) - sleep 1 - done - - [ $count -eq 3 ] && { - echo "\n\033[33;1mThe command \"$@\" failed 3 times.\033[0m\n" >&2 - } - - return $result -} - -function is_mri { - if ruby -e "exit(!defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby')"; then - # RUBY_ENGINE only returns 'ruby' on MRI. - # MRI 1.8.7 lacks the constant but all other rubies have it (including JRuby in 1.8 mode) - return 0 - else - return 1 - fi; -} - -function is_mri_192 { - if is_mri; then - if ruby -e "exit(RUBY_VERSION == '1.9.2')"; then - return 0 - else - return 1 - fi - else - return 1 - fi -} - -function rspec_support_compatible { - if [ "$MAINTENANCE_BRANCH" != "2-99-maintenance" ] && [ "$MAINTENANCE_BRANCH" != "2-14-maintenance" ]; then - return 0 - else - return 1 - fi -} - -function documentation_enforced { - if [ -x ./bin/yard ]; then - return 0 - else - return 1 - fi -} - -function style_and_lint_enforced { - if [ -x ./bin/rubocop ]; then - return 0 - else - return 1 - fi -} - function clone_repo { if [ ! -d $1 ]; then # don't clone if the dir is already there travis_retry eval "git clone git://github.com/rspec/$1 --depth 1 --branch $MAINTENANCE_BRANCH" @@ -90,6 +24,7 @@ function run_specs_and_record_done { rspec_bin=script/rspec_with_simplecov fi; + echo "${PWD}/bin/rspec" $rspec_bin spec --backtrace --format progress --profile --format progress --out $SPECS_HAVE_RUN_FILE } @@ -102,6 +37,8 @@ function run_cukes { # spec failures in our spec suite due to problems with this mode. export JAVA_OPTS='-client -XX:+TieredCompilation -XX:TieredStopAtLevel=1' + echo "${PWD}/bin/cucumber" + if is_mri_192; then # For some reason we get SystemStackError on 1.9.2 when using # the bin/cucumber approach below. That approach is faster @@ -118,6 +55,8 @@ function run_cukes { } function run_specs_one_by_one { + echo "Running each spec file, one-by-one..." + for file in `find spec -iname '*_spec.rb'`; do bin/rspec $file -b --format progress done @@ -125,10 +64,8 @@ function run_specs_one_by_one { function run_spec_suite_for { if [ ! -f ../$1/$SPECS_HAVE_RUN_FILE ]; then # don't rerun specs that have already run - pushd ../$1 - echo echo "Running specs for $1" - echo + pushd ../$1 unset BUNDLE_GEMFILE bundle_install_flags=`cat .travis.yml | grep bundler_args | tr -d '"' | grep -o " .*"` travis_retry eval "bundle install $bundle_install_flags" @@ -138,8 +75,11 @@ function run_spec_suite_for { } function check_documentation_coverage { + echo "bin/yard stats --list-undoc" + bin/yard stats --list-undoc | ruby -e " while line = gets + has_warnings ||= line.start_with?('[warn]:') coverage ||= line[/([\d\.]+)% documented/, 1] puts line end @@ -148,21 +88,27 @@ function check_documentation_coverage { puts \"\n\nMissing documentation coverage (currently at #{coverage}%)\" exit(1) end + + if has_warnings + puts \"\n\nYARD emitted documentation warnings.\" + exit(1) + end " } function check_style_and_lint { + echo "bin/rubucop lib" bin/rubocop lib } function run_all_spec_suites { - run_specs_one_by_one - run_spec_suite_for "rspec-core" - run_spec_suite_for "rspec-expectations" - run_spec_suite_for "rspec-mocks" - run_spec_suite_for "rspec-rails" + fold "one-by-one specs" run_specs_one_by_one + fold "rspec-core specs" run_spec_suite_for "rspec-core" + fold "rspec-expectations specs" run_spec_suite_for "rspec-expectations" + fold "rspec-mocks specs" run_spec_suite_for "rspec-mocks" + fold "rspec-rails specs" run_spec_suite_for "rspec-rails" if rspec_support_compatible; then - run_spec_suite_for "rspec-support" + fold "rspec-support specs" run_spec_suite_for "rspec-support" fi } diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh new file mode 100644 index 0000000000..cc4a73dbbf --- /dev/null +++ b/script/predicate_functions.sh @@ -0,0 +1,48 @@ +# This file was generated on 2014-10-30T08:23:40-07:00 from the rspec-dev repo. +# DO NOT modify it by hand as your changes will get lost the next time it is generated. + +function is_mri { + if ruby -e "exit(!defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby')"; then + # RUBY_ENGINE only returns 'ruby' on MRI. + # MRI 1.8.7 lacks the constant but all other rubies have it (including JRuby in 1.8 mode) + return 0 + else + return 1 + fi; +} + +function is_mri_192 { + if is_mri; then + if ruby -e "exit(RUBY_VERSION == '1.9.2')"; then + return 0 + else + return 1 + fi + else + return 1 + fi +} + +function rspec_support_compatible { + if [ "$MAINTENANCE_BRANCH" != "2-99-maintenance" ] && [ "$MAINTENANCE_BRANCH" != "2-14-maintenance" ]; then + return 0 + else + return 1 + fi +} + +function documentation_enforced { + if [ -x ./bin/yard ]; then + return 0 + else + return 1 + fi +} + +function style_and_lint_enforced { + if [ -x ./bin/rubocop ]; then + return 0 + else + return 1 + fi +} diff --git a/script/run_build b/script/run_build index eb356b8bf8..6618219085 100755 --- a/script/run_build +++ b/script/run_build @@ -1,8 +1,8 @@ #!/bin/bash -# This file was generated on 2014-09-26T16:56:14+10:00 from the rspec-dev repo. +# This file was generated on 2014-10-30T08:23:40-07:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. -set -e -x +set -e source script/functions.sh # Allow repos to override the default functions and add their own @@ -10,15 +10,15 @@ if [ -f script/custom_build_functions.sh ]; then source script/custom_build_functions.sh fi -run_specs_and_record_done -run_cukes +fold "specs" run_specs_and_record_done +fold "cukes" run_cukes if documentation_enforced; then - check_documentation_coverage + fold "doc check" check_documentation_coverage fi if style_and_lint_enforced; then - check_style_and_lint + fold "rubocop" check_style_and_lint fi if is_mri; then diff --git a/script/travis_functions.sh b/script/travis_functions.sh new file mode 100644 index 0000000000..0e1715dba4 --- /dev/null +++ b/script/travis_functions.sh @@ -0,0 +1,66 @@ +# This file was generated on 2014-10-30T08:23:40-07:00 from the rspec-dev repo. +# DO NOT modify it by hand as your changes will get lost the next time it is generated. + +# Taken from: +# https://github.com/travis-ci/travis-build/blob/e9314616e182a23e6a280199cd9070bfc7cae548/lib/travis/build/script/templates/header.sh#L34-L53 +travis_retry() { + local result=0 + local count=1 + while [ $count -le 3 ]; do + [ $result -ne 0 ] && { + echo -e "\n\033[33;1mThe command \"$@\" failed. Retrying, $count of 3.\033[0m\n" >&2 + } + "$@" + result=$? + [ $result -eq 0 ] && break + count=$(($count + 1)) + sleep 1 + done + + [ $count -eq 3 ] && { + echo "\n\033[33;1mThe command \"$@\" failed 3 times.\033[0m\n" >&2 + } + + return $result +} + +# Taken from https://github.com/vcr/vcr/commit/fa96819c92b783ec0c794f788183e170e4f684b2 +# and https://github.com/vcr/vcr/commit/040aaac5370c68cd13c847c076749cd547a6f9b1 +nano_cmd="$(type -p gdate date | head -1)" +nano_format="+%s%N" +[ "$(uname -s)" != "Darwin" ] || nano_format="${nano_format/%N/000000000}" + +travis_time_start() { + travis_timer_id=$(printf %08x $(( RANDOM * RANDOM ))) + travis_start_time=$($nano_cmd -u "$nano_format") + printf "travis_time:start:%s\r\e[0m" $travis_timer_id +} + +travis_time_finish() { + local travis_end_time=$($nano_cmd -u "$nano_format") + local duration=$(($travis_end_time-$travis_start_time)) + printf "travis_time:end:%s:start=%s,finish=%s,duration=%s\r\e[0m" \ + $travis_timer_id $travis_start_time $travis_end_time $duration +} + +fold() { + local name="$1" + local status=0 + shift 1 + if [ -n "$TRAVIS" ]; then + printf "travis_fold:start:%s\r\e[0m" "$name" + travis_time_start + fi + + "$@" || status=$? + + [ -z "$TRAVIS" ] || travis_time_finish + + if [ "$status" -eq 0 ]; then + if [ -n "$TRAVIS" ]; then + printf "travis_fold:end:%s\r\e[0m" "$name" + fi + else + STATUS="$status" + fi +}