test-prof 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29df0c008d08c25f6924b35fd76cf02e7747c116
4
- data.tar.gz: 1216e9ee73060c8d20e2caa94b2d1fd5f9c70292
3
+ metadata.gz: 801b84df6d3f7ee580f2cdd0bb907a5d973d0f12
4
+ data.tar.gz: 7a1295fa606ba8fcbdb6d22867e0b6dfb5709519
5
5
  SHA512:
6
- metadata.gz: d0b7e7e899c7a81512d686e4bfac89937f8c37df476ffc94daf7e351476b131c6301c8528731e263fc36a4c1397be5876fc053cf837cb51777a2dcb5ae1687f5
7
- data.tar.gz: 143c0eb3c07ecbad124299395e06bc4174bda227a5ec36c4e71eb5c8d67eb6079e7f62a138c24da98d6dbc1c887529bf8105dc3c2e46b4df1cd4bbd06a65144b
6
+ metadata.gz: '078e932d7605e8399820ecdd3d7b4ee1098093c73d4f0f647c94ba095fad4b64531848304f86a3e1debce528bf815d2f78085b983c20ab906d0ca388d1874522'
7
+ data.tar.gz: '09c1d29d373158828d5d44d0a96a2413960934a60170b81a1f3974bc9c10e59fcdf4bcb20df2f842cd2985d82510c9e46ba024eca4f080d6008656e72a86a649'
data/CHANGELOG.md CHANGED
@@ -1,7 +1,27 @@
1
1
  # Change log
2
2
 
3
+ ## master
4
+
5
+ ## 0.2.0
6
+
7
+ - Ensure output directory exists. ([@danielwestendorf][])
8
+
9
+ **Change default output dir** to "tmp/test_prof".
10
+
11
+ Rename `#artefact_path` to `#artifact_path` to be more US-like
12
+
13
+ Ensure output dir exists in `#artifact_path` method.
14
+
15
+ - FactoryDoctor: print success message when no bad examples found. ([@palkan][])
16
+
17
+ ## 0.1.1
18
+
19
+ - AnyFixture: clean tables in reverse order to not fail when foreign keys exist. ([@marshall-lee][])
20
+
3
21
  ## 0.1.0
4
22
 
5
23
  - Initial version. ([@palkan][])
6
24
 
7
25
  [@palkan]: https://github.com/palkan
