Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Minitest support to TagProf #283

Conversation

lioneldebauge
Copy link
Contributor

@lioneldebauge lioneldebauge commented Dec 22, 2023

What is the purpose of this pull request?

Following this discussion this PR aims to add Minitest support for TagProf.

What changes did you make? (overview)

Created a TagProfReporter class which reproduces TestProf::TagProf::RSpecListener behavior. The main differences are:

  • because tags do not exist in Minitest we use subdirectories of main test directory to group tests statistics
  • when a main test directory cannot be determined it groups by test and display a significant warning message

Is there anything you'd like reviewers to focus on?

You can read the comments for my different questions :)

Checklist

  • I've added tests for this change
  • I've added a Changelog entry
  • I've updated a documentation

@@ -30,15 +30,42 @@ That's how a report looks like:

## Instructions

TagProf can only be used with RSpec.
TagProf can be used with both RSpec and Minitest.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure TagProf is a very relevant name for Minitest. I was wondering if I should not create another profiler called DirectoryProf and refer to it in TagProf documentation as a Minitest equivalent. What do you think ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the TagProf name for now. We'll probably add support for other tags beyond "type" in the future (maybe, via integration with some third-party plugins, e.g., minitest-metadat or similar).

private

def main_folder_path(result)
return "subdirectory_not_found: #{result.source_location.first}" if absolute_path_from(result).nil?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is the right behavior. Maybe we want to raise if the root test directory cannot be found ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answered above: let's return :__unknown__

@lioneldebauge lioneldebauge force-pushed the feature/support-minitest-for-directory-profiling branch from 6c3e7e1 to 1a30c6e Compare December 22, 2023 17:15
@lioneldebauge lioneldebauge force-pushed the feature/support-minitest-for-directory-profiling branch from 1a30c6e to 11939ae Compare December 22, 2023 17:25
@lioneldebauge lioneldebauge marked this pull request as ready for review December 22, 2023 17:26
Copy link
Collaborator

@palkan palkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good.

Left a comment regarding unrecognized paths.

And we also have some CI tests problems—could you please take a look?

@@ -30,15 +30,42 @@ That's how a report looks like:

## Instructions

TagProf can only be used with RSpec.
TagProf can be used with both RSpec and Minitest.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the TagProf name for now. We'll probably add support for other tags beyond "type" in the future (maybe, via integration with some third-party plugins, e.g., minitest-metadat or similar).

docs/profilers/tag_prof.md Show resolved Hide resolved
private

def main_folder_path(result)
return "subdirectory_not_found: #{result.source_location.first}" if absolute_path_from(result).nil?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answered above: let's return :__unknown__

docs/profilers/tag_prof.md Outdated Show resolved Hide resolved
@@ -1,6 +1,6 @@
source "https://rubygems.org"

gem "rails", github: "rails/rails"
gem "rails", "~> 7.0"
Copy link
Contributor Author

@lioneldebauge lioneldebauge Feb 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows to fix bugs related to a constant not being loaded in Rails. I fixed it by using only the last stable branch of version 7 but maybe there is a good reason why we don't do that already ?

Bugs were occuring both on my branch and on master

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try adding require "active_support/inflector" somewhere here (before factory_bot):

require "test_prof/factory_bot"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@palkan done. CI is all green on my side 👍

@lioneldebauge
Copy link
Contributor Author

@palkan thanks for the review. I have triggered CI in my fork with my GA free plan and everything should be green and suggestions/comments should be addressed now. Let me know what you think!

Copy link
Collaborator

@palkan palkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work 👍 Thank you!

Will craft a new release soon

@palkan palkan merged commit a98edb5 into test-prof:master Mar 7, 2024
17 checks passed
@mjankowski
Copy link

Looks like a rubygems release was pushed, but no changelog/tag yet?

@palkan
Copy link
Collaborator

palkan commented Mar 8, 2024

Yeah, looks like my git push attempt failed. Thanks for pointing to this! Fixed now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants