smartest 0.2.1 → 0.2.2
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 +4 -4
- data/README.md +13 -1
- data/exe/smartest +4 -4
- data/lib/smartest/cli_arguments.rb +4 -8
- data/lib/smartest/version.rb +1 -1
- data/smartest/smartest_test.rb +52 -9
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5f8abe11f15ae34b9c69f3c63baa01a2c724d5027b6acb842c9ed19fd3ab0fd4
|
|
4
|
+
data.tar.gz: 1db282b10807ae9e31115cabe6df364979e57690455a0da30775c7e9c5f65349
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 60bd8acff86dc1ad7f2e4614b4dc1d34d0f2ba60d3ccdccece9f451dd9ea57510b77b572f69fa6163e5299165778e8bed051d93f8568cdc1c6c21416ed639f3d
|
|
7
|
+
data.tar.gz: 5ae7701a9471265a7ff113d9db3dae538ea47b6314a7a8162c817f8bfe425cce757d1b32b12a08d70b7912f6643cb777154b96f4e960710a90de4a12595e7ae9
|
data/README.md
CHANGED
|
@@ -98,6 +98,14 @@ bundle exec smartest smartest/user_test.rb:12
|
|
|
98
98
|
bundle exec smartest smartest/user_test.rb:3-12
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
+
Smartest prints the 5 slowest tests after each CLI run by default. Use
|
|
102
|
+
`--profile N` to choose a different count:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
bundle exec smartest --profile 10
|
|
106
|
+
bundle exec smartest --profile 3 smartest/user_test.rb
|
|
107
|
+
```
|
|
108
|
+
|
|
101
109
|
CLI help and version output are available with:
|
|
102
110
|
|
|
103
111
|
```bash
|
|
@@ -105,13 +113,17 @@ bundle exec smartest --help
|
|
|
105
113
|
bundle exec smartest --version
|
|
106
114
|
```
|
|
107
115
|
|
|
108
|
-
|
|
116
|
+
Output resembles:
|
|
109
117
|
|
|
110
118
|
```text
|
|
111
119
|
Running 1 test
|
|
112
120
|
|
|
113
121
|
✓ example
|
|
114
122
|
|
|
123
|
+
Top 1 slowest test (0.00001 seconds, 100.0% of total time):
|
|
124
|
+
example
|
|
125
|
+
0.00001 seconds .../smartest/example_test.rb:3
|
|
126
|
+
|
|
115
127
|
1 test, 1 passed, 0 failed
|
|
116
128
|
```
|
|
117
129
|
|
data/exe/smartest
CHANGED
|
@@ -7,15 +7,15 @@ require "smartest"
|
|
|
7
7
|
|
|
8
8
|
usage = <<~USAGE
|
|
9
9
|
Usage:
|
|
10
|
-
smartest [paths...]
|
|
11
|
-
smartest path/to/test_file.rb:line[-line]
|
|
12
|
-
smartest --profile [N]
|
|
10
|
+
smartest [--profile N] [paths...]
|
|
11
|
+
smartest [--profile N] path/to/test_file.rb:line[-line]
|
|
13
12
|
smartest --init
|
|
14
13
|
smartest --version
|
|
15
14
|
smartest --help
|
|
16
15
|
|
|
17
16
|
When no paths are given, Smartest loads smartest/**/*_test.rb.
|
|
18
|
-
|
|
17
|
+
Smartest prints the 5 slowest tests after the run by default.
|
|
18
|
+
Use --profile N to choose how many slowest tests are printed.
|
|
19
19
|
USAGE
|
|
20
20
|
|
|
21
21
|
command = :run
|
|
@@ -12,7 +12,7 @@ module Smartest
|
|
|
12
12
|
@files = []
|
|
13
13
|
@whole_files = Set.new
|
|
14
14
|
@line_filters = Hash.new { |hash, key| hash[key] = Set.new }
|
|
15
|
-
@profile_count =
|
|
15
|
+
@profile_count = DEFAULT_PROFILE_COUNT
|
|
16
16
|
|
|
17
17
|
paths = extract_options(argv)
|
|
18
18
|
parse_paths(paths.empty? ? ["smartest/**/*_test.rb"] : paths)
|
|
@@ -45,17 +45,13 @@ module Smartest
|
|
|
45
45
|
|
|
46
46
|
case argument
|
|
47
47
|
when "--profile"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
@profile_count = next_argument.to_i
|
|
48
|
+
if argv[index + 1]&.match?(/\A\d+\z/)
|
|
49
|
+
@profile_count = argv[index + 1].to_i
|
|
51
50
|
index += 2
|
|
52
51
|
else
|
|
53
|
-
|
|
52
|
+
paths << argument
|
|
54
53
|
index += 1
|
|
55
54
|
end
|
|
56
|
-
when /\A--profile=(\d+)\z/
|
|
57
|
-
@profile_count = Regexp.last_match(1).to_i
|
|
58
|
-
index += 1
|
|
59
55
|
else
|
|
60
56
|
paths << argument
|
|
61
57
|
index += 1
|
data/lib/smartest/version.rb
CHANGED
data/smartest/smartest_test.rb
CHANGED
|
@@ -1566,10 +1566,10 @@ test("cli prints help") do
|
|
|
1566
1566
|
expect(status.success?).to eq(true)
|
|
1567
1567
|
expect(stderr).to eq("")
|
|
1568
1568
|
expect(stdout).to include("Usage:")
|
|
1569
|
-
expect(stdout).to include("smartest [paths...]")
|
|
1570
|
-
expect(stdout).to include("smartest path/to/test_file.rb:line[-line]")
|
|
1569
|
+
expect(stdout).to include("smartest [--profile N] [paths...]")
|
|
1570
|
+
expect(stdout).to include("smartest [--profile N] path/to/test_file.rb:line[-line]")
|
|
1571
1571
|
expect(stdout).to include("smartest --init")
|
|
1572
|
-
expect(stdout).to include("
|
|
1572
|
+
expect(stdout).to include("Use --profile N")
|
|
1573
1573
|
expect(stdout).to include("smartest/**/*_test.rb")
|
|
1574
1574
|
end
|
|
1575
1575
|
|
|
@@ -1664,15 +1664,58 @@ test("--profile is not printed when there are no results") do
|
|
|
1664
1664
|
expect(output.string).not_to include("slowest")
|
|
1665
1665
|
end
|
|
1666
1666
|
|
|
1667
|
-
test("CLIArguments parses --profile
|
|
1668
|
-
|
|
1667
|
+
test("CLIArguments defaults profile count and parses --profile N") do
|
|
1668
|
+
arguments = Smartest::CLIArguments.new([])
|
|
1669
|
+
|
|
1670
|
+
expect(arguments.profile_count).to eq(5)
|
|
1671
|
+
expect(arguments.files).to eq(Dir["smartest/**/*_test.rb"])
|
|
1669
1672
|
expect(Smartest::CLIArguments.new(["--profile", "3"]).profile_count).to eq(3)
|
|
1670
|
-
expect(Smartest::CLIArguments.new(["--profile=7"]).profile_count).to eq(7)
|
|
1671
|
-
expect(Smartest::CLIArguments.new([]).profile_count).to eq(nil)
|
|
1672
|
-
expect(Smartest::CLIArguments.new(["--profile", "smartest/foo_test.rb"]).profile_count).to eq(5)
|
|
1673
1673
|
end
|
|
1674
1674
|
|
|
1675
|
-
test("
|
|
1675
|
+
test("CLIArguments leaves unsupported profile forms as paths") do
|
|
1676
|
+
equals_form = Smartest::CLIArguments.new(["--profile=7"])
|
|
1677
|
+
missing_count = Smartest::CLIArguments.new(["--profile"])
|
|
1678
|
+
path_after_profile = Smartest::CLIArguments.new(["--profile", "smartest/foo_test.rb"])
|
|
1679
|
+
|
|
1680
|
+
expect(equals_form.profile_count).to eq(5)
|
|
1681
|
+
expect(equals_form.files).to eq(["--profile=7"])
|
|
1682
|
+
expect(missing_count.profile_count).to eq(5)
|
|
1683
|
+
expect(missing_count.files).to eq(["--profile"])
|
|
1684
|
+
expect(path_after_profile.profile_count).to eq(5)
|
|
1685
|
+
expect(path_after_profile.files).to eq(["--profile", "smartest/foo_test.rb"])
|
|
1686
|
+
end
|
|
1687
|
+
|
|
1688
|
+
test("cli runs without --profile N and prints default slowest tests") do
|
|
1689
|
+
Dir.mktmpdir do |dir|
|
|
1690
|
+
smartest_dir = File.join(dir, "smartest")
|
|
1691
|
+
FileUtils.mkdir_p(smartest_dir)
|
|
1692
|
+
File.write(File.join(smartest_dir, "sample_test.rb"), <<~RUBY)
|
|
1693
|
+
require "smartest/autorun"
|
|
1694
|
+
|
|
1695
|
+
test("default first") do
|
|
1696
|
+
expect(1).to eq(1)
|
|
1697
|
+
end
|
|
1698
|
+
|
|
1699
|
+
test("default second") do
|
|
1700
|
+
expect(1).to eq(1)
|
|
1701
|
+
end
|
|
1702
|
+
RUBY
|
|
1703
|
+
|
|
1704
|
+
stdout, stderr, status = Open3.capture3(
|
|
1705
|
+
{ "RUBYLIB" => File.expand_path("../lib", __dir__) },
|
|
1706
|
+
"ruby",
|
|
1707
|
+
File.expand_path("../exe/smartest", __dir__),
|
|
1708
|
+
chdir: dir
|
|
1709
|
+
)
|
|
1710
|
+
|
|
1711
|
+
expect(status.success?).to eq(true)
|
|
1712
|
+
expect(stderr).to eq("")
|
|
1713
|
+
expect(stdout).to include("Top 2 slowest tests")
|
|
1714
|
+
expect(stdout).to include("2 tests, 2 passed, 0 failed")
|
|
1715
|
+
end
|
|
1716
|
+
end
|
|
1717
|
+
|
|
1718
|
+
test("cli runs with --profile N and prints requested slowest tests") do
|
|
1676
1719
|
Dir.mktmpdir do |dir|
|
|
1677
1720
|
smartest_dir = File.join(dir, "smartest")
|
|
1678
1721
|
FileUtils.mkdir_p(smartest_dir)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: smartest
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yusuke Iwaki
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-04-
|
|
11
|
+
date: 2026-04-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|