26
+ [@marshall-lee]: https://github.com/marshall-lee
27
+ [@danielwestendorf]: https://github.com/danielwestendorf
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Gem Version](https://badge.fury.io/rb/test-prof.svg)](https://rubygems.org/gems/test-prof) [![Build Status](https://travis-ci.org/palkan/test-prof.svg?branch=master)](https://travis-ci.org/palkan/test-prof) [![CircleCI](https://circleci.com/gh/palkan/test-prof.svg?style=svg)](https://circleci.com/gh/palkan/test-prof)
1
+ [![Gem Version](https://badge.fury.io/rb/test-prof.svg)](https://rubygems.org/gems/test-prof) [![Build Status](https://travis-ci.org/palkan/test-prof.svg?branch=master)](https://travis-ci.org/palkan/test-prof) [![CircleCI](https://circleci.com/gh/palkan/test-prof.svg?style=svg)](https://circleci.com/gh/palkan/test-prof) [![Code Triagers Badge](https://www.codetriage.com/palkan/test-prof/badges/users.svg)](https://www.codetriage.com/palkan/test-prof)
2
2
 
3
3
  # Ruby Tests Profiling Toolbox
4
4
 
@@ -29,6 +29,8 @@ See [Table of Contents](#table-of-contents) for more.
29
29
 
30
30
  ## Resources
31
31
 
32
+ - [TestProf: a good doctor for slow Ruby tests](https://evilmartians.com/chronicles/testprof-a-good-doctor-for-slow-ruby-tests)
33
+
32
34
  - RubyConfBy, 2017, "Run Test Run" talk [[video](https://www.youtube.com/watch?v=q52n4p0wkIs), [slides](https://speakerdeck.com/palkan/rubyconfby-minsk-2017-run-test-run)]
33
35
 
34
36
  - [Tips to improve speed of your test suite](https://medium.com/appaloosa-store-engineering/tips-to-improve-speed-of-your-test-suite-8418b485205c) by [Benoit Tigeot](https://github.com/benoittgt)
@@ -83,7 +85,7 @@ TestProf global configuration is used by most of the profilers:
83
85
 
84
86
  ```ruby
85
87
  TestProf.configure do |config|
86
- # the directory to put artifacts (reports) in ("tmp" by default)
88
+ # the directory to put artifacts (reports) in ("tmp/test_prof" by default)
87
89
  config.output_dir = "tmp/test_prof"
88
90
 
89
91
  # use unique filenames for reports (by simply appending current timestamp)
@@ -30,7 +30,7 @@ And we want to test the `Task` model:
30
30
 
31
31
  ```ruby
32
32
  describe "PATCH #update" do
33
- let(:task( { create(:task) }
33
+ let(:task) { create(:task) }
34
34
 
35
35
  it "works" do
36
36
  patch :update, id: task.id, task: { completed: 't' }
@@ -34,7 +34,7 @@ module TestProf
34
34
 
35
35
  # Clean all affected tables (but do not reset cache)
36
36
  def clean
37
- tables_cache.keys.each do |table|
37
+ tables_cache.keys.reverse_each do |table|
38
38
  ActiveRecord::Base.connection.execute %(
39
39
  DELETE FROM #{table}
40
40
  )
@@ -8,6 +8,8 @@ module TestProf
8
8
  include Logging
9
9
  using FloatDuration
10
10
 
11
+ SUCCESS_MESSAGE = 'FactoryDoctor says: "Looks good to me!"'
12
+
11
13
  NOTIFICATIONS = %i[
12
14
  example_started
13
15
  example_finished
@@ -42,7 +44,7 @@ module TestProf
42
44
  end
43
45
 
44
46
  def print
45
- return if @example_groups.empty?
47
+ return log(:info, SUCCESS_MESSAGE) if @example_groups.empty?
46
48
 
47
49
  msgs = []
48
50
 
@@ -61,7 +61,7 @@ module TestProf::FactoryProf
61
61
  template = File.read(TestProf.asset_path("flamegraph.template.html"))
62
62
  template.sub! '/**REPORT-DATA**/', data.to_json
63
63
 
64
- outpath = TestProf.artefact_path("factory-flame.html")
64
+ outpath = TestProf.artifact_path("factory-flame.html")
65
65
  File.write(outpath, template)
66
66
  outpath
67
67
  end
@@ -107,7 +107,7 @@ module TestProf
107
107
  private
108
108
 
109
109
  def build_path(name, printer)
110
- TestProf.artefact_path(
110
+ TestProf.artifact_path(
111
111
  "ruby-prof-report-#{printer}-#{config.mode}-#{name}.html"
112
112
  )
113
113
  end
@@ -98,7 +98,7 @@ module TestProf
98
98
  private
99
99
 
100
100
  def build_path(name)
101
- TestProf.artefact_path(
101
+ TestProf.artifact_path(
102
102
  "stack-prof-report-#{config.mode}#{config.raw ? '-raw' : ''}-#{name}.dump"
103
103
  )
104
104
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TestProf
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/test_prof.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "fileutils"
3
4
  require "test_prof/version"
4
5
  require "test_prof/logging"
5
6
 
@@ -58,8 +59,10 @@ module TestProf
58
59
  ::File.expand_path(filename, ::File.join(::File.dirname(__FILE__), "..", "assets"))
59
60
  end
60
61
 
61
- # Return a path to store artefact
62
- def artefact_path(filename)
62
+ # Return a path to store artifact
63
+ def artifact_path(filename)
64
+ FileUtils.mkdir_p(config.output_dir)
65
+
63
66
  with_timestamps(
64
67
  ::File.join(
65
68
  config.output_dir,
@@ -91,7 +94,7 @@ module TestProf
91
94
  def initialize
92
95
  @output = $stdout
93
96
  @color = true
94
- @output_dir = "tmp"
97
+ @output_dir = "tmp/test_prof"
95
98
  @timestamps = false
96
99
  end
97
100
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-prof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-15 00:00:00.000000000 Z
11
+ date: 2017-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler