From 95aab5a8a8d1561b85a91e8eca2d4f8d63520fe7 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 15 Apr 2020 05:35:36 +0000 Subject: [PATCH 1/3] build(deps): bump parser from 2.7.1.0 to 2.7.1.1 in /Library/Homebrew Bumps [parser](https://github.com/whitequark/parser) from 2.7.1.0 to 2.7.1.1. - [Release notes](https://github.com/whitequark/parser/releases) - [Changelog](https://github.com/whitequark/parser/blob/master/CHANGELOG.md) - [Commits](https://github.com/whitequark/parser/compare/v2.7.1.0...v2.7.1.1) Signed-off-by: dependabot-preview[bot] --- Library/Homebrew/Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/Gemfile.lock b/Library/Homebrew/Gemfile.lock index 0781ea7596..d425f09917 100644 --- a/Library/Homebrew/Gemfile.lock +++ b/Library/Homebrew/Gemfile.lock @@ -51,7 +51,7 @@ GEM parallel (1.19.1) parallel_tests (2.32.0) parallel - parser (2.7.1.0) + parser (2.7.1.1) ast (~> 2.4.0) plist (3.5.0) rainbow (3.0.0) From 4af3037a18d2f3d1cb5ac69b75b652050a6bb163 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 15 Apr 2020 10:41:46 +0100 Subject: [PATCH 2/3] brew vendor-gems: commit updates. --- Library/Homebrew/vendor/bundle/bundler/setup.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/vendor/bundle/bundler/setup.rb b/Library/Homebrew/vendor/bundle/bundler/setup.rb index 089f8ac9fe..1148094680 100644 --- a/Library/Homebrew/vendor/bundle/bundler/setup.rb +++ b/Library/Homebrew/vendor/bundle/bundler/setup.rb @@ -46,7 +46,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/mechanize-2.7.6/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/mustache-1.1.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel-1.19.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel_tests-2.32.0/lib" -$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parser-2.7.0.5/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parser-2.7.1.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/plist-3.5.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rainbow-3.0.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/universal-darwin-19/2.6.0/rdiscount-2.2.0.1" From 9a8a4cff9fc98b953cc81447d0c99c957e3531a3 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Wed, 15 Apr 2020 03:21:07 +0100 Subject: [PATCH 3/3] test/dev-cmd/style_spec: fix flaky test --- Library/Homebrew/test/.rubocop_todo.yml | 3 +- Library/Homebrew/test/dev-cmd/style_spec.rb | 77 -------------------- Library/Homebrew/test/style_spec.rb | 80 +++++++++++++++++++++ 3 files changed, 82 insertions(+), 78 deletions(-) create mode 100644 Library/Homebrew/test/style_spec.rb diff --git a/Library/Homebrew/test/.rubocop_todo.yml b/Library/Homebrew/test/.rubocop_todo.yml index ccd1f0be95..92fd0457d7 100644 --- a/Library/Homebrew/test/.rubocop_todo.yml +++ b/Library/Homebrew/test/.rubocop_todo.yml @@ -12,7 +12,7 @@ RSpec/ExampleLength: Exclude: - 'rubocops/patches_spec.rb' -# Offense count: 37 +# Offense count: 41 # Configuration parameters: CustomTransform, IgnoreMethods. RSpec/FilePath: Exclude: @@ -53,6 +53,7 @@ RSpec/FilePath: - 'rubocops/formula_desc_spec.rb' - 'search_spec.rb' - 'string_spec.rb' + - 'style_spec.rb' - 'system_command_result_spec.rb' - 'unpack_strategy/p7zip_spec.rb' - 'utils/github_spec.rb' diff --git a/Library/Homebrew/test/dev-cmd/style_spec.rb b/Library/Homebrew/test/dev-cmd/style_spec.rb index 6926f49929..2c0164c9f9 100644 --- a/Library/Homebrew/test/dev-cmd/style_spec.rb +++ b/Library/Homebrew/test/dev-cmd/style_spec.rb @@ -5,80 +5,3 @@ require "cmd/shared_examples/args_parse" describe "Homebrew.style_args" do it_behaves_like "parseable arguments" end - -describe "brew style" do - around do |example| - FileUtils.ln_s HOMEBREW_LIBRARY_PATH, HOMEBREW_LIBRARY/"Homebrew" - FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop.yml", HOMEBREW_LIBRARY/".rubocop.yml" - FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop_shared.yml", HOMEBREW_LIBRARY/".rubocop_shared.yml" - - example.run - ensure - FileUtils.rm_f HOMEBREW_LIBRARY/"Homebrew" - FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop.yml" - FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop_shared.yml" - end - - before do - allow(Homebrew).to receive(:install_bundler_gems!) - end - - describe "Homebrew::check_style_json" do - let(:dir) { mktmpdir } - - it "returns RubocopResults when RuboCop reports offenses" do - formula = dir/"my-formula.rb" - - formula.write <<~'EOS' - class MyFormula < Formula - - end - EOS - - rubocop_result = Homebrew::Style.check_style_json([formula]) - - expect(rubocop_result.file_offenses(formula.realpath.to_s).map(&:message)) - .to include("Extra empty line detected at class body beginning.") - end - - it "corrected offense output format" do - formula = dir/"my-formula-2.rb" - - formula.write <<~EOS - class MyFormula2 < Formula - desc "Test formula" - homepage "https://foo.org" - url "https://foo.org/foo-1.7.5.tgz" - sha256 "cc692fb9dee0cc288757e708fc1a3b6b56ca1210ca181053a371cb11746969da" - - depends_on "foo" - depends_on "bar-config" => :build - - test do - assert_equal 5, 5 - end - end - EOS - rubocop_result = Homebrew::Style.check_style_json( - [formula], - fix: true, only_cops: ["FormulaAudit/DependencyOrder"], - ) - offense_string = rubocop_result.file_offenses(formula.realpath).first.to_s - expect(offense_string).to match(/\[Corrected\]/) - end - end - - describe "Homebrew::check_style_and_print" do - let(:dir) { mktmpdir } - - it "returns false for conforming file with only audit-level violations" do - # This file is known to use non-rocket hashes and other things that trigger audit, - # but not regular, cop violations - target_file = HOMEBREW_LIBRARY_PATH/"utils.rb" - - rubocop_result = Homebrew::Style.check_style_and_print([target_file]) - - expect(rubocop_result).to eq true - end - end -end diff --git a/Library/Homebrew/test/style_spec.rb b/Library/Homebrew/test/style_spec.rb new file mode 100644 index 0000000000..cd5bcaefda --- /dev/null +++ b/Library/Homebrew/test/style_spec.rb @@ -0,0 +1,80 @@ +# frozen_string_literal: true + +require "style" + +describe Homebrew::Style do + around do |example| + FileUtils.ln_s HOMEBREW_LIBRARY_PATH, HOMEBREW_LIBRARY/"Homebrew" + FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop.yml", HOMEBREW_LIBRARY/".rubocop.yml" + FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop_shared.yml", HOMEBREW_LIBRARY/".rubocop_shared.yml" + + example.run + ensure + FileUtils.rm_f HOMEBREW_LIBRARY/"Homebrew" + FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop.yml" + FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop_shared.yml" + end + + before do + allow(Homebrew).to receive(:install_bundler_gems!) + end + + describe ".check_style_json" do + let(:dir) { mktmpdir } + + it "returns RubocopResults when RuboCop reports offenses" do + formula = dir/"my-formula.rb" + + formula.write <<~'EOS' + class MyFormula < Formula + + end + EOS + + rubocop_result = described_class.check_style_json([formula]) + + expect(rubocop_result.file_offenses(formula.realpath.to_s).map(&:message)) + .to include("Extra empty line detected at class body beginning.") + end + + it "corrected offense output format" do + formula = dir/"my-formula-2.rb" + + formula.write <<~EOS + class MyFormula2 < Formula + desc "Test formula" + homepage "https://foo.org" + url "https://foo.org/foo-1.7.5.tgz" + sha256 "cc692fb9dee0cc288757e708fc1a3b6b56ca1210ca181053a371cb11746969da" + + depends_on "foo" + depends_on "bar-config" => :build + + test do + assert_equal 5, 5 + end + end + EOS + rubocop_result = described_class.check_style_json( + [formula], + fix: true, only_cops: ["FormulaAudit/DependencyOrder"], + ) + offense_string = rubocop_result.file_offenses(formula.realpath).first.to_s + expect(offense_string).to match(/\[Corrected\]/) + end + end + + describe ".check_style_and_print" do + let(:dir) { mktmpdir } + + it "returns false for conforming file with only audit-level violations" do + # This file is known to use non-rocket hashes and other things that trigger audit, + # but not regular, cop violations + target_file = HOMEBREW_LIBRARY_PATH/"utils.rb" + + rubocop_result = described_class.check_style_and_print([target_file]) + + expect(rubocop_result).to eq true + end + end +end