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

services: migrate external tap to main repo (WIP) #19385

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

botantony
Copy link
Contributor

@botantony botantony commented Feb 26, 2025

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Any feedback/suggestion is appreciated (help wanted label would be nice). For some reason I cannot generate .rbi file for dynamic methods:

$ /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.3.0/bin/tapioca dsl Homebrew::Cmd::Services
/opt/homebrew/Cellar/ruby/3.4.2/lib/ruby/3.4.0/rubygems.rb:262:in 'Gem.find_spec_for_exe': can't find gem tapioca (>= 0.a) with executable tapioca (Gem::GemNotFoundException)
        from /opt/homebrew/Cellar/ruby/3.4.2/lib/ruby/3.4.0/rubygems.rb:281:in 'Gem.activate_bin_path'
        from bin/tapioca:25:in '<main>'

Maybe I'm doing something wrong

partially resolves #19210

Sorry, something went wrong.

@MikeMcQuaid MikeMcQuaid added the help wanted We want help addressing this label Feb 26, 2025
@MikeMcQuaid
Copy link
Member

Maybe I'm doing something wrong

Can try brew typecheck --update or brew typecheck --update-all (can't remember which).

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Wow, great work so far @botantony! Thanks for this.

@@ -1,13 +1,12 @@
# frozen_string_literal: true
Copy link
Member

Choose a reason for hiding this comment

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

Would be good to also move some of https://github.com/Homebrew/homebrew-services/tree/master/spec into Library/Homebrew/test too for some basic unit testing.

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 tested some specs and it is probably easier to just write them from scratch. homebrew-services repo doesn't use strict types and as the result they "emulate" formula object with OpenStruct. I'll try to write new unit tests that test functions the proper way

Copy link
Member

Choose a reason for hiding this comment

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

@botantony It's ok to not use strict types here and even maintain the emulation for now. The goal is to have this merged with the code as close as possible to that in homebrew-services. Additional refactoring should be in a follow-up PR. Thanks 🙇🏻

@p-linnane
Copy link
Member

Thanks for taking this on @botantony! Have loved seeing all of your great contributions lately!

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looking good @botantony! Think once the specs get ported over as as-is as possible: this should be good to merge!

@Homebrew Homebrew deleted a comment from knka983 Mar 2, 2025
@botantony
Copy link
Contributor Author

does anyone have an idea why this test may fail?

  describe "#dest" do
    it "macOS - outputs the destination for the service file" do
      ENV["HOME"] = "/tmp_home"

      allow(Service::System).to receive_messages(launchctl?: true, systemctl?: false)
      expect(service.dest.to_s).to eq("/tmp_home/Library/LaunchAgents/homebrew.mysql.plist")
    end

    it "systemD - outputs the destination for the service file" do
      ENV["HOME"] = "/tmp_home"

      allow(Service::System).to receive_messages(launchctl?: false, systemctl?: true)
      expect(service.dest.to_s).to eq("/tmp_home/.config/systemd/user/homebrew.mysql.service")
    end
  end

shell output:

  1) Service::FormulaWrapper#dest systemD - outputs the destination for the service file
     Failure/Error: expect(service.dest.to_s).to eq("/tmp_home/.config/systemd/user/homebrew.mysql.service")

       expected: "/tmp_home/.config/systemd/user/homebrew.mysql.service"
            got: "/tmp_home/Library/LaunchAgents/homebrew.mysql.service"

       (compared using ==)
     # ./test/services/formulae_wrapper_spec.rb:121:in `block (3 levels) in <top (required)>'

it tests formula_wrapper.rb

@MikeMcQuaid
Copy link
Member

does anyone have an idea why this test may fail?

@botantony My best guess is something was being mocked successfully before but is not being mocked in the test now?

@botantony
Copy link
Contributor Author

Oh, I found the issue, there's no need to set values in before block. Thank you Mike!

@botantony
Copy link
Contributor Author

🤔
image
image

@Bo98
Copy link
Member

Bo98 commented Mar 7, 2025

The tap tests redefines opoo to stdout: https://github.com/Homebrew/homebrew-services/blob/5f26f05cf986f418d83931ce2085b44b4213a9d8/spec/spec_helper.rb#L123 whereas the regular behaviour puts it to stderr.

So you'll need to separate that output to check the root message under stderr and the success message under stdout

.to output(...).to_stdout
.and output(...).to_stderr

Verified

This commit was signed with the committer’s verified signature.
EricFromCanada Eric Knibbe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted We want help addressing this
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Combine Homebrew organisation repositories
4 participants