From 08ce7f6c934a61e11292432a2f41b3b028fae23e Mon Sep 17 00:00:00 2001 From: Andrej Ocenas Date: Thu, 4 Apr 2019 14:48:11 +0200 Subject: [PATCH] Chore: Add task to find FocusConvey tests (#16381) --- pkg/tsdb/mysql/mysql_test.go | 2 +- scripts/grunt/default_task.js | 46 +++++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/pkg/tsdb/mysql/mysql_test.go b/pkg/tsdb/mysql/mysql_test.go index fe59a4b9d9d..e6a1b3a84d2 100644 --- a/pkg/tsdb/mysql/mysql_test.go +++ b/pkg/tsdb/mysql/mysql_test.go @@ -593,7 +593,7 @@ func TestMySQL(t *testing.T) { So(queryResult.Series[0].Points[0][1].Float64, ShouldEqual, float64(tInitial.UnixNano()/1e6)) }) - FocusConvey("When doing a metric query using epoch (int32) as time column and value column (int32) should return metric with time in milliseconds", func() { + Convey("When doing a metric query using epoch (int32) as time column and value column (int32) should return metric with time in milliseconds", func() { query := &tsdb.TsdbQuery{ Queries: []*tsdb.Query{ { diff --git a/scripts/grunt/default_task.js b/scripts/grunt/default_task.js index a656e0c60af..7619ef8601c 100644 --- a/scripts/grunt/default_task.js +++ b/scripts/grunt/default_task.js @@ -1,52 +1,68 @@ // Lint and build CSS -module.exports = function (grunt) { +module.exports = function(grunt) { 'use strict'; + // prettier-ignore grunt.registerTask('default', [ 'clean:build', 'phantomjs', - 'webpack:dev', + 'webpack:dev' ]); + // prettier-ignore grunt.registerTask('test', [ 'sasslint', 'tslint', 'typecheck', - "exec:jest", - 'no-only-tests' + 'exec:jest', + 'no-only-tests', + 'no-focus-convey-tests' ]); + // prettier-ignore grunt.registerTask('tslint', [ 'newer:exec:tslintPackages', - 'newer:exec:tslintRoot', + 'newer:exec:tslintRoot' ]); + // prettier-ignore grunt.registerTask('typecheck', [ 'newer:exec:typecheckPackages', - 'newer:exec:typecheckRoot', + 'newer:exec:typecheckRoot' ]); + // prettier-ignore grunt.registerTask('precommit', [ 'newer:sasslint', 'typecheck', 'tslint', - 'no-only-tests' + 'no-only-tests', + 'no-focus-convey-tests' ]); - grunt.registerTask('no-only-tests', function () { + grunt.registerTask('no-only-tests', function() { var files = grunt.file.expand( - 'public/**/*@(_specs|\.test)\.@(ts|js|tsx|jsx)', - 'packages/grafana-ui/**/*@(_specs|\.test)\.@(ts|js|tsx|jsx)' + 'public/**/*@(_specs|.test).@(ts|js|tsx|jsx)', + 'packages/grafana-ui/**/*@(_specs|.test).@(ts|js|tsx|jsx)' ); + grepFiles(files, '.only(', 'found only statement in test: '); + }); - files.forEach(function (spec) { + grunt.registerTask('no-focus-convey-tests', function() { + var files = grunt.file.expand('pkg/**/*_test.go'); + grepFiles(files, 'FocusConvey(', 'found FocusConvey statement in test: '); + }); + + function grepFiles(files, pattern, errorMessage) { + files.forEach(function(spec) { var rows = grunt.file.read(spec).split('\n'); - rows.forEach(function (row) { - if (row.indexOf('.only(') > 0) { + rows.forEach(function(row) { + if (row.indexOf(pattern) > 0) { grunt.log.errorlns(row); - grunt.fail.warn('found only statement in test: ' + spec); + grunt.fail.warn(errorMessage + spec); } }); }); - }); + } }; +