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

Wrap options_string values in quotes #633

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

KaanOzkan
Copy link
Contributor

No description provided.

@KaanOzkan KaanOzkan requested a review from a team as a code owner January 23, 2025 15:58
Copy link
Collaborator

@Morriar Morriar left a comment

Choose a reason for hiding this comment

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

Can we also add a test showing how Sorbet behaves when we run it? Maybe through tc test? https://github.com/Shopify/spoom/blob/cbe88be63783e0e593780b4151e6b98251de0f60/test/spoom/cli/srb/tc_test.rb

@project.remove!("sorbet/config")
result = @project.spoom("srb coverage report --no-color")
assert_empty(result.out)
assert_equal("Error: not in a Sorbet project (`sorbet/config` not found)", result.err&.lines&.first&.chomp)
refute(result.status)

# Restore original config
@project.write!("sorbet/config", sorbet_config)
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 don't know why removing the config didn't cause problems before. I can't find anywhere where we add . to the sorbet/config again.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure why we need this, every test should be reinitialized with a proper config using new_project https://github.com/Shopify/spoom/blob/main/test/test_helper.rb#L18-L24.

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 thought it was called just once at the beginning

@project = T.let(new_project, TestProject)

Copy link
Collaborator

Choose a reason for hiding this comment

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

When you run the test, a new instance should be created for each test case so the initialize method should be called for each test_ method, you can put a print in new_project to confirm.

@@ -488,6 +492,45 @@ def test_finish_on_original_branch
assert_equal("fake-branch", @project.git_current_branch)
end

def test_config_options_string
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Morriar I went with a coverage test since it uses the options parsing. This test checks that the metrics are altered after ignoring one of the files.

@project.remove!("sorbet/config")
result = @project.spoom("srb coverage report --no-color")
assert_empty(result.out)
assert_equal("Error: not in a Sorbet project (`sorbet/config` not found)", result.err&.lines&.first&.chomp)
refute(result.status)

# Restore original config
@project.write!("sorbet/config", sorbet_config)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure why we need this, every test should be reinitialized with a proper config using new_project https://github.com/Shopify/spoom/blob/main/test/test_helper.rb#L18-L24.

def test_config_options_string
sorbet_config = @project.read("sorbet/config")
# Add ignore path to config to test config options string
@project.write!("sorbet/config", "\n--ignore=lib/a.rb", append: true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we try with a wildcard * to show the expected behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done below as a new test.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The coverage tests are kind of expensive, do you mind merging both of them please?

@KaanOzkan KaanOzkan force-pushed the ko/quote-config branch 2 times, most recently from aa9fc58 to c4791d3 Compare January 24, 2025 18:54
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.

2 participants