language
stringclasses
1 value
owner
stringlengths
2
15
repo
stringlengths
2
21
sha
stringlengths
45
45
message
stringlengths
7
36.3k
path
stringlengths
1
199
patch
stringlengths
15
102k
is_multipart
bool
2 classes
Other
Homebrew
brew
cc8f029f222a618eb30b585ccb22efcce1e5cf91.json
secure urls + remove -k from in-doc curl command
Library/Homebrew/vendor/macho/macho/utils.rb
@@ -5,7 +5,7 @@ module Utils # @param value [Fixnum] the number being rounded # @param round [Fixnum] the number being rounded with # @return [Fixnum] the rounded value - # @see http://www.opensource.apple.com/source/cctools/cctools-870/libstuff/rnd.c + # @see https://www.opensource.apple.com/source/cctools/cctools-870/libstuff/rnd.c def self.round(value, round) round -= 1 value += round
true
Other
Homebrew
brew
cc8f029f222a618eb30b585ccb22efcce1e5cf91.json
secure urls + remove -k from in-doc curl command
Library/Homebrew/version.rb
@@ -360,8 +360,8 @@ def self._parse(spec) m = /-((?:\d+\.)*\d+-(?:alpha|beta|rc)\d*)$/.match(stem) return m.captures.first unless m.nil? - # e.g. http://ftpmirror.gnu.org/libidn/libidn-1.29-win64.zip - # e.g. http://ftpmirror.gnu.org/libmicrohttpd/libmicrohttpd-0.9.17-w32.zip + # e.g. https://ftpmirror.gnu.org/libidn/libidn-1.29-win64.zip + # e.g. https://ftpmirror.gnu.org/libmicrohttpd/libmicrohttpd-0.9.17-w32.zip m = /-(\d+\.\d+(?:\.\d+)?)-w(?:in)?(?:32|64)$/.match(stem) return m.captures.first unless m.nil? @@ -372,11 +372,11 @@ def self._parse(spec) m = /\.(\d+\.\d+(?:\.\d+)?)\+opam$/.match(stem) return m.captures.first unless m.nil? - # e.g. http://ftpmirror.gnu.org/mtools/mtools-4.0.18-1.i686.rpm - # e.g. http://ftpmirror.gnu.org/autogen/autogen-5.5.7-5.i386.rpm - # e.g. http://ftpmirror.gnu.org/libtasn1/libtasn1-2.8-x86.zip - # e.g. http://ftpmirror.gnu.org/libtasn1/libtasn1-2.8-x64.zip - # e.g. http://ftpmirror.gnu.org/mtools/mtools_4.0.18_i386.deb + # e.g. https://ftpmirror.gnu.org/mtools/mtools-4.0.18-1.i686.rpm + # e.g. https://ftpmirror.gnu.org/autogen/autogen-5.5.7-5.i386.rpm + # e.g. https://ftpmirror.gnu.org/libtasn1/libtasn1-2.8-x86.zip + # e.g. https://ftpmirror.gnu.org/libtasn1/libtasn1-2.8-x64.zip + # e.g. https://ftpmirror.gnu.org/mtools/mtools_4.0.18_i386.deb m = /[-_](\d+\.\d+(?:\.\d+)?(?:-\d+)?)[-_.](?:i[36]86|x86|x64(?:[-_](?:32|64))?)$/.match(stem) return m.captures.first unless m.nil?
true
Other
Homebrew
brew
cc8f029f222a618eb30b585ccb22efcce1e5cf91.json
secure urls + remove -k from in-doc curl command
docs/Gems,-Eggs-and-Perl-Modules.md
@@ -131,7 +131,7 @@ If you don’t even want (or can’t) use sudo for bootstrapping Another alternative is to use `perlbrew` to install a separate copy of Perl in your home directory, or wherever you like : ```bash -curl -kL http://install.perlbrew.pl | bash +curl -L https://install.perlbrew.pl | bash perlbrew install perl-5.16.2 echo ".~/perl5/perlbrew/etc/bashrc" >> ~/.bashrc ```
true
Other
Homebrew
brew
cc8f029f222a618eb30b585ccb22efcce1e5cf91.json
secure urls + remove -k from in-doc curl command
docs/Python-for-Formula-Authors.md
@@ -213,7 +213,7 @@ Distribute (not to be confused with distutils) is an obsolete fork of setuptools ## What is `--single-version-externally-managed`? -`--single-version-externally-managed` ("SVEM") is a setuptools-only [argument to setup.py install](http://setuptools.readthedocs.io/en/latest/setuptools.html?#install-run-easy-install-or-old-style-installation). The primary effect of SVEM is to use distutils to perform the install instead of using setuptools' `easy_install`. +`--single-version-externally-managed` ("SVEM") is a setuptools-only [argument to setup.py install](https://setuptools.readthedocs.io/en/latest/setuptools.html?#install-run-easy-install-or-old-style-installation). The primary effect of SVEM is to use distutils to perform the install instead of using setuptools' `easy_install`. `easy_install` does a few things that we need to avoid:
true
Other
Homebrew
brew
cc8f029f222a618eb30b585ccb22efcce1e5cf91.json
secure urls + remove -k from in-doc curl command
docs/_layouts/index.html
@@ -115,7 +115,7 @@ <h2 id="question">{{ page.pagecontent.question }}</h2> <div class="group row"> <h2 id="further-doc">{{ page.pagecontent.doc.further }}</h2> <div class="button"> - <p><a href="http://docs.brew.sh">docs.brew.sh</a></p> + <p><a href="http://docs.brew.sh/">docs.brew.sh</a></p> </div> </div> </li> @@ -124,7 +124,7 @@ <h2 id="further-doc">{{ page.pagecontent.doc.further }}</h2> <div class="group row"> <h2 id="homebrew-community">{{ page.pagecontent.doc.community }}</h2> <div class="button"> - <p><a href="http://discourse.brew.sh">discourse.brew.sh</a></p> + <p><a href="https://discourse.brew.sh/">discourse.brew.sh</a></p> </div> </div> </li>
true
Other
Homebrew
brew
cc8f029f222a618eb30b585ccb22efcce1e5cf91.json
secure urls + remove -k from in-doc curl command
docs/brew.1.html
@@ -592,7 +592,7 @@ <h2 id="DEVELOPER-COMMANDS">DEVELOPER COMMANDS</h2> <p> ~ The URL of a commit on GitHub</p> -<p> ~ A "http://bot.brew.sh/job/..." string specifying a testing job ID</p> +<p> ~ A "https://bot.brew.sh/job/..." string specifying a testing job ID</p> <p>If <code>--bottle</code> is passed, handle bottles, pulling the bottle-update commit and publishing files on Bintray.</p>
true
Other
Homebrew
brew
cc8f029f222a618eb30b585ccb22efcce1e5cf91.json
secure urls + remove -k from in-doc curl command
manpages/brew-cask.1
@@ -67,7 +67,7 @@ Download remote application files for the given Cask to the local cache\. With \ Display the homepage associated with a given Cask in a browser\. . .IP -With no arguments, display the project page \fIhttp://caskroom\.github\.io\fR\. +With no arguments, display the project page \fIhttps://caskroom\.github\.io/\fR\. . .TP \fBinfo\fR or \fBabv\fR \fItoken\fR [ \fItoken\fR \.\.\. ] @@ -288,7 +288,7 @@ This variable may contain any arguments normally used as options on the command\ . .SH "SEE ALSO" -The Homebrew\-Cask home page: \fIhttp://caskroom\.github\.io\fR +The Homebrew\-Cask home page: \fIhttps://caskroom\.github\.io/\fR . .P The Homebrew\-Cask GitHub page: \fIhttps://github\.com/caskroom/homebrew\-cask\fR
true
Other
Homebrew
brew
cc8f029f222a618eb30b585ccb22efcce1e5cf91.json
secure urls + remove -k from in-doc curl command
manpages/brew.1
@@ -786,7 +786,7 @@ Each \fIpatch\-source\fR may be one of: ~ The URL of a commit on GitHub . .IP -~ A "http://bot\.brew\.sh/job/\.\.\." string specifying a testing job ID +~ A "https://bot\.brew\.sh/job/\.\.\." string specifying a testing job ID . .IP If \fB\-\-bottle\fR is passed, handle bottles, pulling the bottle\-update commit and publishing files on Bintray\.
true
Other
Homebrew
brew
f6b1f88c3c7715a72a2dbd8ec9a7359450909747.json
Update RuboCop-Cask to 0.12.0.
Library/Homebrew/constants.rb
@@ -1,3 +1,3 @@ # RuboCop version used for `brew style` and `brew cask style` HOMEBREW_RUBOCOP_VERSION = "0.47.1".freeze -HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.11.0".freeze # has to be updated when RuboCop version changes +HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.12.0".freeze # has to be updated when RuboCop version changes
false
Other
Homebrew
brew
c0468a3266ca173cb1e04a764bcc205a88957bba.json
docs: add markers to ordered lists and sublists While GitHub allows a single space to denote a sublist, Jekyll is not so lenient. It also seems unable to handle ordered sublists.
docs/How-To-Open-a-Homebrew-Pull-Request.md
@@ -12,18 +12,18 @@ Depending on the change you want to make, you need to send the pull request to t ### Core `brew` code related pull request 1. [Fork the Homebrew/brew repository on GitHub](https://github.com/Homebrew/brew/fork). - * This creates a personal remote repository that you can push to. This is needed because only Homebrew maintainers have push access to the main repositories. + * This creates a personal remote repository that you can push to. This is needed because only Homebrew maintainers have push access to the main repositories. 2. Change to the directory containing your Homebrew installation with `cd $(brew --repository)`. 3. Add your pushable forked repository with `git remote add <YOUR_USERNAME> https://github.com/<YOUR_USERNAME>/brew.git`. - * `<YOUR_USERNAME>` is your GitHub username, not your local machine username. + * `<YOUR_USERNAME>` is your GitHub username, not your local machine username. ### Formulae related pull request 1. [Fork the Homebrew/homebrew-core repository on GitHub](https://github.com/Homebrew/homebrew-core/fork). - * This creates a personal remote repository that you can push to. This is needed because only Homebrew maintainers have push access to the main repositories. + * This creates a personal remote repository that you can push to. This is needed because only Homebrew maintainers have push access to the main repositories. 2. Change to the directory containing Homebrew formulae with `cd $(brew --repository homebrew/core)`. 3. Add your pushable forked repository with `git remote add <YOUR_USERNAME> https://github.com/<YOUR_USERNAME>/homebrew-core.git` - * `<YOUR_USERNAME>` is your GitHub username, not your local machine username. + * `<YOUR_USERNAME>` is your GitHub username, not your local machine username. For formulae in central taps other than `homebrew/core`, such as `homebrew/science` or `homebrew/nginx`, substitute that tap's name for `homebrew/core` in each step, and alter the GitHub repository URLs as necessary. @@ -35,26 +35,27 @@ To make a new branch and submit it for review, create a GitHub pull request with 2. Retrieve new changes to the `master` branch with `brew update`. 3. Create a new branch from the latest `master` branch with `git checkout -b <YOUR_BRANCH_NAME> origin/master`. 4. Make your changes. For formulae, use `brew edit` or your favorite text editor, following all the guidelines in the [Formula Cookbook](Formula-Cookbook.md). - * If there's a `bottle do` block in the formula: don't remove or change it; we'll update it when we pull your PR. + * If there's a `bottle do` block in the formula: don't remove or change it; we'll update it when we pull your PR. 5. Test your changes by doing the following, and ensure they all pass without issue. For changed formulae, make sure you do the `brew audit` step while your changed formula is installed. - 1. `brew tests` - 2. `brew install --build-from-source <CHANGED_FORMULA>` - 3. `brew test <CHANGED_FORMULA>` - 4. `brew audit --strict <CHANGED_FORMULA>` + * `brew tests` + * `brew install --build-from-source <CHANGED_FORMULA>` + * `brew test <CHANGED_FORMULA>` + * `brew audit --strict <CHANGED_FORMULA>` 6. Make a separate commit for each changed formula with `git add` and `git commit`. 7. Upload your new commits to the branch on your fork with `git push --set-upstream <YOUR_USERNAME> <YOUR_BRANCH_NAME>`. 8. Go to the relevant repository (e.g. <https://github.com/Homebrew/brew>, <https://github.com/Homebrew/homebrew-core>, etc.) and create a pull request to request review and merging of the commits in your pushed branch. Explain why the change is needed and, if fixing a bug, how to reproduce the bug. Make sure you have done each step in the checklist that appears in your new PR. - * Please note that our preferred commit message format for simple version updates is "`<FORMULA_NAME> <NEW_VERSION>`", e.g. "`source-highlight 3.1.8`". `devel` version updates should have the commit message suffixed with `(devel)`, e.g. "`nginx 1.9.1 (devel)`". If updating both stable and `devel`, the format should be a concatenation of these two forms, e.g. "`x264 r2699, r2705 (devel)`". + * Please note that our preferred commit message format for simple version updates is "`<FORMULA_NAME> <NEW_VERSION>`", e.g. "`source-highlight 3.1.8`". `devel` version updates should have the commit message suffixed with `(devel)`, e.g. "`nginx 1.9.1 (devel)`". If updating both stable and `devel`, the format should be a concatenation of these two forms, e.g. "`x264 r2699, r2705 (devel)`". 9. Await feedback or a merge from Homebrew's maintainers. We typically respond to all PRs within a couple days, but it may take up to a week, depending on the maintainers' workload. -10. Thank you! + +Thank you! ## Following up To respond well to feedback: 1. Ask for clarification of anything you don't understand and for help with anything you don't know how to do. 2. Post a comment on your pull request if you've provided all the requested changes/information and it hasn't been merged after a week. Post a comment on your pull request if you're stuck and need help. - * A `needs response` label on a PR means that the Homebrew maintainers need you to respond to previous comments. + * A `needs response` label on a PR means that the Homebrew maintainers need you to respond to previous comments. 3. Keep discussion in the pull request unless requested otherwise (i.e. do not email maintainers privately). 4. Do not continue discussion in closed pull requests. 5. Do not argue with Homebrew maintainers. You may disagree but unless they change their mind, please implement what they request. Ultimately they control what is included in Homebrew, as they have to support any changes that are made.
true
Other
Homebrew
brew
c0468a3266ca173cb1e04a764bcc205a88957bba.json
docs: add markers to ordered lists and sublists While GitHub allows a single space to denote a sublist, Jekyll is not so lenient. It also seems unable to handle ordered sublists.
docs/Prose-Style-Guidelines.md
@@ -28,7 +28,7 @@ We prefer: * British/Commonwealth English over American English, in general * "e.g." and "i.e.": Go ahead and use "e.g." or "i.e." instead of spelling them out. Don't worry about putting a comma after them. - * "e.g." means "for example"; "i.e." means "that is" + * "e.g." means "for example"; "i.e." means "that is" * Offset nontrivial subordinate clauses with commas ### Personal pronouns @@ -45,36 +45,36 @@ We prefer: * Capitalize all list items if you want, even if they're not complete sentences; just be consistent within each list, and preferably, throughout the whole page * Use a subordinate list item instead of dropping a multi-sentence paragraph-long item into a list of sentence fragments * Prefer Markdown over other markup formats unless their specific features are needed - * GitHub Flavored Markdown. GitHub's implementation is the standard, period. + * GitHub Flavored Markdown. GitHub's implementation is the standard, period. ### Typographical conventions * Literal text in commands and code is styled in `fixed width font` * Placeholders inside code snippets are marked up with `<...>` brackets - * e.g. `git remote add <my-user-name> https://github.com/<my-user-name>/homebrew-core.git` + * e.g. `git remote add <my-user-name> https://github.com/<my-user-name>/homebrew-core.git` * Names of commands like `git` and `brew` are styled in `fixed width font` * No "$" with environment variables mentioned outside code snippets - * e.g. "Set `BLAH` to 5", not "Set `$BLAH` to 5" + * e.g. "Set `BLAH` to 5", not "Set `$BLAH` to 5" * One space after periods, not two * Capitalized proper nouns * We do not defer to extensive nonstandard capitalization, typesetting, or other styling of brand names, aside from the normal capitalization of proper nouns and simple internal capitalization * No "TM", &trade;, <sup>SM</sup>, &copy;, &reg;, or other explicit indicators of rights ownership or trademarks; we take these as understood when the brand name is mentioned * Tap names like `homebrew/core` are styled in `fixed width font`. Repository names may be styled in either fixed width font like "`Homebrew/homebrew-core`", as links like "[Homebrew/homebrew-core](https://github.com/homebrew/homebrew-core)", or regular text like "Homebrew/homebrew-core", based on which looks best for a given use. - * But be consistent within a single document - * Capitalize repository names to match the user and repository names on GitHub. Keep tap names in lower case. + * But be consistent within a single document + * Capitalize repository names to match the user and repository names on GitHub. Keep tap names in lower case. * Commas - * No Oxford commas - * Prefer a "loose" comma style: "when in doubt, leave it out" unless needed for clarity + * No Oxford commas + * Prefer a "loose" comma style: "when in doubt, leave it out" unless needed for clarity ### Terminology, words, and word styling * "pull request", not "Pull Request" * "check out" is the verb; "checkout" is the noun * Spell out certain technical words - * "repository", not "repo" - * When abbreviating, introduce the abbreviation with the first usage in any document + * "repository", not "repo" + * When abbreviating, introduce the abbreviation with the first usage in any document * Some abbreviations (near-universally understood among our user base) are fine, though. - * "Mac" is fine; "Macintosh" isn't necessary + * "Mac" is fine; "Macintosh" isn't necessary * "macOS" for all versions, "OS X" or "Mac OS X" when describing specific older versions * "RuboCop", not "Rubocop" * A pull request is made "on" a repository; that repository is "at" a URL
true
Other
Homebrew
brew
c0468a3266ca173cb1e04a764bcc205a88957bba.json
docs: add markers to ordered lists and sublists While GitHub allows a single space to denote a sublist, Jekyll is not so lenient. It also seems unable to handle ordered sublists.
docs/css/screen.css
@@ -158,8 +158,12 @@ pre code { box-shadow: 0 -1px 0 rgba(0,0,0,0.5); } +#home ol, #page ol, .postcontent ol { + list-style: decimal; +} + #home ul, #page ul, .postcontent ul { - list-style: inherit; + list-style: disc; } #home h1, #page h1 {
true
Other
Homebrew
brew
282622e449e640a61361890296eee46d880f77a3.json
update: stop autoupdate skipping no formula taps. This will be slightly slower if you have a bunch of non-formula (i.e. command or cask) taps but it avoids the confusion of having Homebrew saying it's updated when it only did so selectively. Fixes #1946.
Library/Homebrew/cmd/update.sh
@@ -458,14 +458,6 @@ EOS then # Skip taps checked/fetched recently [[ -n "$(find "$DIR/.git/FETCH_HEAD" -type f -mtime -"${HOMEBREW_AUTO_UPDATE_SECS}"s 2>/dev/null)" ]] && exit - - # Skip taps without formulae (but always update Homebrew/brew and Homebrew/homebrew-core) - if [[ "$DIR" != "$HOMEBREW_REPOSITORY" && - "$DIR" != "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] - then - FORMULAE="$(find "$DIR" -maxdepth 1 \( -name "*.rb" -or -name Formula -or -name HomebrewFormula \) -print -quit)" - [[ -z "$FORMULAE" ]] && exit - fi fi UPSTREAM_REPOSITORY_URL="$(git config remote.origin.url)"
false
Other
Homebrew
brew
31d7d6e5f3ec88ffbaf8aa86ac6239e79cd9d160.json
Remove old metadata when installing with `--force`.
Library/Homebrew/cask/lib/hbc/cask.rb
@@ -32,7 +32,6 @@ def metadata_versioned_container_path end def metadata_path(timestamp = :latest, create = false) - return nil unless metadata_versioned_container_path.respond_to?(:join) if create && timestamp == :latest raise CaskError, "Cannot create metadata path when timestamp is :latest" end
true
Other
Homebrew
brew
31d7d6e5f3ec88ffbaf8aa86ac6239e79cd9d160.json
Remove old metadata when installing with `--force`.
Library/Homebrew/cask/lib/hbc/installer.rb
@@ -295,16 +295,15 @@ def disable_accessibility_access end def save_caskfile - timestamp = :now - create = true - savedir = @cask.metadata_subdir("Casks", timestamp, create) - if Dir.entries(savedir).size > 2 - # should not happen - raise CaskAlreadyInstalledError, @cask unless force - savedir.rmtree - FileUtils.mkdir_p savedir + unless (old_savedirs = Pathname.glob(@cask.metadata_path("*"))).empty? + old_savedirs.each(&:rmtree) end - FileUtils.copy(@cask.sourcefile_path, savedir) if @cask.sourcefile_path + + return unless @cask.sourcefile_path + + savedir = @cask.metadata_subdir("Casks", :now, true) + savedir.mkpath + FileUtils.copy @cask.sourcefile_path, savedir end def uninstall
true
Other
Homebrew
brew
c5a9ee5719413d0d93f44da61100e7beee469410.json
java_requirement.rb: use HTTPS in Java Platform URL It's redirected to cleartext, though this URL will be opened in a browser so it won't be something hidden, and maybe Oracle will fix this in the future.
Library/Homebrew/requirements/java_requirement.rb
@@ -2,7 +2,7 @@ class JavaRequirement < Requirement fatal true - download "http://www.oracle.com/technetwork/java/javase/downloads/index.html" + download "https://www.oracle.com/technetwork/java/javase/downloads/index.html" satisfy build_env: false do setup_java
false
Other
Homebrew
brew
642e355b4f042de80a78036f66d5810dc392cfdc.json
Save flags in `with_full_permissions`.
Library/Homebrew/cask/lib/hbc/pkg.rb
@@ -92,12 +92,14 @@ def rmdir(path) def with_full_permissions(path) original_mode = (path.stat.mode % 01000).to_s(8) - # TODO: similarly read and restore macOS flags (cf man chflags) + original_flags = @command.run!("/usr/bin/stat", args: ["-f", "%Of", "--", path]).stdout.chomp + @command.run!("/bin/chmod", args: ["--", "777", path], sudo: true) yield ensure if path.exist? # block may have removed dir @command.run!("/bin/chmod", args: ["--", original_mode, path], sudo: true) + @command.run!("/usr/bin/chflags", args: ["--", original_flags, path], sudo: true) end end
true
Other
Homebrew
brew
642e355b4f042de80a78036f66d5810dc392cfdc.json
Save flags in `with_full_permissions`.
Library/Homebrew/test/cask/pkg_spec.rb
@@ -1,7 +1,7 @@ describe Hbc::Pkg, :cask do describe "#uninstall" do let(:fake_system_command) { Hbc::NeverSudoSystemCommand } - let(:empty_response) { double(stdout: "", plist: {"volume" => "/", "install-location" => "", "paths" => {}}) } + let(:empty_response) { double(stdout: "", plist: { "volume" => "/", "install-location" => "", "paths" => {} }) } let(:pkg) { described_class.new("my.fake.pkg", fake_system_command) } it "removes files and dirs referenced by the pkg" do @@ -51,7 +51,7 @@ it "removes broken symlinks" do fake_dir = Pathname.new(Dir.mktmpdir) - fake_root = Pathname.new(Dir.mktmpdir) + fake_root = Pathname.new(Dir.mktmpdir) fake_file = fake_dir.join("ima_file").tap { |path| FileUtils.touch(path) } intact_symlink = fake_dir.join("intact_symlink").tap { |path| path.make_symlink(fake_file) }
true
Other
Homebrew
brew
d0f1fa668ce2a943f1613080f8b517decdeab215.json
hardware: use march=native for generic module. This matches Linux where this behaviour was original imported from.
Library/Homebrew/hardware.rb
@@ -12,7 +12,7 @@ class << self penryn: "-march=core2 -msse4.1", core2: "-march=core2", core: "-march=prescott", - dunno: "", + dunno: "-march=native", }.freeze def optimization_flags
false
Other
Homebrew
brew
c6cbf9590d897db7cff7f2f81863ae34ccc947ed.json
linux: Add ARM to CPU.type
Library/Homebrew/extend/os/linux/hardware/cpu.rb
@@ -12,6 +12,8 @@ def cpuinfo def type @type ||= if cpuinfo =~ /Intel|AMD/ :intel + elsif cpuinfo =~ /ARM|Marvell/ + :arm else :dunno end @@ -71,7 +73,7 @@ def cores end def flags - @flags ||= cpuinfo[/^flags.*/, 0].split + @flags ||= cpuinfo[/^(flags|Features).*/, 0].split end # Compatibility with Mac method, which returns lowercase symbols
false
Other
Homebrew
brew
0e30d34d272cbec3ed6b07eebc4c9fcbb3189317.json
test: fix tests with a shallow clone. In this case `HOMEBREW_VERSION` is `>1.1.0 (no git repository)` so these tests failed. This was the cause of the Homebrew/homebrew-test-bot Linux CI failures as it was testing a shallow clone.
Library/Homebrew/test/cmd/config_spec.rb
@@ -1,7 +1,7 @@ describe "brew config", :integration_test do it "prints information about the current Homebrew configuration" do expect { brew "config" } - .to output(/HOMEBREW_VERSION: #{HOMEBREW_VERSION}/).to_stdout + .to output(/HOMEBREW_VERSION: #{Regexp.escape HOMEBREW_VERSION}/).to_stdout .and not_to_output.to_stderr .and be_a_success end
true
Other
Homebrew
brew
0e30d34d272cbec3ed6b07eebc4c9fcbb3189317.json
test: fix tests with a shallow clone. In this case `HOMEBREW_VERSION` is `>1.1.0 (no git repository)` so these tests failed. This was the cause of the Homebrew/homebrew-test-bot Linux CI failures as it was testing a shallow clone.
Library/Homebrew/test/tab_spec.rb
@@ -18,7 +18,7 @@ subject { described_class.new( - "homebrew_version" => HOMEBREW_VERSION, + "homebrew_version" => HOMEBREW_VERSION, "used_options" => used_options.as_flags, "unused_options" => unused_options.as_flags, "built_as_bottle" => false, @@ -51,6 +51,9 @@ let(:f_tab_content) { (TEST_FIXTURE_DIR/"receipt.json").read } specify "defaults" do + # < 1.1.7 runtime_dependencies were wrong so are ignored + stub_const("HOMEBREW_VERSION", "1.1.7") + tab = described_class.empty expect(tab.homebrew_version).to eq(HOMEBREW_VERSION) @@ -199,6 +202,9 @@ describe "::create" do it "creates a Tab" do + # < 1.1.7 runtime dependencies were wrong so are ignored + stub_const("HOMEBREW_VERSION", "1.1.7") + f = formula do url "foo-1.0" depends_on "bar" @@ -223,8 +229,8 @@ { "full_name" => "bar", "version" => "2.0" }, { "full_name" => "user/repo/from_tap", "version" => "1.0" }, ] - expect(tab.runtime_dependencies).to eq(runtime_dependencies) + expect(tab.source["path"]).to eq(f.path.to_s) end
true
Other
Homebrew
brew
10a235d6abfed687236b14577a02df13a9b5adca.json
pull: check Bintray mirror URLs
Library/Homebrew/dev-cmd/pull.rb
@@ -155,6 +155,13 @@ def pull next end + if f.stable + stable_urls = [f.stable.url] + f.stable.mirrors + stable_urls.grep(%r{^https://dl.bintray.com/homebrew/mirror/}) do |mirror_url| + check_bintray_mirror(f.full_name, mirror_url) + end + end + if ARGV.include? "--bottle" if f.bottle_unneeded? ohai "#{f}: skipping unneeded bottle." @@ -588,4 +595,12 @@ def verify_bintray_published(formulae_names) end end end + + def check_bintray_mirror(name, url) + headers = curl_output("--connect-timeout", "15", "--head", url)[0] + status_code = headers.scan(%r{^HTTP\/.* (\d+)}).last.first + return if status_code.start_with?("3") + opoo "The Bintray mirror #{url} is not reachable (HTTP status code #{status_code})." + opoo "Do you need to upload it with `brew mirror #{name}`?" + end end
false
Other
Homebrew
brew
e0acaeef816ae73566b2067608a6530b61a8037a.json
Remove redundant `Utils`.
Library/Homebrew/cask/lib/hbc/cli/cleanup.rb
@@ -62,7 +62,7 @@ def cache_completes end def disk_cleanup_size - Utils.size_in_bytes(cache_files) + cache_files.map(&:disk_usage).inject(:+) end def remove_cache_files(*tokens)
true
Other
Homebrew
brew
e0acaeef816ae73566b2067608a6530b61a8037a.json
Remove redundant `Utils`.
Library/Homebrew/cask/lib/hbc/cli/style.rb
@@ -24,7 +24,7 @@ def run end def install_rubocop - Utils.capture_stderr do + capture_stderr do begin Homebrew.install_gem_setup_path! "rubocop-cask", HOMEBREW_RUBOCOP_CASK_VERSION, "rubocop" rescue SystemExit
true
Other
Homebrew
brew
e0acaeef816ae73566b2067608a6530b61a8037a.json
Remove redundant `Utils`.
Library/Homebrew/cask/lib/hbc/utils.rb
@@ -90,27 +90,6 @@ def self.current_user Etc.getpwuid(Process.euid).name end - # paths that "look" descendant (textually) will still - # return false unless both the given paths exist - def self.file_is_descendant(file, dir) - file = Pathname.new(file) - dir = Pathname.new(dir) - return false unless file.exist? && dir.exist? - unless dir.directory? - onoe "Argument must be a directory: '#{dir}'" - return false - end - unless file.absolute? && dir.absolute? - onoe "Both arguments must be absolute: '#{file}', '#{dir}'" - return false - end - while file.parent != file - return true if File.identical?(file, dir) - file = file.parent - end - false - end - def self.path_occupied?(path) File.exist?(path) || File.symlink?(path) end @@ -145,18 +124,5 @@ def self.nowstamp_metadata_path(container_path) timestamp.concat(fraction) container_path.join(timestamp) end - - def self.size_in_bytes(files) - Array(files).reduce(0) { |acc, elem| acc + (File.size?(elem) || 0) } - end - - def self.capture_stderr - previous_stderr = $stderr - $stderr = StringIO.new - yield - $stderr.string - ensure - $stderr = previous_stderr - end end end
true
Other
Homebrew
brew
e0acaeef816ae73566b2067608a6530b61a8037a.json
Remove redundant `Utils`.
Library/Homebrew/test/cask/cli/cleanup_spec.rb
@@ -19,7 +19,7 @@ cached_downloads.each(&FileUtils.method(:touch)) - cleanup_size = Hbc::Utils.size_in_bytes(cached_downloads[0]) + cleanup_size = cached_downloads[0].disk_usage expect { subject.cleanup(cleaned_up_cached_download)
true
Other
Homebrew
brew
76e65ca070c0142f05ba2fcaf05fb6931c929547.json
Move legacy cache and caskroom code to `compat/*`.
Library/Homebrew/cask/lib/hbc.rb
@@ -45,9 +45,6 @@ module Hbc def self.init Cache.ensure_cache_exists - Cache.delete_legacy_cache - - Caskroom.migrate_caskroom_from_repo_to_prefix Caskroom.ensure_caskroom_exists end
true
Other
Homebrew
brew
76e65ca070c0142f05ba2fcaf05fb6931c929547.json
Move legacy cache and caskroom code to `compat/*`.
Library/Homebrew/cask/lib/hbc/cache.rb
@@ -8,13 +8,5 @@ def ensure_cache_exists odebug "Creating Cache at #{Hbc.cache}" Hbc.cache.mkpath end - - def delete_legacy_cache - legacy_cache = HOMEBREW_CACHE.join("Casks") - return unless legacy_cache.exist? - - ohai "Deleting legacy cache at #{legacy_cache}..." - FileUtils.remove_entry_secure(legacy_cache) - end end end
true
Other
Homebrew
brew
76e65ca070c0142f05ba2fcaf05fb6931c929547.json
Move legacy cache and caskroom code to `compat/*`.
Library/Homebrew/cask/lib/hbc/caskroom.rb
@@ -2,21 +2,6 @@ module Hbc module Caskroom module_function - def migrate_caskroom_from_repo_to_prefix - repo_caskroom = HOMEBREW_REPOSITORY.join("Caskroom") - return if Hbc.caskroom.exist? - return unless repo_caskroom.directory? - - ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX" - - if Hbc.caskroom.parent.writable? - FileUtils.mv repo_caskroom, Hbc.caskroom - else - opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom." - SystemCommand.run("/bin/mv", args: [repo_caskroom, Hbc.caskroom.parent], sudo: true) - end - end - def ensure_caskroom_exists return if Hbc.caskroom.exist?
true
Other
Homebrew
brew
76e65ca070c0142f05ba2fcaf05fb6931c929547.json
Move legacy cache and caskroom code to `compat/*`.
Library/Homebrew/compat/hbc.rb
@@ -1,2 +1,19 @@ require "compat/hbc/cask_loader" require "compat/hbc/cli/update" +require "compat/hbc/cache" +require "compat/hbc/caskroom" + +module Hbc + class << self + prepend( + Module.new do + def init + Cache.delete_legacy_cache + Caskroom.migrate_caskroom_from_repo_to_prefix + + super + end + end, + ) + end +end
true
Other
Homebrew
brew
76e65ca070c0142f05ba2fcaf05fb6931c929547.json
Move legacy cache and caskroom code to `compat/*`.
Library/Homebrew/compat/hbc/cache.rb
@@ -0,0 +1,13 @@ +module Hbc + module Cache + module_function + + def delete_legacy_cache + legacy_cache = HOMEBREW_CACHE.join("Casks") + return unless legacy_cache.exist? + + ohai "Deleting legacy cache at #{legacy_cache}" + FileUtils.remove_entry_secure(legacy_cache) + end + end +end
true
Other
Homebrew
brew
76e65ca070c0142f05ba2fcaf05fb6931c929547.json
Move legacy cache and caskroom code to `compat/*`.
Library/Homebrew/compat/hbc/caskroom.rb
@@ -0,0 +1,20 @@ +module Hbc + module Caskroom + module_function + + def migrate_caskroom_from_repo_to_prefix + repo_caskroom = HOMEBREW_REPOSITORY.join("Caskroom") + return if Hbc.caskroom.exist? + return unless repo_caskroom.directory? + + ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX" + + if Hbc.caskroom.parent.writable? + FileUtils.mv repo_caskroom, Hbc.caskroom + else + opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom." + SystemCommand.run("/bin/mv", args: [repo_caskroom, Hbc.caskroom.parent], sudo: true) + end + end + end +end
true
Other
Homebrew
brew
0d3e1119a1155dc60fb9a0840ea4fb2783dc3f37.json
bottle: Remove superfluous odie
Library/Homebrew/dev-cmd/bottle.rb
@@ -437,7 +437,6 @@ def merge --keep-old was passed but there are changes in: #{mismatches.join("\n")} EOS - odie "--keep-old was passed but there were changes in #{mismatches.join(", ")}!" end output = bottle_output bottle end
false
Other
Homebrew
brew
d37f2e7ae7b6915063960998df16b3cf4f76115c.json
New-Maintainer-Checklist: add analytics link.
docs/New-Maintainer-Checklist.md
@@ -46,6 +46,7 @@ If they accept, follow a few steps to get them set up: - Invite them to the [`homebrew-dev` private maintainers mailing list](https://groups.google.com/forum/#!managemembers/homebrew-dev/invite) - Invite them to the [`machomebrew` private maintainers Slack](https://machomebrew.slack.com/admin/invites) - Invite them to the [`homebrew` private maintainers 1Password](https://homebrew.1password.com/signin) +- Invite them to [Google Analytics](https://analytics.google.com/analytics/web/?authuser=1#management/Settings/a76679469w115400090p120682403/%3Fm.page%3DAccountUsers/) - Add them to [Homebrew's README](https://github.com/Homebrew/brew/edit/master/README.md) After a few weeks/months with no problems consider making them [owners on the Homebrew GitHub organisation](https://github.com/orgs/Homebrew/people).
false
Other
Homebrew
brew
aee23ccb0355228f24d387fcbe7cf5d30f57d8b6.json
Add more flags and descriptions to man pages.
Library/Homebrew/cmd/install.rb
@@ -1,4 +1,4 @@ -#: * `install` [`--debug`] [`--env=`<std>|<super>] [`--ignore-dependencies`] [`--only-dependencies`] [`--cc=`<compiler>] [`--build-from-source`] [`--devel`|`--HEAD`] [`--keep-tmp`] <formula>: +#: * `install` [`--debug`] [`--env=`(`std`|`super`)] [`--ignore-dependencies`|`--only-dependencies`] [`--cc=`<compiler>] [`--build-from-source`|`--force-bottle`] [`--devel`|`--HEAD`] [`--keep-tmp`] [`--build-bottle`] <formula>: #: Install <formula>. #: #: <formula> is usually the name of the formula to install, but it can be specified @@ -44,6 +44,9 @@ #: If `--keep-tmp` is passed, the temporary files created during installation #: are not deleted. #: +#: If `--build-bottle` is passed, prepare the formula for eventual bottling +#: during installation. +#: #: * `install` `--interactive` [`--git`] <formula>: #: Download and patch <formula>, then open a shell. This allows the user to #: run `./configure --help` and otherwise determine how to turn the software
true
Other
Homebrew
brew
aee23ccb0355228f24d387fcbe7cf5d30f57d8b6.json
Add more flags and descriptions to man pages.
Library/Homebrew/cmd/sh.rb
@@ -1,9 +1,11 @@ #: * `sh` [`--env=std`]: -#: Instantiate a Homebrew build environment. Uses our years-battle-hardened +#: Start a Homebrew build environment shell. Uses our years-battle-hardened #: Homebrew build logic to help your `./configure && make && make install` #: or even your `gem install` succeed. Especially handy if you run Homebrew #: in an Xcode-only configuration since it adds tools like `make` to your `PATH` -#: which otherwise build-systems would not find. +#: which otherwise build systems would not find. +#: +#: If `--env=std` is passed, use the standard `PATH` instead of superenv's. require "extend/ENV" require "formula" @@ -20,13 +22,13 @@ def sh end ENV.setup_build_environment if superenv? - # superenv stopped adding brew's bin but generally user's will want it + # superenv stopped adding brew's bin but generally users will want it ENV["PATH"] = ENV["PATH"].split(File::PATH_SEPARATOR).insert(1, "#{HOMEBREW_PREFIX}/bin").join(File::PATH_SEPARATOR) end ENV["PS1"] = 'brew \[\033[1;32m\]\w\[\033[0m\]$ ' ENV["VERBOSE"] = "1" puts <<-EOS.undent_________________________________________________________72 - Your shell has been configured to use Homebrew's build environment: + Your shell has been configured to use Homebrew's build environment; this should help you build stuff. Notably though, the system versions of gem and pip will ignore our configuration and insist on using the environment they were built under (mostly). Sadly, scons will also
true
Other
Homebrew
brew
aee23ccb0355228f24d387fcbe7cf5d30f57d8b6.json
Add more flags and descriptions to man pages.
Library/Homebrew/dev-cmd/bottle.rb
@@ -1,7 +1,29 @@ -#: * `bottle` [`--verbose`] [`--no-rebuild`] [`--keep-old`] [`--skip-relocation`] [`--root-url=`<URL>] [`--force-core-tap`]: -#: * `bottle` `--merge` [`--no-commit`] [`--keep-old`] [`--write`]: +#: * `bottle` [`--verbose`] [`--no-rebuild`|`--keep-old`] [`--skip-relocation`] [`--root-url=`<URL>] [`--force-core-tap`] <formulae>: #: Generate a bottle (binary package) from a formula installed with #: `--build-bottle`. +#: +#: If the formula specifies a rebuild version, it will be incremented in the +#: generated DSL. Passing `--keep-old` will attempt to keep it at its +#: original value, while `--no-rebuild` will remove it. +#: +#: If `--verbose` is passed, print the bottling commands and any warnings +#: encountered. +#: +#: If `--skip-relocation` is passed, do not check if the bottle can be marked +#: as relocatable. +#: +#: If `--root-url` is passed, use the specified <URL> as the root of the +#: bottle's URL instead of Homebrew's default. +#: +#: If `--force-core-tap` is passed, build a bottle even if <formula> is not +#: in homebrew/core or any installed taps. +#: +#: * `bottle` `--merge` [`--keep-old`] [`--write` [`--no-commit`]] <formulae>: +#: Generate a bottle from a formula and print the new DSL merged into the +#: existing formula. +#: +#: If `--write` is passed, write the changes to the formula file. A new +#: commit will then be generated unless `--no-commit` is passed. require "formula" require "utils/bottles"
true
Other
Homebrew
brew
aee23ccb0355228f24d387fcbe7cf5d30f57d8b6.json
Add more flags and descriptions to man pages.
Library/Homebrew/dev-cmd/tests.rb
@@ -1,5 +1,21 @@ -#: * `tests` [`-v`] [`--coverage`] [`--generic`] [`--no-compat`] [`--only=`<test_script>`:`<line_number>] [`--seed` <seed>] [`--online`] [`--official-cmd-taps`]: -#: Run Homebrew's unit and integration tests. +#: * `tests` [`--verbose`] [`--coverage`] [`--generic`] [`--no-compat`] [`--only=`<test_script>[`:`<line_number>]] [`--seed` <seed>] [`--online`] [`--official-cmd-taps`]: +#: Run Homebrew's unit and integration tests. If provided, +#: `--only=`<test_script> runs only <test_script>_spec.rb, and `--seed` +#: randomizes tests with the provided value instead of a random seed. +#: +#: If `--verbose` is passed, print the command that runs the tests. +#: +#: If `--coverage` is passed, also generate code coverage reports. +#: +#: If `--generic` is passed, only run OS-agnostic tests. +#: +#: If `--no-compat` is passed, do not load the compatibility layer when +#: running tests. +#: +#: If `--online` is passed, include tests that use the GitHub API. +#: +#: If `--official-cmd-taps` is passed, include tests that use any of the +#: taps for official external commands. require "fileutils" require "tap"
true
Other
Homebrew
brew
aee23ccb0355228f24d387fcbe7cf5d30f57d8b6.json
Add more flags and descriptions to man pages.
Library/Homebrew/dev-cmd/update-test.rb
@@ -1,4 +1,4 @@ -#: * `update-test` [`--commit=`<commit>] [`--before=`<date>] [`--keep-tmp`]: +#: * `update-test` [`--commit=`<commit>] [`--before=`<date>] [`--to-tag`] [`--keep-tmp`]: #: Runs a test of `brew update` with a new repository clone. #: #: If no arguments are passed, use `origin/master` as the start commit.
true
Other
Homebrew
brew
aee23ccb0355228f24d387fcbe7cf5d30f57d8b6.json
Add more flags and descriptions to man pages.
Library/Homebrew/manpages/brew.1.md.erb
@@ -65,7 +65,7 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note <https://github.com/caskroom/homebrew-cask> * `services`: - Integrates Homebrew formulae with macOS's `launchctl` manager: + Integrates Homebrew formulae with macOS's `launchctl`(1) manager: <https://github.com/Homebrew/homebrew-services> ## CUSTOM EXTERNAL COMMANDS
true
Other
Homebrew
brew
aee23ccb0355228f24d387fcbe7cf5d30f57d8b6.json
Add more flags and descriptions to man pages.
docs/brew.1.html
@@ -152,7 +152,7 @@ <h2 id="COMMANDS">COMMANDS</h2> <p>See the docs for examples of using the JSON output: <a href="http://docs.brew.sh/Querying-Brew.html" data-bare-link="true">http://docs.brew.sh/Querying-Brew.html</a></p></dd> -<dt><code>install</code> [<code>--debug</code>] [<code>--env=</code><var>std</var>|<var>super</var>] [<code>--ignore-dependencies</code>] [<code>--only-dependencies</code>] [<code>--cc=</code><var>compiler</var>] [<code>--build-from-source</code>] [<code>--devel</code>|<code>--HEAD</code>] [<code>--keep-tmp</code>] <var>formula</var></dt><dd><p>Install <var>formula</var>.</p> +<dt><code>install</code> [<code>--debug</code>] [<code>--env=</code>(<code>std</code>|<code>super</code>)] [<code>--ignore-dependencies</code>|<code>--only-dependencies</code>] [<code>--cc=</code><var>compiler</var>] [<code>--build-from-source</code>|<code>--force-bottle</code>] [<code>--devel</code>|<code>--HEAD</code>] [<code>--keep-tmp</code>] [<code>--build-bottle</code>] <var>formula</var></dt><dd><p>Install <var>formula</var>.</p> <p><var>formula</var> is usually the name of the formula to install, but it can be specified in several different ways. See <a href="#SPECIFYING-FORMULAE" title="SPECIFYING FORMULAE" data-bare-link="true">SPECIFYING FORMULAE</a>.</p> @@ -195,7 +195,10 @@ <h2 id="COMMANDS">COMMANDS</h2> aka master, trunk, unstable.</p> <p>If <code>--keep-tmp</code> is passed, the temporary files created during installation -are not deleted.</p></dd> +are not deleted.</p> + +<p>If <code>--build-bottle</code> is passed, prepare the formula for eventual bottling +during installation.</p></dd> <dt><code>install</code> <code>--interactive</code> [<code>--git</code>] <var>formula</var></dt><dd><p>Download and patch <var>formula</var>, then open a shell. This allows the user to run <code>./configure --help</code> and otherwise determine how to turn the software package into a Homebrew formula.</p> @@ -301,11 +304,13 @@ <h2 id="COMMANDS">COMMANDS</h2> <p>If <code>--desc</code> is passed, browse available packages matching <var>text</var> including a description for each.</p></dd> <dt><code>search</code> (<code>--debian</code>|<code>--fedora</code>|<code>--fink</code>|<code>--macports</code>|<code>--opensuse</code>|<code>--ubuntu</code>) <var>text</var></dt><dd><p>Search for <var>text</var> in the given package manager's list.</p></dd> -<dt><code>sh</code> [<code>--env=std</code>]</dt><dd><p>Instantiate a Homebrew build environment. Uses our years-battle-hardened +<dt><code>sh</code> [<code>--env=std</code>]</dt><dd><p>Start a Homebrew build environment shell. Uses our years-battle-hardened Homebrew build logic to help your <code>./configure &amp;&amp; make &amp;&amp; make install</code> or even your <code>gem install</code> succeed. Especially handy if you run Homebrew in an Xcode-only configuration since it adds tools like <code>make</code> to your <code>PATH</code> -which otherwise build-systems would not find.</p></dd> +which otherwise build systems would not find.</p> + +<p>If <code>--env=std</code> is passed, use the standard <code>PATH</code> instead of superenv's.</p></dd> <dt><code>style</code> [<code>--fix</code>] [<code>--display-cop-names</code>] [<var>files</var>|<var>taps</var>|<var>formulae</var>]</dt><dd><p>Check formulae or files for conformance to Homebrew style guidelines.</p> <p><var>formulae</var> and <var>files</var> may not be combined. If both are omitted, style will run @@ -478,9 +483,29 @@ <h2 id="DEVELOPER-COMMANDS">DEVELOPER COMMANDS</h2> <p><code>audit</code> exits with a non-zero status if any errors are found. This is useful, for instance, for implementing pre-commit hooks.</p></dd> -<dt><code>bottle</code> [<code>--verbose</code>] [<code>--no-rebuild</code>] [<code>--keep-old</code>] [<code>--skip-relocation</code>] [<code>--root-url=</code><var>URL</var>] [<code>--force-core-tap</code>]:</dt><dd><p></p></dd> -<dt><code>bottle</code> <code>--merge</code> [<code>--no-commit</code>] [<code>--keep-old</code>] [<code>--write</code>]</dt><dd><p>Generate a bottle (binary package) from a formula installed with -<code>--build-bottle</code>.</p></dd> +<dt><code>bottle</code> [<code>--verbose</code>] [<code>--no-rebuild</code>|<code>--keep-old</code>] [<code>--skip-relocation</code>] [<code>--root-url=</code><var>URL</var>] [<code>--force-core-tap</code>] <var>formulae</var></dt><dd><p>Generate a bottle (binary package) from a formula installed with +<code>--build-bottle</code>.</p> + +<p>If the formula specifies a rebuild version, it will be incremented in the +generated DSL. Passing <code>--keep-old</code> will attempt to keep it at its +original value, while <code>--no-rebuild</code> will remove it.</p> + +<p>If <code>--verbose</code> is passed, print the bottling commands and any warnings +encountered.</p> + +<p>If <code>--skip-relocation</code> is passed, do not check if the bottle can be marked +as relocatable.</p> + +<p>If <code>--root-url</code> is passed, use the specified <var>URL</var> as the root of the +bottle's URL instead of Homebrew's default.</p> + +<p>If <code>--force-core-tap</code> is passed, build a bottle even if <var>formula</var> is not +in homebrew/core or any installed taps.</p></dd> +<dt><code>bottle</code> <code>--merge</code> [<code>--keep-old</code>] [<code>--write</code> [<code>--no-commit</code>]] <var>formulae</var></dt><dd><p>Generate a bottle from a formula and print the new DSL merged into the +existing formula.</p> + +<p>If <code>--write</code> is passed, write the changes to the formula file. A new +commit will then be generated unless <code>--no-commit</code> is passed.</p></dd> <dt><code>bump-formula-pr</code> [<code>--devel</code>] [<code>--dry-run</code> [<code>--write</code>]] [<code>--audit</code>|<code>--strict</code>] [<code>--mirror=</code><var>URL</var>] [<code>--version=</code><var>version</var>] [<code>--message=</code><var>message</var>] (<code>--url=</code><var>URL</var> <code>--sha256=</code><var>sha-256</var>|<code>--tag=</code><var>tag</var> <code>--revision=</code><var>revision</var>) <var>formula</var></dt><dd><p>Creates a pull request to update the formula with a new URL or a new tag.</p> <p>If a <var>URL</var> is specified, the <var>sha-256</var> checksum of the new download must @@ -612,8 +637,24 @@ <h2 id="DEVELOPER-COMMANDS">DEVELOPER COMMANDS</h2> not deleted.</p> <p>Example: <code>brew install jruby &amp;&amp; brew test jruby</code></p></dd> -<dt><code>tests</code> [<code>-v</code>] [<code>--coverage</code>] [<code>--generic</code>] [<code>--no-compat</code>] [<code>--only=</code><var>test_script</var><code>:</code><var>line_number</var>] [<code>--seed</code> <var>seed</var>] [<code>--online</code>] [<code>--official-cmd-taps</code>]</dt><dd><p>Run Homebrew's unit and integration tests.</p></dd> -<dt><code>update-test</code> [<code>--commit=</code><var>commit</var>] [<code>--before=</code><var>date</var>] [<code>--keep-tmp</code>]</dt><dd><p>Runs a test of <code>brew update</code> with a new repository clone.</p> +<dt><code>tests</code> [<code>--verbose</code>] [<code>--coverage</code>] [<code>--generic</code>] [<code>--no-compat</code>] [<code>--only=</code><var>test_script</var>[<code>:</code><var>line_number</var>]] [<code>--seed</code> <var>seed</var>] [<code>--online</code>] [<code>--official-cmd-taps</code>]</dt><dd><p>Run Homebrew's unit and integration tests. If provided, +<code>--only=</code><var>test_script</var> runs only <var>test_script</var>_spec.rb, and <code>--seed</code> +randomizes tests with the provided value instead of a random seed.</p> + +<p>If <code>--verbose</code> is passed, print the command that runs the tests.</p> + +<p>If <code>--coverage</code> is passed, also generate code coverage reports.</p> + +<p>If <code>--generic</code> is passed, only run OS-agnostic tests.</p> + +<p>If <code>--no-compat</code> is passed, do not load the compatibility layer when +running tests.</p> + +<p>If <code>--online</code> is passed, include tests that use the GitHub API.</p> + +<p>If <code>--official-cmd-taps</code> is passed, include tests that use any of the +taps for official external commands.</p></dd> +<dt><code>update-test</code> [<code>--commit=</code><var>commit</var>] [<code>--before=</code><var>date</var>] [<code>--to-tag</code>] [<code>--keep-tmp</code>]</dt><dd><p>Runs a test of <code>brew update</code> with a new repository clone.</p> <p>If no arguments are passed, use <code>origin/master</code> as the start commit.</p> @@ -637,7 +678,7 @@ <h2 id="OFFICIAL-EXTERNAL-COMMANDS">OFFICIAL EXTERNAL COMMANDS</h2> <a href="https://github.com/Homebrew/homebrew-bundle" data-bare-link="true">https://github.com/Homebrew/homebrew-bundle</a></p></dd> <dt class="flush"><code>cask</code></dt><dd><p>Install macOS applications distributed as binaries: <a href="https://github.com/caskroom/homebrew-cask" data-bare-link="true">https://github.com/caskroom/homebrew-cask</a></p></dd> -<dt><code>services</code></dt><dd><p>Integrates Homebrew formulae with macOS's <code>launchctl</code> manager: +<dt><code>services</code></dt><dd><p>Integrates Homebrew formulae with macOS's <code>launchctl</code>(1) manager: <a href="https://github.com/Homebrew/homebrew-services" data-bare-link="true">https://github.com/Homebrew/homebrew-services</a></p></dd> </dl>
true
Other
Homebrew
brew
aee23ccb0355228f24d387fcbe7cf5d30f57d8b6.json
Add more flags and descriptions to man pages.
manpages/brew.1
@@ -216,7 +216,7 @@ Pass \fB\-\-all\fR to get information on all formulae, or \fB\-\-installed\fR to See the docs for examples of using the JSON output: \fIhttp://docs\.brew\.sh/Querying\-Brew\.html\fR . .TP -\fBinstall\fR [\fB\-\-debug\fR] [\fB\-\-env=\fR\fIstd\fR|\fIsuper\fR] [\fB\-\-ignore\-dependencies\fR] [\fB\-\-only\-dependencies\fR] [\fB\-\-cc=\fR\fIcompiler\fR] [\fB\-\-build\-from\-source\fR] [\fB\-\-devel\fR|\fB\-\-HEAD\fR] [\fB\-\-keep\-tmp\fR] \fIformula\fR +\fBinstall\fR [\fB\-\-debug\fR] [\fB\-\-env=\fR(\fBstd\fR|\fBsuper\fR)] [\fB\-\-ignore\-dependencies\fR|\fB\-\-only\-dependencies\fR] [\fB\-\-cc=\fR\fIcompiler\fR] [\fB\-\-build\-from\-source\fR|\fB\-\-force\-bottle\fR] [\fB\-\-devel\fR|\fB\-\-HEAD\fR] [\fB\-\-keep\-tmp\fR] [\fB\-\-build\-bottle\fR] \fIformula\fR Install \fIformula\fR\. . .IP @@ -258,6 +258,9 @@ If \fB\-\-HEAD\fR is passed, and \fIformula\fR defines it, install the HEAD vers .IP If \fB\-\-keep\-tmp\fR is passed, the temporary files created during installation are not deleted\. . +.IP +If \fB\-\-build\-bottle\fR is passed, prepare the formula for eventual bottling during installation\. +. .TP \fBinstall\fR \fB\-\-interactive\fR [\fB\-\-git\fR] \fIformula\fR Download and patch \fIformula\fR, then open a shell\. This allows the user to run \fB\./configure \-\-help\fR and otherwise determine how to turn the software package into a Homebrew formula\. @@ -406,7 +409,10 @@ Search for \fItext\fR in the given package manager\'s list\. . .TP \fBsh\fR [\fB\-\-env=std\fR] -Instantiate a Homebrew build environment\. Uses our years\-battle\-hardened Homebrew build logic to help your \fB\./configure && make && make install\fR or even your \fBgem install\fR succeed\. Especially handy if you run Homebrew in an Xcode\-only configuration since it adds tools like \fBmake\fR to your \fBPATH\fR which otherwise build\-systems would not find\. +Start a Homebrew build environment shell\. Uses our years\-battle\-hardened Homebrew build logic to help your \fB\./configure && make && make install\fR or even your \fBgem install\fR succeed\. Especially handy if you run Homebrew in an Xcode\-only configuration since it adds tools like \fBmake\fR to your \fBPATH\fR which otherwise build systems would not find\. +. +.IP +If \fB\-\-env=std\fR is passed, use the standard \fBPATH\fR instead of superenv\'s\. . .TP \fBstyle\fR [\fB\-\-fix\fR] [\fB\-\-display\-cop\-names\fR] [\fIfiles\fR|\fItaps\fR|\fIformulae\fR] @@ -653,12 +659,30 @@ If \fB\-\-display\-filename\fR is passed, every line of output is prefixed with \fBaudit\fR exits with a non\-zero status if any errors are found\. This is useful, for instance, for implementing pre\-commit hooks\. . .TP -\fBbottle\fR [\fB\-\-verbose\fR] [\fB\-\-no\-rebuild\fR] [\fB\-\-keep\-old\fR] [\fB\-\-skip\-relocation\fR] [\fB\-\-root\-url=\fR\fIURL\fR] [\fB\-\-force\-core\-tap\fR]: - +\fBbottle\fR [\fB\-\-verbose\fR] [\fB\-\-no\-rebuild\fR|\fB\-\-keep\-old\fR] [\fB\-\-skip\-relocation\fR] [\fB\-\-root\-url=\fR\fIURL\fR] [\fB\-\-force\-core\-tap\fR] \fIformulae\fR +Generate a bottle (binary package) from a formula installed with \fB\-\-build\-bottle\fR\. +. +.IP +If the formula specifies a rebuild version, it will be incremented in the generated DSL\. Passing \fB\-\-keep\-old\fR will attempt to keep it at its original value, while \fB\-\-no\-rebuild\fR will remove it\. +. +.IP +If \fB\-\-verbose\fR is passed, print the bottling commands and any warnings encountered\. +. +.IP +If \fB\-\-skip\-relocation\fR is passed, do not check if the bottle can be marked as relocatable\. +. +.IP +If \fB\-\-root\-url\fR is passed, use the specified \fIURL\fR as the root of the bottle\'s URL instead of Homebrew\'s default\. +. +.IP +If \fB\-\-force\-core\-tap\fR is passed, build a bottle even if \fIformula\fR is not in homebrew/core or any installed taps\. . .TP -\fBbottle\fR \fB\-\-merge\fR [\fB\-\-no\-commit\fR] [\fB\-\-keep\-old\fR] [\fB\-\-write\fR] -Generate a bottle (binary package) from a formula installed with \fB\-\-build\-bottle\fR\. +\fBbottle\fR \fB\-\-merge\fR [\fB\-\-keep\-old\fR] [\fB\-\-write\fR [\fB\-\-no\-commit\fR]] \fIformulae\fR +Generate a bottle from a formula and print the new DSL merged into the existing formula\. +. +.IP +If \fB\-\-write\fR is passed, write the changes to the formula file\. A new commit will then be generated unless \fB\-\-no\-commit\fR is passed\. . .TP \fBbump\-formula\-pr\fR [\fB\-\-devel\fR] [\fB\-\-dry\-run\fR [\fB\-\-write\fR]] [\fB\-\-audit\fR|\fB\-\-strict\fR] [\fB\-\-mirror=\fR\fIURL\fR] [\fB\-\-version=\fR\fIversion\fR] [\fB\-\-message=\fR\fImessage\fR] (\fB\-\-url=\fR\fIURL\fR \fB\-\-sha256=\fR\fIsha\-256\fR|\fB\-\-tag=\fR\fItag\fR \fB\-\-revision=\fR\fIrevision\fR) \fIformula\fR @@ -816,11 +840,29 @@ If \fB\-\-keep\-tmp\fR is passed, the temporary files created for the test are n Example: \fBbrew install jruby && brew test jruby\fR . .TP -\fBtests\fR [\fB\-v\fR] [\fB\-\-coverage\fR] [\fB\-\-generic\fR] [\fB\-\-no\-compat\fR] [\fB\-\-only=\fR\fItest_script\fR\fB:\fR\fIline_number\fR] [\fB\-\-seed\fR \fIseed\fR] [\fB\-\-online\fR] [\fB\-\-official\-cmd\-taps\fR] -Run Homebrew\'s unit and integration tests\. +\fBtests\fR [\fB\-\-verbose\fR] [\fB\-\-coverage\fR] [\fB\-\-generic\fR] [\fB\-\-no\-compat\fR] [\fB\-\-only=\fR\fItest_script\fR[\fB:\fR\fIline_number\fR]] [\fB\-\-seed\fR \fIseed\fR] [\fB\-\-online\fR] [\fB\-\-official\-cmd\-taps\fR] +Run Homebrew\'s unit and integration tests\. If provided, \fB\-\-only=\fR\fItest_script\fR runs only \fItest_script\fR_spec\.rb, and \fB\-\-seed\fR randomizes tests with the provided value instead of a random seed\. +. +.IP +If \fB\-\-verbose\fR is passed, print the command that runs the tests\. +. +.IP +If \fB\-\-coverage\fR is passed, also generate code coverage reports\. +. +.IP +If \fB\-\-generic\fR is passed, only run OS\-agnostic tests\. +. +.IP +If \fB\-\-no\-compat\fR is passed, do not load the compatibility layer when running tests\. +. +.IP +If \fB\-\-online\fR is passed, include tests that use the GitHub API\. +. +.IP +If \fB\-\-official\-cmd\-taps\fR is passed, include tests that use any of the taps for official external commands\. . .TP -\fBupdate\-test\fR [\fB\-\-commit=\fR\fIcommit\fR] [\fB\-\-before=\fR\fIdate\fR] [\fB\-\-keep\-tmp\fR] +\fBupdate\-test\fR [\fB\-\-commit=\fR\fIcommit\fR] [\fB\-\-before=\fR\fIdate\fR] [\fB\-\-to\-tag\fR] [\fB\-\-keep\-tmp\fR] Runs a test of \fBbrew update\fR with a new repository clone\. . .IP @@ -850,7 +892,7 @@ Install macOS applications distributed as binaries: \fIhttps://github\.com/caskr . .TP \fBservices\fR -Integrates Homebrew formulae with macOS\'s \fBlaunchctl\fR manager: \fIhttps://github\.com/Homebrew/homebrew\-services\fR +Integrates Homebrew formulae with macOS\'s \fBlaunchctl\fR(1) manager: \fIhttps://github\.com/Homebrew/homebrew\-services\fR . .SH "CUSTOM EXTERNAL COMMANDS" Homebrew, like \fBgit\fR(1), supports external commands\. These are executable scripts that reside somewhere in the \fBPATH\fR, named \fBbrew\-\fR\fIcmdname\fR or \fBbrew\-\fR\fIcmdname\fR\fB\.rb\fR, which can be invoked like \fBbrew\fR \fIcmdname\fR\. This allows you to create your own commands without modifying Homebrew\'s internals\.
true
Other
Homebrew
brew
bba2c632ec972eab5289e5114908eff28eb82be9.json
Remove Cask Gemfile.
Library/Homebrew/cask/Gemfile
@@ -1,11 +0,0 @@ -source "https://rubygems.org" - -gem "parallel_tests" -gem "rspec" -gem "rspec-its", require: false -gem "rspec-wait", require: false - -group :coverage do - gem "simplecov", require: false - gem "codecov", require: false -end
true
Other
Homebrew
brew
bba2c632ec972eab5289e5114908eff28eb82be9.json
Remove Cask Gemfile.
Library/Homebrew/cask/Gemfile.lock
@@ -1,51 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - codecov (0.1.9) - json - simplecov - url - diff-lcs (1.3) - docile (1.1.5) - json (2.0.3) - parallel (1.10.0) - parallel_tests (2.13.0) - parallel - rspec (3.5.0) - rspec-core (~> 3.5.0) - rspec-expectations (~> 3.5.0) - rspec-mocks (~> 3.5.0) - rspec-core (3.5.4) - rspec-support (~> 3.5.0) - rspec-expectations (3.5.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) - rspec-its (1.2.0) - rspec-core (>= 3.0.0) - rspec-expectations (>= 3.0.0) - rspec-mocks (3.5.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) - rspec-support (3.5.0) - rspec-wait (0.0.9) - rspec (>= 3, < 4) - simplecov (0.13.0) - docile (~> 1.1.0) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.0) - url (0.3.2) - -PLATFORMS - ruby - -DEPENDENCIES - codecov - parallel_tests - rspec - rspec-its - rspec-wait - simplecov - -BUNDLED WITH - 1.14.5
true
Other
Homebrew
brew
b7135eec493c1b2cad69b934bbf0d1aefbcbf8ab.json
Move `shared_examples` and `matcher` into specs.
Library/Homebrew/cask/spec/cask/audit_spec.rb
@@ -1,5 +1,39 @@ describe Hbc::Audit do - include AuditMatchers + def include_msg?(messages, msg) + if msg.is_a?(Regexp) + Array(messages).any? { |m| m =~ msg } + else + Array(messages).include?(msg) + end + end + + matcher :pass do + match do |audit| + !audit.errors? && !audit.warnings? + end + end + + matcher :fail do + match(&:errors?) + end + + matcher :warn do + match do |audit| + audit.warnings? && !audit.errors? + end + end + + matcher :fail_with do |error_msg| + match do |audit| + include_msg?(audit.errors, error_msg) + end + end + + matcher :warn_with do |warning_msg| + match do |audit| + include_msg?(audit.warnings, warning_msg) + end + end let(:cask) { instance_double(Hbc::Cask) } let(:download) { false }
true
Other
Homebrew
brew
b7135eec493c1b2cad69b934bbf0d1aefbcbf8ab.json
Move `shared_examples` and `matcher` into specs.
Library/Homebrew/cask/spec/cask/dsl/version_spec.rb
@@ -1,7 +1,12 @@ describe Hbc::DSL::Version do - include ExpectationsHashHelper - - let(:version) { described_class.new(raw_version) } + shared_examples "expectations hash" do |input_name, expectations| + expectations.each do |input_value, expected_output| + context "when #{input_name} is #{input_value.inspect}" do + let(input_name.to_sym) { input_value } + it { is_expected.to eq expected_output } + end + end + end shared_examples "version equality" do let(:raw_version) { "1.2.3" } @@ -36,6 +41,8 @@ end end + let(:version) { described_class.new(raw_version) } + describe "#==" do subject { version == other } include_examples "version equality"
true
Other
Homebrew
brew
b7135eec493c1b2cad69b934bbf0d1aefbcbf8ab.json
Move `shared_examples` and `matcher` into specs.
Library/Homebrew/cask/spec/support/audit_matchers.rb
@@ -1,39 +0,0 @@ -module AuditMatchers - extend RSpec::Matchers::DSL - - matcher :pass do - match do |audit| - !audit.errors? && !audit.warnings? - end - end - - matcher :fail do - match(&:errors?) - end - - matcher :warn do - match do |audit| - audit.warnings? && !audit.errors? - end - end - - matcher :fail_with do |error_msg| - match do |audit| - include_msg?(audit.errors, error_msg) - end - end - - matcher :warn_with do |warning_msg| - match do |audit| - include_msg?(audit.warnings, warning_msg) - end - end - - def include_msg?(messages, msg) - if msg.is_a?(Regexp) - Array(messages).any? { |m| m =~ msg } - else - Array(messages).include?(msg) - end - end -end
true
Other
Homebrew
brew
b7135eec493c1b2cad69b934bbf0d1aefbcbf8ab.json
Move `shared_examples` and `matcher` into specs.
Library/Homebrew/cask/spec/support/expectations_hash_helper.rb
@@ -1,10 +0,0 @@ -module ExpectationsHashHelper - shared_examples "expectations hash" do |input_name, expectations| - expectations.each do |input_value, expected_output| - context "when #{input_name} is #{input_value.inspect}" do - let(input_name.to_sym) { input_value } - it { is_expected.to eq expected_output } - end - end - end -end
true
Other
Homebrew
brew
a1fbb1020bdfa5cad0659b466c4b236c7d37c789.json
Simplify Cask `spec_helper`.
Library/Homebrew/cask/lib/hbc/locations.rb
@@ -15,6 +15,8 @@ def default_caskroom @default_caskroom ||= HOMEBREW_PREFIX.join("Caskroom") end + attr_writer :caskroom + def caskroom @caskroom ||= begin if Utils.path_occupied?(legacy_caskroom) @@ -36,14 +38,12 @@ def caskroom end end - def caskroom=(caskroom) - @caskroom = caskroom - end - def legacy_cache @legacy_cache ||= HOMEBREW_CACHE.join("Casks") end + attr_writer :cache + def cache @cache ||= HOMEBREW_CACHE.join("Cask") end
true
Other
Homebrew
brew
a1fbb1020bdfa5cad0659b466c4b236c7d37c789.json
Simplify Cask `spec_helper`.
Library/Homebrew/cask/spec/spec_helper.rb
@@ -1,4 +1,3 @@ -require "pathname" require "rspec/its" require "rspec/wait" @@ -22,9 +21,6 @@ require "hbc" # create and override default directories -Hbc.appdir = Pathname.new(TEST_TMPDIR).join("Applications").tap(&:mkpath) -Hbc.cache.mkpath -Hbc.caskroom = Hbc.default_caskroom.tap(&:mkpath) Hbc.default_tap = Tap.fetch("caskroom", "spec").tap do |tap| # link test casks FileUtils.mkdir_p tap.path.dirname @@ -37,6 +33,7 @@ HOMEBREW_CASK_DIRS = [ :appdir, :caskroom, + :cache, :prefpanedir, :qlplugindir, :servicedir,
true
Other
Homebrew
brew
8385f179dfc6dc056a248cb445627fa02f83f397.json
audit: reject versions starting with HEAD Many parts of Homebrew assume that a version string beginning with "HEAD" is, in fact, a head build. A stable version that begins with "HEAD" violates this assumption and causes problems, as it's treated as a head build in some places and as a stable build in others.
Library/Homebrew/dev-cmd/audit.rb
@@ -755,6 +755,9 @@ def audit_specs if version.to_s !~ /\d/ problem "#{name}: version (#{version}) is set to a string without a digit" end + if version.to_s.start_with?("HEAD") + problem "#{name}: non-HEAD version name (#{version}) should not begin with HEAD" + end end if formula.stable && formula.devel
false
Other
Homebrew
brew
ea28c79031b157e7604ac905e7a09fbe2e603778.json
java_requirement: avoid nil in possible_javas
Library/Homebrew/extend/os/mac/requirements/java_requirement.rb
@@ -14,7 +14,7 @@ def possible_javas javas << java_home_cmd javas << which("java") javas.delete(Pathname.new("/usr/bin/java")) # /usr/bin/java is a stub on macOS - javas + javas.compact end def java_home_cmd
false
Other
Homebrew
brew
f9e07fcaab781d9d7e37348f5af37a832cd914ea.json
Fix typo in the new issue template
.github/ISSUE_TEMPLATE.md
@@ -4,7 +4,7 @@ If Homebrew was updated on Aug 10-11th 2016 and `brew update` always says `Alrea - [ ] Ran `brew update` and retried your prior step? - [ ] Ran `brew doctor`, fixed as many issues as possible and retried your prior step? -- [ ] Confirmed this is problem with Homebrew/brew and not specific formulae? If it's a formulae-specific problem please file this issue at https://github.com/Homebrew/homebrew-core/issues/new +- [ ] Confirmed this is a problem with Homebrew/brew and not specific formulae? If it's a formulae-specific problem please file this issue at https://github.com/Homebrew/homebrew-core/issues/new _You can erase any parts of this template not applicable to your Issue._
false
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/cmd/bundle_spec.rb
@@ -10,9 +10,9 @@ end end - Dir.mktmpdir do |path| + mktmpdir do |path| FileUtils.touch "#{path}/Brewfile" - Dir.chdir path do + path.cd do expect { brew "bundle", "check" } .to output("The Brewfile's dependencies are satisfied.\n").to_stdout .and not_to_output.to_stderr
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/cmd/commands_spec.rb
@@ -54,7 +54,7 @@ end specify "::external_commands" do - Dir.mktmpdir do |dir| + mktmpdir do |dir| %w[brew-t1 brew-t2.rb brew-t3.py].each do |file| path = "#{dir}/#{file}" FileUtils.touch path
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/cmd/custom-external-command_spec.rb
@@ -1,8 +1,6 @@ describe "brew custom-external-command", :integration_test do it "is supported" do - Dir.mktmpdir do |path| - path = Pathname.new(path) - + mktmpdir do |path| cmd = "custom-external-command-#{rand}" file = path/"brew-#{cmd}"
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/cmd/linkapps_spec.rb
@@ -1,11 +1,7 @@ describe "brew linkapps", :integration_test do - let(:home_dir) { @home_dir = Pathname.new(Dir.mktmpdir) } + let(:home_dir) { mktmpdir } let(:apps_dir) { home_dir/"Applications" } - after(:each) do - home_dir.rmtree unless @home_dir.nil? - end - it "symlinks applications" do apps_dir.mkpath
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/cmd/unlinkapps_spec.rb
@@ -1,11 +1,7 @@ describe "brew unlinkapps", :integration_test do - let(:home_dir) { @home_dir = Pathname.new(Dir.mktmpdir) } + let(:home_dir) { mktmpdir } let(:apps_dir) { home_dir/"Applications" } - after(:each) do - home_dir.rmtree unless @home_dir.nil? - end - it "unlinks symlinked applications" do apps_dir.mkpath
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/cmd/unpack_spec.rb
@@ -2,9 +2,7 @@ it "unpacks a given Formula's archive" do setup_test_formula "testball" - Dir.mktmpdir do |path| - path = Pathname.new(path) - + mktmpdir do |path| shutup do expect { brew "unpack", "testball", "--destdir=#{path}" } .to be_a_success
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/dev-cmd/audit_spec.rb
@@ -6,11 +6,7 @@ RSpec::Matchers.alias_matcher :have_trailing_newline, :be_trailing_newline describe FormulaText do - let(:dir) { @dir = Pathname.new(Dir.mktmpdir) } - - after(:each) do - dir.rmtree unless @dir.nil? - end + let(:dir) { mktmpdir } def formula_text(name, body = nil, options = {}) path = dir/"#{name}.rb" @@ -70,11 +66,7 @@ def formula_auditor(name, text, options = {}) described_class.new(Formulary.factory(path), options) end - let(:dir) { @dir = Pathname.new(Dir.mktmpdir) } - - after(:each) do - dir.rmtree unless @dir.nil? - end + let(:dir) { mktmpdir } describe "#problems" do it "is empty by default" do
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/diagnostic_spec.rb
@@ -13,7 +13,7 @@ end specify "#check_for_anaconda" do - Dir.mktmpdir do |path| + mktmpdir do |path| anaconda = "#{path}/anaconda" python = "#{path}/python" FileUtils.touch anaconda @@ -23,7 +23,7 @@ FileUtils.chmod 0755, anaconda FileUtils.chmod 0755, python - ENV["PATH"] = path + File::PATH_SEPARATOR + ENV["PATH"] + ENV["PATH"] = "#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}" expect(subject.check_for_anaconda).to match("Anaconda") end @@ -124,7 +124,7 @@ end specify "#check_user_curlrc" do - Dir.mktmpdir do |path| + mktmpdir do |path| FileUtils.touch "#{path}/.curlrc" ENV["CURL_HOME"] = path @@ -133,7 +133,7 @@ end specify "#check_for_config_scripts" do - Dir.mktmpdir do |path| + mktmpdir do |path| file = "#{path}/foo-config" FileUtils.touch file FileUtils.chmod 0755, file @@ -153,7 +153,7 @@ begin HOMEBREW_CELLAR.rmtree - Dir.mktmpdir do |path| + mktmpdir do |path| FileUtils.ln_s path, HOMEBREW_CELLAR expect(subject.check_for_symlinked_cellar).to match(path) @@ -170,8 +170,8 @@ end specify "#check_for_external_cmd_name_conflict" do - Dir.mktmpdir do |path1| - Dir.mktmpdir do |path2| + mktmpdir do |path1| + mktmpdir do |path2| [path1, path2].each do |path| cmd = "#{path}/brew-foo" FileUtils.touch cmd
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/gpg2_requirement_spec.rb
@@ -2,11 +2,7 @@ require "fileutils" describe GPG2Requirement do - let(:dir) { @dir = Pathname.new(Dir.mktmpdir) } - - after(:each) do - FileUtils.rm_rf dir unless @dir.nil? - end + let(:dir) { mktmpdir } describe "#satisfied?" do it "returns true if GPG2 is installed" do
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/gpg_spec.rb
@@ -7,9 +7,8 @@ it "creates a test key in the home directory" do skip "GPG Unavailable" unless subject.available? - Dir.mktmpdir do |dir| + mktmpdir do |dir| ENV["HOME"] = dir - dir = Pathname.new(dir) shutup do subject.create_test_key(dir)
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/java_requirement_spec.rb
@@ -46,7 +46,7 @@ end context "when #possible_javas contains paths" do - let(:path) { Pathname.new(Dir.mktmpdir) } + let(:path) { mktmpdir } let(:java) { path/"java" } def setup_java_with_version(version) @@ -61,10 +61,6 @@ def setup_java_with_version(version) allow(subject).to receive(:possible_javas).and_return([java]) end - after(:each) do - path.rmtree - end - context "and 1.7 is required" do subject { described_class.new(%w[1.7]) }
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/language/go_spec.rb
@@ -6,7 +6,7 @@ expect(described_class).to receive(:opoo).once - Dir.mktmpdir do |path| + mktmpdir do |path| shutup do described_class.stage_deps [], path end
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/language/python_spec.rb
@@ -4,14 +4,12 @@ describe Language::Python::Virtualenv::Virtualenv do subject { described_class.new(formula, dir, "python") } - let(:dir) { @dir = Pathname.new(Dir.mktmpdir) } + let(:dir) { mktmpdir } let(:resource) { double("resource", stage: true) } let(:formula_bin) { dir/"formula_bin" } let(:formula) { double("formula", resource: resource, bin: formula_bin) } - after(:each) { dir.rmtree unless @dir.nil? } - describe "#create" do it "creates a virtual environment" do expect(formula).to receive(:resource).with("homebrew-virtualenv").and_return(resource)
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/os/mac/java_requirement_spec.rb
@@ -3,32 +3,29 @@ describe JavaRequirement do subject { described_class.new(%w[1.8]) } - let(:java_home) { Dir.mktmpdir } - let(:java_home_path) { Pathname.new(java_home) } + let(:java_home) { mktmpdir } before(:each) do - FileUtils.mkdir java_home_path/"bin" - FileUtils.touch java_home_path/"bin/java" - allow(subject).to receive(:preferred_java).and_return(java_home_path/"bin/java") + FileUtils.mkdir java_home/"bin" + FileUtils.touch java_home/"bin/java" + allow(subject).to receive(:preferred_java).and_return(java_home/"bin/java") expect(subject).to be_satisfied end - after(:each) { java_home_path.rmtree } - specify "Apple Java environment" do expect(ENV).to receive(:prepend_path) expect(ENV).to receive(:append_to_cflags) subject.modify_build_environment - expect(ENV["JAVA_HOME"]).to eq(java_home) + expect(ENV["JAVA_HOME"]).to eq(java_home.to_s) end specify "Oracle Java environment" do - FileUtils.mkdir java_home_path/"include" + FileUtils.mkdir java_home/"include" expect(ENV).to receive(:prepend_path) expect(ENV).to receive(:append_to_cflags).twice subject.modify_build_environment - expect(ENV["JAVA_HOME"]).to eq(java_home) + expect(ENV["JAVA_HOME"]).to eq(java_home.to_s) end end
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/pathname_spec.rb
@@ -5,13 +5,11 @@ describe Pathname do include FileUtils - let(:src) { Pathname.new(Dir.mktmpdir) } - let(:dst) { Pathname.new(Dir.mktmpdir) } + let(:src) { mktmpdir } + let(:dst) { mktmpdir } let(:file) { src/"foo" } let(:dir) { src/"bar" } - after(:each) { rm_rf [src, dst] } - describe DiskUsageExtension do before(:each) do mkdir_p dir/"a-directory" @@ -294,7 +292,7 @@ end describe FileUtils do - let(:dst) { Pathname.new(Dir.mktmpdir) } + let(:dst) { mktmpdir } describe "#mkdir" do it "creates indermediate directories" do
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/sandbox_spec.rb
@@ -3,17 +3,13 @@ RSpec::Matchers.define_negated_matcher :not_matching, :matching describe Sandbox do - let(:dir) { @dir = Pathname.new(Dir.mktmpdir) } + let(:dir) { mktmpdir } let(:file) { dir/"foo" } before(:each) do skip "Sandbox not implemented." unless described_class.available? end - after(:each) do - dir.rmtree unless @dir.nil? - end - specify "#formula?" do f = formula { url "foo-1.0" } f2 = formula { url "bar-1.0" }
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/spec_helper.rb
@@ -17,6 +17,7 @@ require "test/support/helper/shutup" require "test/support/helper/fixtures" require "test/support/helper/formula" +require "test/support/helper/mktmpdir" require "test/support/helper/spec/shared_context/integration_test" TEST_DIRECTORIES = [ @@ -35,6 +36,7 @@ config.include(Test::Helper::Shutup) config.include(Test::Helper::Fixtures) config.include(Test::Helper::Formula) + config.include(Test::Helper::MkTmpDir) config.before(:each, :needs_compat) do skip "Requires compatibility layer." if ENV["HOMEBREW_NO_COMPAT"]
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/support/helper/mktmpdir.rb
@@ -0,0 +1,11 @@ +module Test + module Helper + module MkTmpDir + def mktmpdir(prefix_suffix = nil) + new_dir = Pathname.new(Dir.mktmpdir(prefix_suffix, HOMEBREW_TEMP)) + return yield new_dir if block_given? + new_dir + end + end + end +end
true
Other
Homebrew
brew
a5549023804a8cef50f71dc2d7a723be8e83f3d1.json
Add `mktmpdir` helper method.
Library/Homebrew/test/utils_spec.rb
@@ -1,9 +1,7 @@ require "utils" describe "globally-scoped helper methods" do - let(:dir) { @dir = Pathname.new(Dir.mktmpdir) } - - after(:each) { dir.rmtree unless @dir.nil? } + let(:dir) { mktmpdir } def esc(code) /(\e\[\d+m)*\e\[#{code}m/ @@ -195,8 +193,7 @@ def esc(code) end specify "#gzip" do - Dir.mktmpdir do |path| - path = Pathname.new(path) + mktmpdir do |path| somefile = path/"somefile" FileUtils.touch somefile expect(gzip(somefile)[0].to_s).to eq("#{somefile}.gz")
true
Other
Homebrew
brew
0457f0d3e2186991c16e2136b12a5ecc034d99da.json
README: point new contributors to strict audit.
README.md
@@ -27,7 +27,7 @@ We'd love you to contribute to Homebrew. First, please read our [Contribution Gu We explicitly welcome contributions from people who have never contributed to open-source before: we were all beginners once! We can help build on a partially working pull request with the aim of getting it merged. We are also actively seeking to diversify our contributors and especially welcome contributions from women from all backgrounds and people of colour. -A good starting point for contributing is running `brew audit` (or `brew audit --strict`) with some of the packages you use (e.g. `brew audit wget` if you use `wget`) and then read through the warnings, try to fix them until `brew audit` shows no results and [submit a pull request](http://docs.brew.sh/How-To-Open-a-Homebrew-Pull-Request.html). If no formulae you use have warnings you can run `brew audit` without arguments to have it run on all packages and pick one. Good luck! +A good starting point for contributing is running `brew audit --strict`with some of the packages you use (e.g. `brew audit --strict wget` if you use `wget`) and then read through the warnings, try to fix them until `brew audit --strict` shows no results and [submit a pull request](http://docs.brew.sh/How-To-Open-a-Homebrew-Pull-Request.html). If no formulae you use have warnings you can run `brew audit --strict` without arguments to have it run on all packages and pick one. Good luck! ## Security Please report security issues to security@brew.sh.
false
Other
Homebrew
brew
ebe4042b2f9b7b66e1c2ee9082de002795ea0b81.json
Convert FormulaAuditor test to spec.
Library/Homebrew/test/audit_test.rb
@@ -1,464 +0,0 @@ -require "testing_env" -require "fileutils" -require "pathname" -require "formulary" -require "dev-cmd/audit" - -class FormulaAuditorTests < Homebrew::TestCase - def setup - super - @dir = mktmpdir - end - - def formula_auditor(name, text, options = {}) - path = Pathname.new "#{@dir}/#{name}.rb" - path.open("w") do |f| - f.write text - end - FormulaAuditor.new Formulary.factory(path), options - end - - def test_init_no_problems - fa = formula_auditor "foo", <<-EOS.undent - class Foo < Formula - url "http://example.com/foo-1.0.tgz" - end - EOS - - assert_equal [], fa.problems - end - - def test_audit_file_permissions - File.stubs(:umask).returns 022 - fa = formula_auditor "foo", <<-EOS.undent - class Foo < Formula - url "http://example.com/foo-1.0.tgz" - end - EOS - - path = fa.formula.path - path.chmod 0400 - - fa.audit_file - assert_equal ["Incorrect file permissions (400): chmod 644 #{path}"], - fa.problems - end - - def test_audit_file_data_no_end - fa = formula_auditor "foo", <<-EOS.undent - class Foo < Formula - url "http://example.com/foo-1.0.tgz" - patch :DATA - end - EOS - fa.audit_file - assert_equal ["'DATA' was found, but no '__END__'"], fa.problems - end - - def test_audit_file_end_no_data - fa = formula_auditor "foo", <<-EOS.undent - class Foo < Formula - url "http://example.com/foo-1.0.tgz" - end - __END__ - a patch goes here - EOS - fa.audit_file - assert_equal ["'__END__' was found, but 'DATA' is not used"], fa.problems - end - - def test_audit_file_no_trailing_newline - fa = formula_auditor "foo", 'class Foo<Formula; url "file:///foo-1.0.tgz";end' - fa.audit_file - assert_equal ["File should end with a newline"], fa.problems - end - - def test_audit_file_not_strict_no_issue - fa = formula_auditor "foo", <<-EOS.undent - class Foo < Formula - url "http://example.com/foo-1.0.tgz" - homepage "http://example.com" - end - EOS - fa.audit_file - assert_equal [], fa.problems - end - - def test_audit_file_strict_ordering_issue - fa = formula_auditor "foo", <<-EOS.undent, strict: true - class Foo < Formula - url "http://example.com/foo-1.0.tgz" - homepage "http://example.com" - end - EOS - fa.audit_file - assert_equal ["`homepage` (line 3) should be put before `url` (line 2)"], - fa.problems - end - - def test_audit_file_strict_resource_placement - fa = formula_auditor "foo", <<-EOS.undent, strict: true - class Foo < Formula - url "https://example.com/foo-1.0.tgz" - - resource "foo2" do - url "https://example.com/foo-2.0.tgz" - end - - depends_on "openssl" - end - EOS - fa.audit_file - assert_equal ["`depends_on` (line 8) should be put before `resource` (line 4)"], - fa.problems - end - - def test_audit_file_strict_plist_placement - fa = formula_auditor "foo", <<-EOS.undent, strict: true - class Foo < Formula - url "https://example.com/foo-1.0.tgz" - - test do - assert_match "Dogs are terrific", shell_output("./dogs") - end - - def plist - end - end - EOS - fa.audit_file - assert_equal ["`plist block` (line 8) should be put before `test block` (line 4)"], - fa.problems - end - - def test_audit_file_strict_url_outside_of_stable_block - fa = formula_auditor "foo", <<-EOS.undent, strict: true - class Foo < Formula - url "http://example.com/foo-1.0.tgz" - stable do - # stuff - end - end - EOS - fa.audit_file - assert_equal ["`url` should be put inside `stable block`"], fa.problems - end - - def test_audit_file_strict_head_and_head_do - fa = formula_auditor "foo", <<-EOS.undent, strict: true - class Foo < Formula - head "http://example.com/foo.git" - head do - # stuff - end - end - EOS - fa.audit_file - assert_equal ["Should not have both `head` and `head do`"], fa.problems - end - - def test_audit_file_strict_bottle_and_bottle_do - fa = formula_auditor "foo", <<-EOS.undent, strict: true - class Foo < Formula - url "http://example.com/foo-1.0.tgz" - bottle do - # bottles go here - end - bottle :unneeded - end - EOS - fa.audit_file - assert_equal ["Should not have `bottle :unneeded/:disable` and `bottle do`"], - fa.problems - end - - def test_audit_class_no_test - fa = formula_auditor "foo", <<-EOS.undent - class Foo < Formula - url "http://example.com/foo-1.0.tgz" - end - EOS - fa.audit_class - assert_equal [], fa.problems - - fa = formula_auditor "foo", <<-EOS.undent, strict: true - class Foo < Formula - url "http://example.com/foo-1.0.tgz" - end - EOS - fa.audit_class - assert_equal ["A `test do` test block should be added"], fa.problems - end - - def test_audit_class_github_gist_formula - needs_compat - require "compat/formula_specialties" - - ENV.delete("HOMEBREW_DEVELOPER") - fa = shutup do - formula_auditor "foo", <<-EOS.undent - class Foo < GithubGistFormula - url "http://example.com/foo-1.0.tgz" - end - EOS - end - fa.audit_class - assert_equal ["GithubGistFormula is deprecated, use Formula instead"], - fa.problems - end - - def test_audit_class_script_file_formula - needs_compat - require "compat/formula_specialties" - - ENV.delete("HOMEBREW_DEVELOPER") - fa = formula_auditor "foo", <<-EOS.undent - class Foo < ScriptFileFormula - url "http://example.com/foo-1.0.tgz" - end - EOS - fa.audit_class - assert_equal ["ScriptFileFormula is deprecated, use Formula instead"], - fa.problems - end - - def test_audit_class_aws_formula - needs_compat - require "compat/formula_specialties" - - ENV.delete("HOMEBREW_DEVELOPER") - fa = formula_auditor "foo", <<-EOS.undent - class Foo < AmazonWebServicesFormula - url "http://example.com/foo-1.0.tgz" - end - EOS - fa.audit_class - assert_equal ["AmazonWebServicesFormula is deprecated, use Formula instead"], - fa.problems - end - - def test_audit_line_pkgshare - fa = formula_auditor "foo", <<-EOS.undent, strict: true - class Foo < Formula - url "http://example.com/foo-1.0.tgz" - end - EOS - fa.audit_line 'ohai "#{share}/foo"', 3 - assert_equal "Use \#{pkgshare} instead of \#{share}/foo", fa.problems.shift - - fa.audit_line 'ohai "#{share}/foo/bar"', 3 - assert_equal "Use \#{pkgshare} instead of \#{share}/foo", fa.problems.shift - - fa.audit_line 'ohai share/"foo"', 3 - assert_equal 'Use pkgshare instead of (share/"foo")', fa.problems.shift - - fa.audit_line 'ohai share/"foo/bar"', 3 - assert_equal 'Use pkgshare instead of (share/"foo")', fa.problems.shift - - fa.audit_line 'ohai "#{share}/foo-bar"', 3 - assert_equal [], fa.problems - fa.audit_line 'ohai share/"foo-bar"', 3 - assert_equal [], fa.problems - fa.audit_line 'ohai share/"bar"', 3 - assert_equal [], fa.problems - end - - # Regression test for https://github.com/Homebrew/legacy-homebrew/pull/48744 - # Formulae with "++" in their name would break various audit regexps: - # Error: nested *?+ in regexp: /^libxml++3\s/ - def test_audit_plus_plus_name - fa = formula_auditor "foolibc++", <<-EOS.undent, strict: true - class Foolibcxx < Formula - desc "foolibc++ is a test" - url "http://example.com/foo-1.0.tgz" - end - EOS - - fa.audit_desc - assert_equal "Description shouldn't include the formula name", - fa.problems.shift - - fa.audit_line 'ohai "#{share}/foolibc++"', 3 - assert_equal "Use \#{pkgshare} instead of \#{share}/foolibc++", fa.problems.shift - - fa.audit_line 'ohai share/"foolibc++"', 3 - assert_equal 'Use pkgshare instead of (share/"foolibc++")', fa.problems.shift - end - - def test_audit_line_space_in_class_inheritance - fa = formula_auditor "foo", "class Foo<Formula; url '/foo-1.0.tgz'; end" - fa.audit_line "class Foo<Formula", 1 - assert_equal "Use a space in class inheritance: class Foo < Formula", - fa.problems.shift - end - - def test_audit_line_default_template - fa = formula_auditor "foo", "class Foo < Formula; url '/foo-1.0.tgz'; end" - - fa.audit_line '# system "cmake", ".", *std_cmake_args', 3 - assert_equal "Commented cmake call found", - fa.problems.shift - - fa.audit_line "# PLEASE REMOVE", 3 - assert_equal "Please remove default template comments", - fa.problems.shift - end - - def test_audit_github_repository_no_api - fa = formula_auditor "foo", <<-EOS.undent, strict: true, online: true - class Foo < Formula - homepage "https://github.com/example/example" - url "http://example.com/foo-1.0.tgz" - end - EOS - - ENV["HOMEBREW_NO_GITHUB_API"] = "1" - - fa.audit_github_repository - assert_equal [], fa.problems - end - - def test_audit_caveats - fa = formula_auditor "foo", <<-EOS.undent - class Foo < Formula - homepage "http://example.com/foo" - url "http://example.com/foo-1.0.tgz" - - def caveats - "setuid" - end - end - EOS - - fa.audit_caveats - assert_equal ["Don't recommend setuid in the caveats, suggest sudo instead."], - fa.problems - end - - def test_audit_desc - formula_descriptions = [ - { name: "foo", desc: nil, - problem: "Formula should have a desc" }, - { name: "bar", desc: "bar" * 30, - problem: "Description is too long" }, - { name: "baz", desc: "Baz commandline tool", - problem: "Description should use \"command-line\"" }, - { name: "qux", desc: "A tool called Qux", - problem: "Description shouldn't start with an indefinite article" }, - ] - - formula_descriptions.each do |formula| - content = <<-EOS.undent - class #{Formulary.class_s(formula[:name])} < Formula - url "http://example.com/#{formula[:name]}-1.0.tgz" - desc "#{formula[:desc]}" - end - EOS - - fa = formula_auditor formula[:name], content, strict: true - fa.audit_desc - assert_match formula[:problem], fa.problems.first - end - end - - def test_audit_homepage - fa = formula_auditor "foo", <<-EOS.undent, online: true - class Foo < Formula - homepage "ftp://example.com/foo" - url "http://example.com/foo-1.0.tgz" - end - EOS - - fa.audit_homepage - assert_equal ["The homepage should start with http or https (URL is #{fa.formula.homepage})."], - fa.problems - - formula_homepages = { - "bar" => "http://www.freedesktop.org/wiki/bar", - "baz" => "http://www.freedesktop.org/wiki/Software/baz", - "qux" => "https://code.google.com/p/qux", - "quux" => "http://github.com/quux", - "corge" => "http://savannah.nongnu.org/corge", - "grault" => "http://grault.github.io/", - "garply" => "http://www.gnome.org/garply", - "sf1" => "http://foo.sourceforge.net/", - "sf2" => "http://foo.sourceforge.net", - "sf3" => "http://foo.sf.net/", - "sf4" => "http://foo.sourceforge.io/", - "waldo" => "http://www.gnu.org/waldo", - } - - formula_homepages.each do |name, homepage| - fa = formula_auditor name, <<-EOS.undent - class #{Formulary.class_s(name)} < Formula - homepage "#{homepage}" - url "http://example.com/#{name}-1.0.tgz" - end - EOS - - fa.audit_homepage - if homepage =~ %r{http:\/\/www\.freedesktop\.org} - if homepage =~ /Software/ - assert_match "#{homepage} should be styled " \ - "`https://wiki.freedesktop.org/www/Software/project_name`", - fa.problems.first - else - assert_match "#{homepage} should be styled " \ - "`https://wiki.freedesktop.org/project_name`", - fa.problems.first - end - elsif homepage =~ %r{https:\/\/code\.google\.com} - assert_match "#{homepage} should end with a slash", fa.problems.first - elsif homepage =~ /foo\.(sf|sourceforge)\.net/ - assert_match "#{homepage} should be `https://foo.sourceforge.io/`", fa.problems.first - else - assert_match "Please use https:// for #{homepage}", fa.problems.first - end - end - end - - def test_audit_without_homepage - fa = formula_auditor "foo", <<-EOS.undent, online: true - class Foo < Formula - url "http://example.com/foo-1.0.tgz" - end - EOS - - fa.audit_homepage - assert_match "Formula should have a homepage.", fa.problems.first - end - - def test_audit_xcodebuild_suggests_symroot - fa = formula_auditor "foo", <<-EOS.undent - class Foo < Formula - url "http://example.com/foo-1.0.tgz" - homepage "http://example.com" - - def install - xcodebuild "-project", "meow.xcodeproject" - end - end - EOS - - fa.audit_text - - assert_match 'xcodebuild should be passed an explicit "SYMROOT"', fa.problems.first - end - - def test_audit_bare_xcodebuild_suggests_symroot_also - fa = formula_auditor "foo", <<-EOS.undent - class Foo < Formula - url "http://example.com/foo-1.0.tgz" - homepage "http://example.com" - - def install - xcodebuild - end - end - EOS - - fa.audit_text - - assert_match 'xcodebuild should be passed an explicit "SYMROOT"', fa.problems.first - end -end
true
Other
Homebrew
brew
ebe4042b2f9b7b66e1c2ee9082de002795ea0b81.json
Convert FormulaAuditor test to spec.
Library/Homebrew/test/dev-cmd/audit_spec.rb
@@ -59,3 +59,501 @@ class #{Formulary.class_s(name)} < Formula expect(ft.without_patch).to eq("class End < Formula\n \nend") end end + +describe FormulaAuditor do + def formula_auditor(name, text, options = {}) + path = Pathname.new "#{dir}/#{name}.rb" + path.open("w") do |f| + f.write text + end + + described_class.new(Formulary.factory(path), options) + end + + let(:dir) { @dir = Pathname.new(Dir.mktmpdir) } + + after(:each) do + dir.rmtree unless @dir.nil? + end + + describe "#problems" do + it "is empty by default" do + fa = formula_auditor "foo", <<-EOS.undent + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + end + EOS + + expect(fa.problems).to be_empty + end + end + + describe "#audit_file" do + specify "file permissions" do + allow(File).to receive(:umask).and_return(022) + + fa = formula_auditor "foo", <<-EOS.undent + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + end + EOS + + path = fa.formula.path + path.chmod 0400 + + fa.audit_file + expect(fa.problems) + .to eq(["Incorrect file permissions (400): chmod 644 #{path}"]) + end + + specify "DATA but no __END__" do + fa = formula_auditor "foo", <<-EOS.undent + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + patch :DATA + end + EOS + + fa.audit_file + expect(fa.problems).to eq(["'DATA' was found, but no '__END__'"]) + end + + specify "__END__ but no DATA" do + fa = formula_auditor "foo", <<-EOS.undent + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + end + __END__ + a patch goes here + EOS + + fa.audit_file + expect(fa.problems).to eq(["'__END__' was found, but 'DATA' is not used"]) + end + + specify "no trailing newline" do + fa = formula_auditor "foo", 'class Foo<Formula; url "file:///foo-1.0.tgz";end' + + fa.audit_file + expect(fa.problems).to eq(["File should end with a newline"]) + end + + specify "no issue" do + fa = formula_auditor "foo", <<-EOS.undent + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + homepage "http://example.com" + end + EOS + + fa.audit_file + expect(fa.problems).to eq([]) + end + + specify "strict: ordering issue" do + fa = formula_auditor "foo", <<-EOS.undent, strict: true + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + homepage "http://example.com" + end + EOS + + fa.audit_file + expect(fa.problems) + .to eq(["`homepage` (line 3) should be put before `url` (line 2)"]) + end + + specify "strict: resource placement" do + fa = formula_auditor "foo", <<-EOS.undent, strict: true + class Foo < Formula + url "https://example.com/foo-1.0.tgz" + + resource "foo2" do + url "https://example.com/foo-2.0.tgz" + end + + depends_on "openssl" + end + EOS + + fa.audit_file + expect(fa.problems) + .to eq(["`depends_on` (line 8) should be put before `resource` (line 4)"]) + end + + specify "strict: plist placement" do + fa = formula_auditor "foo", <<-EOS.undent, strict: true + class Foo < Formula + url "https://example.com/foo-1.0.tgz" + + test do + expect(shell_output("./dogs")).to match("Dogs are terrific") + end + + def plist + end + end + EOS + + fa.audit_file + expect(fa.problems) + .to eq(["`plist block` (line 8) should be put before `test block` (line 4)"]) + end + + specify "strict: url outside of stable block" do + fa = formula_auditor "foo", <<-EOS.undent, strict: true + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + stable do + # stuff + end + end + EOS + + fa.audit_file + expect(fa.problems).to eq(["`url` should be put inside `stable block`"]) + end + + specify "strict: head and head do" do + fa = formula_auditor "foo", <<-EOS.undent, strict: true + class Foo < Formula + head "http://example.com/foo.git" + head do + # stuff + end + end + EOS + + fa.audit_file + expect(fa.problems).to eq(["Should not have both `head` and `head do`"]) + end + + specify "strict: bottle and bottle do" do + fa = formula_auditor "foo", <<-EOS.undent, strict: true + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + bottle do + # bottles go here + end + bottle :unneeded + end + EOS + + fa.audit_file + expect(fa.problems) + .to eq(["Should not have `bottle :unneeded/:disable` and `bottle do`"]) + end + end + + describe "#audit_class" do + specify "missing test" do + fa = formula_auditor "foo", <<-EOS.undent + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + end + EOS + + fa.audit_class + expect(fa.problems).to eq([]) + + fa = formula_auditor "foo", <<-EOS.undent, strict: true + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + end + EOS + + fa.audit_class + expect(fa.problems).to eq(["A `test do` test block should be added"]) + end + + specify "GithubGistFormula", :needs_compat do + ENV.delete("HOMEBREW_DEVELOPER") + + fa = shutup do + formula_auditor "foo", <<-EOS.undent + class Foo < GithubGistFormula + url "http://example.com/foo-1.0.tgz" + end + EOS + end + + fa.audit_class + expect(fa.problems) + .to eq(["GithubGistFormula is deprecated, use Formula instead"]) + end + + specify "ScriptFileFormula", :needs_compat do + ENV.delete("HOMEBREW_DEVELOPER") + + fa = formula_auditor "foo", <<-EOS.undent + class Foo < ScriptFileFormula + url "http://example.com/foo-1.0.tgz" + end + EOS + + fa.audit_class + expect(fa.problems) + .to eq(["ScriptFileFormula is deprecated, use Formula instead"]) + end + + specify "AmazonWebServicesFormula", :needs_compat do + ENV.delete("HOMEBREW_DEVELOPER") + + fa = formula_auditor "foo", <<-EOS.undent + class Foo < AmazonWebServicesFormula + url "http://example.com/foo-1.0.tgz" + end + EOS + + fa.audit_class + expect(fa.problems) + .to eq(["AmazonWebServicesFormula is deprecated, use Formula instead"]) + end + end + + describe "#audit_line" do + specify "pkgshare" do + fa = formula_auditor "foo", <<-EOS.undent, strict: true + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + end + EOS + + fa.audit_line 'ohai "#{share}/foo"', 3 + expect(fa.problems.shift).to eq("Use \#{pkgshare} instead of \#{share}/foo") + + fa.audit_line 'ohai "#{share}/foo/bar"', 3 + expect(fa.problems.shift).to eq("Use \#{pkgshare} instead of \#{share}/foo") + + fa.audit_line 'ohai share/"foo"', 3 + expect(fa.problems.shift).to eq('Use pkgshare instead of (share/"foo")') + + fa.audit_line 'ohai share/"foo/bar"', 3 + expect(fa.problems.shift).to eq('Use pkgshare instead of (share/"foo")') + + fa.audit_line 'ohai "#{share}/foo-bar"', 3 + expect(fa.problems).to eq([]) + + fa.audit_line 'ohai share/"foo-bar"', 3 + expect(fa.problems).to eq([]) + + fa.audit_line 'ohai share/"bar"', 3 + expect(fa.problems).to eq([]) + end + + # Regression test for https://github.com/Homebrew/legacy-homebrew/pull/48744 + # Formulae with "++" in their name would break various audit regexps: + # Error: nested *?+ in regexp: /^libxml++3\s/ + specify "++ in name" do + fa = formula_auditor "foolibc++", <<-EOS.undent, strict: true + class Foolibcxx < Formula + desc "foolibc++ is a test" + url "http://example.com/foo-1.0.tgz" + end + EOS + + fa.audit_desc + expect(fa.problems.shift) + .to eq("Description shouldn't include the formula name") + + fa.audit_line 'ohai "#{share}/foolibc++"', 3 + expect(fa.problems.shift) + .to eq("Use \#{pkgshare} instead of \#{share}/foolibc++") + + fa.audit_line 'ohai share/"foolibc++"', 3 + expect(fa.problems.shift) + .to eq('Use pkgshare instead of (share/"foolibc++")') + end + + specify "no space in class inheritance" do + fa = formula_auditor "foo", <<-EOS.undent + class Foo<Formula + url '/foo-1.0.tgz' + end + EOS + + fa.audit_line "class Foo<Formula", 1 + expect(fa.problems.shift) + .to eq("Use a space in class inheritance: class Foo < Formula") + end + + specify "default template" do + fa = formula_auditor "foo", "class Foo < Formula; url '/foo-1.0.tgz'; end" + + fa.audit_line '# system "cmake", ".", *std_cmake_args', 3 + expect(fa.problems.shift).to eq("Commented cmake call found") + + fa.audit_line "# PLEASE REMOVE", 3 + expect(fa.problems.shift).to eq("Please remove default template comments") + end + end + + describe "#audit_github_repository" do + specify "#audit_github_repository when HOMEBREW_NO_GITHUB_API is set" do + ENV["HOMEBREW_NO_GITHUB_API"] = "1" + + fa = formula_auditor "foo", <<-EOS.undent, strict: true, online: true + class Foo < Formula + homepage "https://github.com/example/example" + url "http://example.com/foo-1.0.tgz" + end + EOS + + fa.audit_github_repository + expect(fa.problems).to eq([]) + end + end + + specify "#audit_caveats" do + fa = formula_auditor "foo", <<-EOS.undent + class Foo < Formula + homepage "http://example.com/foo" + url "http://example.com/foo-1.0.tgz" + + def caveats + "setuid" + end + end + EOS + + fa.audit_caveats + expect(fa.problems) + .to eq(["Don't recommend setuid in the caveats, suggest sudo instead."]) + end + + specify "#audit_desc" do + formula_descriptions = [ + { name: "foo", desc: nil, + problem: "Formula should have a desc" }, + { name: "bar", desc: "bar" * 30, + problem: "Description is too long" }, + { name: "baz", desc: "Baz commandline tool", + problem: "Description should use \"command-line\"" }, + { name: "qux", desc: "A tool called Qux", + problem: "Description shouldn't start with an indefinite article" }, + ] + + formula_descriptions.each do |formula| + content = <<-EOS.undent + class #{Formulary.class_s(formula[:name])} < Formula + url "http://example.com/#{formula[:name]}-1.0.tgz" + desc "#{formula[:desc]}" + end + EOS + + fa = formula_auditor formula[:name], content, strict: true + fa.audit_desc + expect(fa.problems.first).to match(formula[:problem]) + end + end + + describe "#audit_homepage" do + specify "homepage URLs" do + fa = formula_auditor "foo", <<-EOS.undent, online: true + class Foo < Formula + homepage "ftp://example.com/foo" + url "http://example.com/foo-1.0.tgz" + end + EOS + + fa.audit_homepage + expect(fa.problems) + .to eq(["The homepage should start with http or https (URL is #{fa.formula.homepage})."]) + + formula_homepages = { + "bar" => "http://www.freedesktop.org/wiki/bar", + "baz" => "http://www.freedesktop.org/wiki/Software/baz", + "qux" => "https://code.google.com/p/qux", + "quux" => "http://github.com/quux", + "corge" => "http://savannah.nongnu.org/corge", + "grault" => "http://grault.github.io/", + "garply" => "http://www.gnome.org/garply", + "sf1" => "http://foo.sourceforge.net/", + "sf2" => "http://foo.sourceforge.net", + "sf3" => "http://foo.sf.net/", + "sf4" => "http://foo.sourceforge.io/", + "waldo" => "http://www.gnu.org/waldo", + } + + formula_homepages.each do |name, homepage| + fa = formula_auditor name, <<-EOS.undent + class #{Formulary.class_s(name)} < Formula + homepage "#{homepage}" + url "http://example.com/#{name}-1.0.tgz" + end + EOS + + fa.audit_homepage + if homepage =~ %r{http:\/\/www\.freedesktop\.org} + if homepage =~ /Software/ + expect(fa.problems.first).to match( + "#{homepage} should be styled " \ + "`https://wiki.freedesktop.org/www/Software/project_name`", + ) + else + expect(fa.problems.first).to match( + "#{homepage} should be styled " \ + "`https://wiki.freedesktop.org/project_name`", + ) + end + elsif homepage =~ %r{https:\/\/code\.google\.com} + expect(fa.problems.first) + .to match("#{homepage} should end with a slash") + elsif homepage =~ /foo\.(sf|sourceforge)\.net/ + expect(fa.problems.first) + .to match("#{homepage} should be `https://foo.sourceforge.io/`") + else + expect(fa.problems.first) + .to match("Please use https:// for #{homepage}") + end + end + end + + specify "missing homepage" do + fa = formula_auditor "foo", <<-EOS.undent, online: true + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + end + EOS + + fa.audit_homepage + expect(fa.problems.first).to match("Formula should have a homepage.") + end + end + + describe "#audit_text" do + specify "xcodebuild suggests symroot" do + fa = formula_auditor "foo", <<-EOS.undent + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + homepage "http://example.com" + + def install + xcodebuild "-project", "meow.xcodeproject" + end + end + EOS + + fa.audit_text + expect(fa.problems.first) + .to match('xcodebuild should be passed an explicit "SYMROOT"') + end + + specify "bare xcodebuild also suggests symroot" do + fa = formula_auditor "foo", <<-EOS.undent + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + homepage "http://example.com" + + def install + xcodebuild + end + end + EOS + + fa.audit_text + expect(fa.problems.first) + .to match('xcodebuild should be passed an explicit "SYMROOT"') + end + end +end
true
Other
Homebrew
brew
ebe4042b2f9b7b66e1c2ee9082de002795ea0b81.json
Convert FormulaAuditor test to spec.
Library/Homebrew/test/spec_helper.rb
@@ -36,6 +36,10 @@ config.include(Test::Helper::Fixtures) config.include(Test::Helper::Formula) + config.before(:each, :needs_compat) do + skip "Requires compatibility layer." if ENV["HOMEBREW_NO_COMPAT"] + end + config.before(:each, :needs_official_cmd_taps) do skip "Needs official command Taps." unless ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"] end
true
Other
Homebrew
brew
8676960d09fda58ea36a34ce202ce30431474ac6.json
Convert FormulaText test to spec.
Library/Homebrew/test/audit_test.rb
@@ -4,55 +4,6 @@ require "formulary" require "dev-cmd/audit" -class FormulaTextTests < Homebrew::TestCase - def setup - super - @dir = mktmpdir - end - - def formula_text(name, body = nil, options = {}) - path = Pathname.new "#{@dir}/#{name}.rb" - path.open("w") do |f| - f.write <<-EOS.undent - class #{Formulary.class_s(name)} < Formula - #{body} - end - #{options[:patch]} - EOS - end - FormulaText.new path - end - - def test_simple_valid_formula - ft = formula_text "valid", 'url "http://www.example.com/valid-1.0.tar.gz"' - - refute ft.data?, "The formula should not have DATA" - refute ft.end?, "The formula should not have __END__" - assert ft.trailing_newline?, "The formula should have a trailing newline" - - assert ft =~ /\burl\b/, "The formula should match 'url'" - assert_nil ft.line_number(/desc/), "The formula should not match 'desc'" - assert_equal 2, ft.line_number(/\burl\b/) - assert ft.include?("Valid"), "The formula should include \"Valid\"" - end - - def test_trailing_newline - ft = formula_text "newline" - assert ft.trailing_newline?, "The formula must have a trailing newline" - end - - def test_has_data - ft = formula_text "data", "patch :DATA" - assert ft.data?, "The formula must have DATA" - end - - def test_has_end - ft = formula_text "end", "", patch: "__END__\na patch here" - assert ft.end?, "The formula must have __END__" - assert_equal "class End < Formula\n \nend", ft.without_patch - end -end - class FormulaAuditorTests < Homebrew::TestCase def setup super
true
Other
Homebrew
brew
8676960d09fda58ea36a34ce202ce30431474ac6.json
Convert FormulaText test to spec.
Library/Homebrew/test/dev-cmd/audit_spec.rb
@@ -0,0 +1,61 @@ +require "dev-cmd/audit" +require "formulary" + +RSpec::Matchers.alias_matcher :have_data, :be_data +RSpec::Matchers.alias_matcher :have_end, :be_end +RSpec::Matchers.alias_matcher :have_trailing_newline, :be_trailing_newline + +describe FormulaText do + let(:dir) { @dir = Pathname.new(Dir.mktmpdir) } + + after(:each) do + dir.rmtree unless @dir.nil? + end + + def formula_text(name, body = nil, options = {}) + path = dir/"#{name}.rb" + + path.write <<-EOS.undent + class #{Formulary.class_s(name)} < Formula + #{body} + end + #{options[:patch]} + EOS + + described_class.new(path) + end + + specify "simple valid Formula" do + ft = formula_text "valid", <<-EOS.undent + url "http://www.example.com/valid-1.0.tar.gz" + EOS + + expect(ft).not_to have_data + expect(ft).not_to have_end + expect(ft).to have_trailing_newline + + expect(ft =~ /\burl\b/).to be_truthy + expect(ft.line_number(/desc/)).to be nil + expect(ft.line_number(/\burl\b/)).to eq(2) + expect(ft).to include("Valid") + end + + specify "#trailing_newline?" do + ft = formula_text "newline" + expect(ft).to have_trailing_newline + end + + specify "#data?" do + ft = formula_text "data", <<-EOS.undent + patch :DATA + EOS + + expect(ft).to have_data + end + + specify "#end?" do + ft = formula_text "end", "", patch: "__END__\na patch here" + expect(ft).to have_end + expect(ft.without_patch).to eq("class End < Formula\n \nend") + end +end
true
Other
Homebrew
brew
3dcbb84fb5fd1601e669ea15c9ddb1056c839325.json
Convert Tap test to spec.
Library/Homebrew/test/tap_spec.rb
@@ -0,0 +1,346 @@ +RSpec::Matchers.alias_matcher :have_formula_file, :be_formula_file +RSpec::Matchers.alias_matcher :have_custom_remote, :be_custom_remote + +describe Tap do + include FileUtils + + subject { Tap.new("Homebrew", "foo") } + let(:path) { Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" } + let(:formula_file) { path/"Formula/foo.rb" } + let(:alias_file) { path/"Aliases/bar" } + let(:cmd_file) { path/"cmd/brew-tap-cmd.rb" } + let(:manpage_file) { path/"manpages/brew-tap-cmd.1" } + let(:bash_completion_file) { path/"completions/bash/brew-tap-cmd" } + let(:zsh_completion_file) { path/"completions/zsh/_brew-tap-cmd" } + let(:fish_completion_file) { path/"completions/fish/brew-tap-cmd.fish" } + + before(:each) do + path.mkpath + end + + def setup_tap_files + formula_file.write <<-EOS.undent + class Foo < Formula + url "https://example.com/foo-1.0.tar.gz" + end + EOS + + alias_file.parent.mkpath + ln_s formula_file, alias_file + + (path/"formula_renames.json").write <<-EOS.undent + { "oldname": "foo" } + EOS + + (path/"tap_migrations.json").write <<-EOS.undent + { "removed-formula": "homebrew/foo" } + EOS + + [ + cmd_file, + manpage_file, + bash_completion_file, + zsh_completion_file, + fish_completion_file, + ].each do |f| + f.parent.mkpath + touch f + end + + chmod 0755, cmd_file + end + + def setup_git_repo + path.cd do + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" + system "git", "add", "--all" + system "git", "commit", "-m", "init" + end + end + end + + specify "::fetch" do + begin + expect(described_class.fetch("Homebrew", "homebrew")).to be_kind_of(CoreTap) + tap = described_class.fetch("Homebrew", "foo") + expect(tap).to be_kind_of(Tap) + expect(tap.name).to eq("homebrew/foo") + + expect { + described_class.fetch("foo") + }.to raise_error(/Invalid tap name/) + + expect { + described_class.fetch("homebrew/homebrew/bar") + }.to raise_error(/Invalid tap name/) + + expect { + described_class.fetch("homebrew", "homebrew/baz") + }.to raise_error(/Invalid tap name/) + ensure + described_class.clear_cache + end + end + + specify "#names" do + expect(described_class.names.sort).to eq(["homebrew/core", "homebrew/foo"]) + end + + specify "attributes" do + expect(subject.user).to eq("Homebrew") + expect(subject.repo).to eq("foo") + expect(subject.name).to eq("homebrew/foo") + expect(subject.path).to eq(path) + expect(subject).to be_installed + expect(subject).to be_official + expect(subject).not_to be_a_core_tap + end + + specify "#issues_url" do + begin + t = described_class.new("someone", "foo") + path = Tap::TAP_DIRECTORY/"someone/homebrew-foo" + path.mkpath + cd path do + shutup { system "git", "init" } + system "git", "remote", "add", "origin", + "https://github.com/someone/homebrew-foo" + end + expect(t.issues_url).to eq("https://github.com/someone/homebrew-foo/issues") + expect(subject.issues_url).to eq("https://github.com/Homebrew/homebrew-foo/issues") + + (Tap::TAP_DIRECTORY/"someone/homebrew-no-git").mkpath + expect(described_class.new("someone", "no-git").issues_url).to be nil + ensure + path.parent.rmtree + end + end + + specify "files" do + setup_tap_files + + expect(subject.formula_files).to eq([formula_file]) + expect(subject.formula_names).to eq(["homebrew/foo/foo"]) + expect(subject.alias_files).to eq([alias_file]) + expect(subject.aliases).to eq(["homebrew/foo/bar"]) + expect(subject.alias_table).to eq("homebrew/foo/bar" => "homebrew/foo/foo") + expect(subject.alias_reverse_table).to eq("homebrew/foo/foo" => ["homebrew/foo/bar"]) + expect(subject.formula_renames).to eq("oldname" => "foo") + expect(subject.tap_migrations).to eq("removed-formula" => "homebrew/foo") + expect(subject.command_files).to eq([cmd_file]) + expect(subject.to_hash).to be_kind_of(Hash) + expect(subject).to have_formula_file(formula_file) + expect(subject).to have_formula_file("Formula/foo.rb") + expect(subject).not_to have_formula_file("bar.rb") + expect(subject).not_to have_formula_file("Formula/baz.sh") + end + + describe "#remote" do + it "returns the remote URL" do + setup_git_repo + + expect(subject.remote).to eq("https://github.com/Homebrew/homebrew-foo") + expect { described_class.new("Homebrew", "bar").remote }.to raise_error(TapUnavailableError) + expect(subject).not_to have_custom_remote + + services_tap = described_class.new("Homebrew", "services") + services_tap.path.mkpath + services_tap.path.cd do + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-services" + end + end + expect(services_tap).not_to be_private + end + + it "returns nil if the Tap is not a Git repo" do + expect(subject.remote).to be nil + end + + it "returns nil if Git is not available" do + setup_git_repo + allow(Utils).to receive(:git_available?).and_return(false) + expect(subject.remote).to be nil + end + end + + specify "Git variant" do + touch path/"README" + setup_git_repo + + expect(subject.git_head).to eq("0453e16c8e3fac73104da50927a86221ca0740c2") + expect(subject.git_short_head).to eq("0453") + expect(subject.git_last_commit).to match(/\A\d+ .+ ago\Z/) + expect(subject.git_last_commit_date).to eq("2017-01-22") + end + + specify "#private?" do + skip "HOMEBREW_GITHUB_API_TOKEN is required" unless GitHub.api_credentials + expect(subject).to be_private + end + + describe "#install" do + it "raises an error when the Tap is already tapped" do + setup_git_repo + already_tapped_tap = described_class.new("Homebrew", "foo") + expect(already_tapped_tap).to be_installed + expect { already_tapped_tap.install }.to raise_error(TapAlreadyTappedError) + end + + it "raises an error when the Tap is already tapped with the right remote" do + setup_git_repo + already_tapped_tap = described_class.new("Homebrew", "foo") + expect(already_tapped_tap).to be_installed + right_remote = subject.remote + expect { already_tapped_tap.install clone_target: right_remote }.to raise_error(TapAlreadyTappedError) + end + + it "raises an error when the remote doesn't match" do + setup_git_repo + already_tapped_tap = described_class.new("Homebrew", "foo") + touch subject.path/".git/shallow" + expect(already_tapped_tap).to be_installed + wrong_remote = "#{subject.remote}-oops" + expect { already_tapped_tap.install clone_target: wrong_remote, full_clone: true }.to raise_error(TapRemoteMismatchError) + end + + it "raises an error when the Tap is already unshallow" do + setup_git_repo + already_tapped_tap = described_class.new("Homebrew", "foo") + expect { already_tapped_tap.install full_clone: true }.to raise_error(TapAlreadyUnshallowError) + end + + specify "Git error" do + tap = described_class.new("user", "repo") + + expect { + shutup { tap.install clone_target: "file:///not/existed/remote/url" } + }.to raise_error(ErrorDuringExecution) + + expect(tap).not_to be_installed + expect(Tap::TAP_DIRECTORY/"user").not_to exist + end + end + + describe "#uninstall" do + it "raises an error if the Tap is not available" do + tap = described_class.new("Homebrew", "bar") + expect { tap.uninstall }.to raise_error(TapUnavailableError) + end + end + + specify "#install and #uninstall" do + begin + setup_tap_files + setup_git_repo + + tap = Tap.new("Homebrew", "bar") + shutup do + tap.install clone_target: subject.path/".git" + end + expect(tap).to be_installed + expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").to be_a_file + expect(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").to be_a_file + expect(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").to be_a_file + expect(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").to be_a_file + shutup do + tap.uninstall + end + expect(tap).not_to be_installed + expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").not_to exist + expect(HOMEBREW_PREFIX/"share/man/man1").not_to exist + expect(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").not_to exist + expect(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").not_to exist + expect(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").not_to exist + ensure + (HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist? + (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist? + end + end + + specify "#link_completions_and_manpages" do + begin + setup_tap_files + setup_git_repo + tap = Tap.new("Homebrew", "baz") + shutup { tap.install clone_target: subject.path/".git" } + (HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete + (HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").delete + (HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").delete + (HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").delete + shutup { tap.link_completions_and_manpages } + expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").to be_a_file + expect(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").to be_a_file + expect(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").to be_a_file + expect(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").to be_a_file + shutup { tap.uninstall } + ensure + (HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist? + (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist? + end + end + + specify "#pin and #unpin" do + expect(subject).not_to be_pinned + expect { subject.unpin }.to raise_error(TapPinStatusError) + subject.pin + expect(subject).to be_pinned + expect { subject.pin }.to raise_error(TapPinStatusError) + subject.unpin + expect(subject).not_to be_pinned + end + + specify "#config" do + setup_git_repo + + expect(subject.config["foo"]).to be nil + subject.config["foo"] = "bar" + expect(subject.config["foo"]).to eq("bar") + subject.config["foo"] = nil + expect(subject.config["foo"]).to be nil + end +end + +describe CoreTap do + include FileUtils + + specify "attributes" do + expect(subject.user).to eq("Homebrew") + expect(subject.repo).to eq("core") + expect(subject.name).to eq("homebrew/core") + expect(subject.command_files).to eq([]) + expect(subject).to be_installed + expect(subject).not_to be_pinned + expect(subject).to be_official + expect(subject).to be_a_core_tap + end + + specify "forbidden operations" do + expect { subject.uninstall }.to raise_error(RuntimeError) + expect { subject.pin }.to raise_error(RuntimeError) + expect { subject.unpin }.to raise_error(RuntimeError) + end + + specify "files" do + formula_file = subject.formula_dir/"foo.rb" + formula_file.write <<-EOS.undent + class Foo < Formula + url "https://example.com/foo-1.0.tar.gz" + end + EOS + + alias_file = subject.alias_dir/"bar" + alias_file.parent.mkpath + ln_s formula_file, alias_file + + expect(subject.formula_files).to eq([formula_file]) + expect(subject.formula_names).to eq(["foo"]) + expect(subject.alias_files).to eq([alias_file]) + expect(subject.aliases).to eq(["bar"]) + expect(subject.alias_table).to eq("bar" => "foo") + expect(subject.alias_reverse_table).to eq("foo" => ["bar"]) + end +end
true
Other
Homebrew
brew
3dcbb84fb5fd1601e669ea15c9ddb1056c839325.json
Convert Tap test to spec.
Library/Homebrew/test/tap_test.rb
@@ -1,319 +0,0 @@ -require "testing_env" - -class TapTest < Homebrew::TestCase - include FileUtils - - def setup - super - @path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" - @path.mkpath - @tap = Tap.new("Homebrew", "foo") - end - - def setup_tap_files - @formula_file = @path/"Formula/foo.rb" - @formula_file.write <<-EOS.undent - class Foo < Formula - url "https://example.com/foo-1.0.tar.gz" - end - EOS - @alias_file = @path/"Aliases/bar" - @alias_file.parent.mkpath - ln_s @formula_file, @alias_file - (@path/"formula_renames.json").write <<-EOS.undent - { "oldname": "foo" } - EOS - (@path/"tap_migrations.json").write <<-EOS.undent - { "removed-formula": "homebrew/foo" } - EOS - @cmd_file = @path/"cmd/brew-tap-cmd.rb" - @cmd_file.parent.mkpath - touch @cmd_file - chmod 0755, @cmd_file - @manpage_file = @path/"manpages/brew-tap-cmd.1" - @manpage_file.parent.mkpath - touch @manpage_file - @bash_completion_file = @path/"completions/bash/brew-tap-cmd" - @bash_completion_file.parent.mkpath - touch @bash_completion_file - @zsh_completion_file = @path/"completions/zsh/_brew-tap-cmd" - @zsh_completion_file.parent.mkpath - touch @zsh_completion_file - @fish_completion_file = @path/"completions/fish/brew-tap-cmd.fish" - @fish_completion_file.parent.mkpath - touch @fish_completion_file - end - - def setup_git_repo - @path.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" - system "git", "add", "--all" - system "git", "commit", "-m", "init" - end - end - end - - def test_fetch - assert_kind_of CoreTap, Tap.fetch("Homebrew", "homebrew") - tap = Tap.fetch("Homebrew", "foo") - assert_kind_of Tap, tap - assert_equal "homebrew/foo", tap.name - - assert_match "Invalid tap name", - assert_raises { Tap.fetch("foo") }.message - assert_match "Invalid tap name", - assert_raises { Tap.fetch("homebrew/homebrew/bar") }.message - assert_match "Invalid tap name", - assert_raises { Tap.fetch("homebrew", "homebrew/baz") }.message - ensure - Tap.clear_cache - end - - def test_names - assert_equal ["homebrew/core", "homebrew/foo"], Tap.names.sort - end - - def test_attributes - assert_equal "Homebrew", @tap.user - assert_equal "foo", @tap.repo - assert_equal "homebrew/foo", @tap.name - assert_equal @path, @tap.path - assert_predicate @tap, :installed? - assert_predicate @tap, :official? - refute_predicate @tap, :core_tap? - end - - def test_issues_url - t = Tap.new("someone", "foo") - path = Tap::TAP_DIRECTORY/"someone/homebrew-foo" - path.mkpath - cd path do - shutup { system "git", "init" } - system "git", "remote", "add", "origin", - "https://github.com/someone/homebrew-foo" - end - assert_equal "https://github.com/someone/homebrew-foo/issues", t.issues_url - assert_equal "https://github.com/Homebrew/homebrew-foo/issues", @tap.issues_url - - (Tap::TAP_DIRECTORY/"someone/homebrew-no-git").mkpath - assert_nil Tap.new("someone", "no-git").issues_url - ensure - path.parent.rmtree - end - - def test_files - setup_tap_files - - assert_equal [@formula_file], @tap.formula_files - assert_equal ["homebrew/foo/foo"], @tap.formula_names - assert_equal [@alias_file], @tap.alias_files - assert_equal ["homebrew/foo/bar"], @tap.aliases - assert_equal @tap.alias_table, "homebrew/foo/bar" => "homebrew/foo/foo" - assert_equal @tap.alias_reverse_table, "homebrew/foo/foo" => ["homebrew/foo/bar"] - assert_equal @tap.formula_renames, "oldname" => "foo" - assert_equal @tap.tap_migrations, "removed-formula" => "homebrew/foo" - assert_equal [@cmd_file], @tap.command_files - assert_kind_of Hash, @tap.to_hash - assert_equal true, @tap.formula_file?(@formula_file) - assert_equal true, @tap.formula_file?("Formula/foo.rb") - assert_equal false, @tap.formula_file?("bar.rb") - assert_equal false, @tap.formula_file?("Formula/baz.sh") - end - - def test_remote - setup_git_repo - - assert_equal "https://github.com/Homebrew/homebrew-foo", @tap.remote - assert_raises(TapUnavailableError) { Tap.new("Homebrew", "bar").remote } - refute_predicate @tap, :custom_remote? - - services_tap = Tap.new("Homebrew", "services") - services_tap.path.mkpath - services_tap.path.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-services" - end - end - refute_predicate services_tap, :private? - end - - def test_remote_not_git_repo - assert_nil @tap.remote - end - - def test_remote_git_not_available - setup_git_repo - Utils.stubs(:git_available?).returns(false) - assert_nil @tap.remote - end - - def test_git_variant - touch @path/"README" - setup_git_repo - - assert_equal "0453e16c8e3fac73104da50927a86221ca0740c2", @tap.git_head - assert_equal "0453", @tap.git_short_head - assert_match(/\A\d+ .+ ago\Z/, @tap.git_last_commit) - assert_equal "2017-01-22", @tap.git_last_commit_date - end - - def test_private_remote - skip "HOMEBREW_GITHUB_API_TOKEN is required" unless GitHub.api_credentials - assert_predicate @tap, :private? - end - - def test_install_tap_already_tapped_error - setup_git_repo - already_tapped_tap = Tap.new("Homebrew", "foo") - assert_equal true, already_tapped_tap.installed? - assert_raises(TapAlreadyTappedError) { already_tapped_tap.install } - end - - def test_install_tap_remote_match_already_tapped_error - setup_git_repo - already_tapped_tap = Tap.new("Homebrew", "foo") - assert_equal true, already_tapped_tap.installed? - right_remote = @tap.remote - assert_raises(TapAlreadyTappedError) { already_tapped_tap.install clone_target: right_remote } - end - - def test_install_tap_remote_mismatch_error - setup_git_repo - already_tapped_tap = Tap.new("Homebrew", "foo") - touch @tap.path/".git/shallow" - assert_equal true, already_tapped_tap.installed? - wrong_remote = "#{@tap.remote}-oops" - assert_raises(TapRemoteMismatchError) { already_tapped_tap.install clone_target: wrong_remote, full_clone: true } - end - - def test_install_tap_already_unshallow_error - setup_git_repo - already_tapped_tap = Tap.new("Homebrew", "foo") - assert_raises(TapAlreadyUnshallowError) { already_tapped_tap.install full_clone: true } - end - - def test_uninstall_tap_unavailable_error - tap = Tap.new("Homebrew", "bar") - assert_raises(TapUnavailableError) { tap.uninstall } - end - - def test_install_git_error - tap = Tap.new("user", "repo") - assert_raises(ErrorDuringExecution) do - shutup { tap.install clone_target: "file:///not/existed/remote/url" } - end - refute_predicate tap, :installed? - refute_predicate Tap::TAP_DIRECTORY/"user", :exist? - end - - def test_install_and_uninstall - setup_tap_files - setup_git_repo - - tap = Tap.new("Homebrew", "bar") - shutup { tap.install clone_target: @tap.path/".git" } - assert_predicate tap, :installed? - assert_predicate HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1", :file? - assert_predicate HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd", :file? - assert_predicate HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd", :file? - assert_predicate HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish", :file? - shutup { tap.uninstall } - refute_predicate tap, :installed? - refute_predicate HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1", :exist? - refute_predicate HOMEBREW_PREFIX/"share/man/man1", :exist? - refute_predicate HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd", :exist? - refute_predicate HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd", :exist? - refute_predicate HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish", :exist? - ensure - (HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist? - (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist? - end - - def test_link_completions_and_manpages - setup_tap_files - setup_git_repo - tap = Tap.new("Homebrew", "baz") - shutup { tap.install clone_target: @tap.path/".git" } - (HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete - (HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").delete - (HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").delete - (HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").delete - shutup { tap.link_completions_and_manpages } - assert_predicate HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1", :file? - assert_predicate HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd", :file? - assert_predicate HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd", :file? - assert_predicate HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish", :file? - shutup { tap.uninstall } - ensure - (HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist? - (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist? - end - - def test_pin_and_unpin - refute_predicate @tap, :pinned? - assert_raises(TapPinStatusError) { @tap.unpin } - @tap.pin - assert_predicate @tap, :pinned? - assert_raises(TapPinStatusError) { @tap.pin } - @tap.unpin - refute_predicate @tap, :pinned? - end - - def test_config - setup_git_repo - - assert_nil @tap.config["foo"] - @tap.config["foo"] = "bar" - assert_equal "bar", @tap.config["foo"] - @tap.config["foo"] = nil - assert_nil @tap.config["foo"] - end -end - -class CoreTapTest < Homebrew::TestCase - include FileUtils - - def setup - super - @repo = CoreTap.new - end - - def test_attributes - assert_equal "Homebrew", @repo.user - assert_equal "core", @repo.repo - assert_equal "homebrew/core", @repo.name - assert_equal [], @repo.command_files - assert_predicate @repo, :installed? - refute_predicate @repo, :pinned? - assert_predicate @repo, :official? - assert_predicate @repo, :core_tap? - end - - def test_forbidden_operations - assert_raises(RuntimeError) { @repo.uninstall } - assert_raises(RuntimeError) { @repo.pin } - assert_raises(RuntimeError) { @repo.unpin } - end - - def test_files - @formula_file = @repo.formula_dir/"foo.rb" - @formula_file.write <<-EOS.undent - class Foo < Formula - url "https://example.com/foo-1.0.tar.gz" - end - EOS - @alias_file = @repo.alias_dir/"bar" - @alias_file.parent.mkpath - ln_s @formula_file, @alias_file - - assert_equal [@formula_file], @repo.formula_files - assert_equal ["foo"], @repo.formula_names - assert_equal [@alias_file], @repo.alias_files - assert_equal ["bar"], @repo.aliases - assert_equal @repo.alias_table, "bar" => "foo" - assert_equal @repo.alias_reverse_table, "foo" => ["bar"] - end -end
true
Other
Homebrew
brew
14ae87d5c907165dcce7554edaf0c82ec89c2881.json
Add a space after the emoji for terminals Closes #2198. Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
Library/Homebrew/test/emoji_spec.rb
@@ -9,7 +9,7 @@ ENV.delete("HOMEBREW_INSTALL_BADGE") end - it "returns 🍺 by default" do + it "returns 🍺 by default" do expect(subject).to eq "🍺" end
false
Other
Homebrew
brew
ba34cbdc6256b76cd5e3bb31dc9c3fc0ec511333.json
Convert `checksum_verification` test to spec.
Library/Homebrew/test/checksum_verification_spec.rb
@@ -0,0 +1,36 @@ +require "formula" + +describe Formula do + def formula(&block) + super do + url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz" + instance_eval(&block) + end + end + + describe "#brew" do + it "does not raise an error when the checksum matches" do + expect { + shutup do + f = formula do + sha256 TESTBALL_SHA256 + end + + f.brew {} + end + }.not_to raise_error + end + + it "raises an error when the checksum doesn't match" do + expect { + shutup do + f = formula do + sha256 "dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8" + end + + f.brew {} + end + }.to raise_error(ChecksumMismatchError) + end + end +end
true
Other
Homebrew
brew
ba34cbdc6256b76cd5e3bb31dc9c3fc0ec511333.json
Convert `checksum_verification` test to spec.
Library/Homebrew/test/checksum_verification_test.rb
@@ -1,35 +0,0 @@ -require "testing_env" -require "formula" - -class ChecksumVerificationTests < Homebrew::TestCase - def assert_checksum_good - assert_nothing_raised { shutup { @_f.brew {} } } - end - - def assert_checksum_bad - assert_raises(ChecksumMismatchError) { shutup { @_f.brew {} } } - end - - def formula(&block) - super do - url "file://#{TEST_FIXTURE_DIR}/tarballs/testball-0.1.tbz" - instance_eval(&block) - end - end - - def test_good_sha256 - formula do - sha256 TESTBALL_SHA256 - end - - assert_checksum_good - end - - def test_bad_sha256 - formula do - sha256 "dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8" - end - - assert_checksum_bad - end -end
true
Other
Homebrew
brew
834824754f1837aceefe0518b7fe4023053ecfff.json
Convert `formula_validation` test to spec.
Library/Homebrew/test/formula_validation_spec.rb
@@ -0,0 +1,94 @@ +require "formula" + +describe Formula do + describe "::new" do + matcher :fail_with_invalid do |attr| + match do |actual| + expect { + begin + actual.call + rescue => e + expect(e.attr).to eq(attr) + raise e + end + }.to raise_error(FormulaValidationError) + end + + def supports_block_expectations? + true + end + end + + it "cant override the `brew` method" do + expect { + formula do + def brew; end + end + }.to raise_error(RuntimeError, /You cannot override Formula#brew/) + end + + it "validates the `name`" do + expect { + formula "name with spaces" do + url "foo" + version "1.0" + end + }.to fail_with_invalid :name + end + + it "validates the `url`" do + expect { + formula do + url "" + version "1" + end + }.to fail_with_invalid :url + end + + it "validates the `version`" do + expect { + formula do + url "foo" + version "version with spaces" + end + }.to fail_with_invalid :version + + expect { + formula do + url "foo" + version "" + end + }.to fail_with_invalid :version + + expect { + formula do + url "foo" + version nil + end + }.to fail_with_invalid :version + end + + specify "devel-only is valid" do + f = formula do + devel do + url "foo" + version "1.0" + end + end + + expect(f).to be_devel + end + + specify "head-only is valid" do + f = formula do + head "foo" + end + + expect(f).to be_head + end + + it "fails when Formula is empty" do + expect { formula {} }.to raise_error(FormulaSpecificationError) + end + end +end
true
Other
Homebrew
brew
834824754f1837aceefe0518b7fe4023053ecfff.json
Convert `formula_validation` test to spec.
Library/Homebrew/test/formula_validation_test.rb
@@ -1,75 +0,0 @@ -require "testing_env" -require "formula" - -class FormulaValidationTests < Homebrew::TestCase - def assert_invalid(attr, &block) - e = assert_raises(FormulaValidationError, &block) - assert_equal attr, e.attr - end - - def test_cant_override_brew - e = assert_raises(RuntimeError) { formula { def brew; end } } - assert_match(/You cannot override Formula#brew/, e.message) - end - - def test_validates_name - assert_invalid :name do - formula "name with spaces" do - url "foo" - version "1.0" - end - end - end - - def test_validates_url - assert_invalid :url do - formula do - url "" - version "1" - end - end - end - - def test_validates_version - assert_invalid :version do - formula do - url "foo" - version "version with spaces" - end - end - - assert_invalid :version do - formula do - url "foo" - version "" - end - end - - assert_invalid :version do - formula do - url "foo" - version nil - end - end - end - - def test_devel_only_valid - f = formula do - devel do - url "foo" - version "1.0" - end - end - - assert_predicate f, :devel? - end - - def test_head_only_valid - f = formula { head "foo" } - assert_predicate f, :head? - end - - def test_empty_formula_invalid - assert_raises(FormulaSpecificationError) { formula {} } - end -end
true
Other
Homebrew
brew
fb09867ba35e3cb30651cc6b9ab871849c7e8474.json
Convert `formula_support` test to spec.
Library/Homebrew/test/formula_support_spec.rb
@@ -0,0 +1,29 @@ +require "formula_support" + +describe KegOnlyReason do + describe "#to_s" do + it "returns the reason provided" do + r = KegOnlyReason.new :provided_by_osx, "test" + expect(r.to_s).to eq("test") + end + + it "returns a default message when no reason is provided" do + r = KegOnlyReason.new :provided_by_macos, "" + expect(r.to_s).to match(/^macOS already provides/) + end + end +end + +describe BottleDisableReason do + specify ":unneeded" do + bottle_disable_reason = BottleDisableReason.new :unneeded, nil + expect(bottle_disable_reason).to be_unneeded + expect(bottle_disable_reason.to_s).to eq("This formula doesn't require compiling.") + end + + specify ":disabled" do + bottle_disable_reason = BottleDisableReason.new :disable, "reason" + expect(bottle_disable_reason).not_to be_unneeded + expect(bottle_disable_reason.to_s).to eq("reason") + end +end
true
Other
Homebrew
brew
fb09867ba35e3cb30651cc6b9ab871849c7e8474.json
Convert `formula_support` test to spec.
Library/Homebrew/test/formula_support_test.rb
@@ -1,28 +0,0 @@ -require "testing_env" -require "formula_support" - -class KegOnlyReasonTests < Homebrew::TestCase - def test_to_s_explanation - r = KegOnlyReason.new :provided_by_osx, "test" - assert_equal "test", r.to_s - end - - def test_to_s_no_explanation - r = KegOnlyReason.new :provided_by_macos, "" - assert_match(/^macOS already provides/, r.to_s) - end -end - -class BottleDisableReasonTests < Homebrew::TestCase - def test_bottle_unneeded - bottle_disable_reason = BottleDisableReason.new :unneeded, nil - assert_predicate bottle_disable_reason, :unneeded? - assert_equal "This formula doesn't require compiling.", bottle_disable_reason.to_s - end - - def test_bottle_disabled - bottle_disable_reason = BottleDisableReason.new :disable, "reason" - refute_predicate bottle_disable_reason, :unneeded? - assert_equal "reason", bottle_disable_reason.to_s - end -end
true
Other
Homebrew
brew
26c01b4c43c5bf45799d81cd0e86ebca61a328c6.json
Convert X11Requirement test to spec.
Library/Homebrew/test/os/mac/x11_requirement_test.rb
@@ -1,13 +0,0 @@ -require "testing_env" -require "requirements/x11_requirement" - -class OSMacX11RequirementTests < Homebrew::TestCase - def test_satisfied - MacOS::XQuartz.stubs(:version).returns("2.7.5") - MacOS::XQuartz.stubs(:installed?).returns(true) - assert_predicate X11Requirement.new, :satisfied? - - MacOS::XQuartz.stubs(:installed?).returns(false) - refute_predicate X11Requirement.new, :satisfied? - end -end
true
Other
Homebrew
brew
26c01b4c43c5bf45799d81cd0e86ebca61a328c6.json
Convert X11Requirement test to spec.
Library/Homebrew/test/x11_requirement_spec.rb
@@ -33,4 +33,17 @@ subject.modify_build_environment end end + + describe "#satisfied?", :needs_macos do + it "returns true if X11 is installed" do + expect(MacOS::XQuartz).to receive(:version).and_return("2.7.5") + expect(MacOS::XQuartz).to receive(:installed?).and_return(true) + expect(subject).to be_satisfied + end + + it "returns false if X11 is not installed" do + expect(MacOS::XQuartz).to receive(:installed?).and_return(false) + expect(subject).not_to be_satisfied + end + end end
true
Other
Homebrew
brew
d25f9498244d2adebe3046c8857e05ded17f7485.json
Convert Sandbox test to spec.
Library/Homebrew/test/sandbox_spec.rb
@@ -0,0 +1,78 @@ +require "sandbox" + +RSpec::Matchers.define_negated_matcher :not_matching, :matching + +describe Sandbox do + let(:dir) { @dir = Pathname.new(Dir.mktmpdir) } + let(:file) { dir/"foo" } + + before(:each) do + skip "Sandbox not implemented." unless described_class.available? + end + + after(:each) do + dir.rmtree unless @dir.nil? + end + + specify "#formula?" do + f = formula { url "foo-1.0" } + f2 = formula { url "bar-1.0" } + allow(f2).to receive(:tap).and_return(Tap.fetch("test/tap")) + + ENV["HOMEBREW_SANDBOX"] = "1" + expect(described_class).to be_formula(f), "Formulae should be sandboxed if --sandbox was passed." + + ENV.delete("HOMEBREW_SANDBOX") + expect(described_class).to be_formula(f), "Formulae should be sandboxed if in a sandboxed tap." + expect(described_class).not_to be_formula(f2), "Formulae should not be sandboxed if not in a sandboxed tap." + end + + specify "#test?" do + ENV.delete("HOMEBREW_NO_SANDBOX") + expect(described_class).to be_test, "Tests should be sandboxed unless --no-sandbox was passed." + end + + specify "#allow_write" do + subject.allow_write file + subject.exec "touch", file + + expect(file).to exist + end + + describe "#exec" do + it "fails when writing to file not specified with ##allow_write" do + shutup do + expect { + subject.exec "touch", file + }.to raise_error(ErrorDuringExecution) + end + + expect(file).not_to exist + end + + it "complains on failure" do + ENV["HOMEBREW_VERBOSE"] = "1" + + expect(Utils).to receive(:popen_read).and_return("foo") + + expect { subject.exec "false" } + .to raise_error(ErrorDuringExecution) + .and output(/foo/).to_stdout + end + + it "ignores bogus Python error" do + ENV["HOMEBREW_VERBOSE"] = "1" + + with_bogus_error = <<-EOS.undent + foo + Mar 17 02:55:06 sandboxd[342]: Python(49765) deny file-write-unlink /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/errors.pyc + bar + EOS + expect(Utils).to receive(:popen_read).and_return(with_bogus_error) + + expect { subject.exec "false" } + .to raise_error(ErrorDuringExecution) + .and output(a_string_matching(/foo/).and(matching(/bar/).and(not_matching(/Python/)))).to_stdout + end + end +end
true
Other
Homebrew
brew
d25f9498244d2adebe3046c8857e05ded17f7485.json
Convert Sandbox test to spec.
Library/Homebrew/test/sandbox_test.rb
@@ -1,73 +0,0 @@ -require "testing_env" -require "sandbox" - -class SandboxTest < Homebrew::TestCase - def setup - super - skip "sandbox not implemented" unless Sandbox.available? - @sandbox = Sandbox.new - @dir = Pathname.new(mktmpdir) - @file = @dir/"foo" - end - - def test_formula? - f = formula { url "foo-1.0" } - f2 = formula { url "bar-1.0" } - f2.stubs(:tap).returns(Tap.fetch("test/tap")) - - ENV["HOMEBREW_SANDBOX"] = "1" - assert Sandbox.formula?(f), - "Formulae should be sandboxed if --sandbox was passed." - - ENV.delete("HOMEBREW_SANDBOX") - assert Sandbox.formula?(f), - "Formulae should be sandboxed if in a sandboxed tap." - refute Sandbox.formula?(f2), - "Formulae should not be sandboxed if not in a sandboxed tap." - end - - def test_test? - ENV.delete("HOMEBREW_NO_SANDBOX") - assert Sandbox.test?, - "Tests should be sandboxed unless --no-sandbox was passed." - end - - def test_allow_write - @sandbox.allow_write @file - @sandbox.exec "touch", @file - assert_predicate @file, :exist? - end - - def test_deny_write - shutup do - assert_raises(ErrorDuringExecution) { @sandbox.exec "touch", @file } - end - refute_predicate @file, :exist? - end - - def test_complains_on_failure - Utils.expects(popen_read: "foo") - ENV["HOMEBREW_VERBOSE"] = "1" - out, _err = capture_io do - assert_raises(ErrorDuringExecution) { @sandbox.exec "false" } - end - assert_match "foo", out - end - - def test_ignores_bogus_python_error - with_bogus_error = <<-EOS.undent - foo - Mar 17 02:55:06 sandboxd[342]: Python(49765) deny file-write-unlink /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/errors.pyc - bar - EOS - Utils.expects(popen_read: with_bogus_error) - ENV["HOMEBREW_VERBOSE"] = "1" - out, _err = capture_io do - assert_raises(ErrorDuringExecution) { @sandbox.exec "false" } - end - refute_predicate out, :empty? - assert_match "foo", out - assert_match "bar", out - refute_match "Python", out - end -end
true
Other
Homebrew
brew
76acd1e6eeb567647ac9a41dd23a78263c1c1643.json
Convert Version test to spec.
Library/Homebrew/test/support/helper/test_case.rb
@@ -6,11 +6,9 @@ class TestCase < ::Minitest::Test require "test/support/helper/fs_leak_logger" require "test/support/helper/lifecycle_enforcer" require "test/support/helper/shutup" - require "test/support/helper/version_assertions" include Test::Helper::FSLeakLogger include Test::Helper::LifecycleEnforcer include Test::Helper::Shutup - include Test::Helper::VersionAssertions TEST_DIRECTORIES = [ CoreTap.instance.path/"Formula",
true
Other
Homebrew
brew
76acd1e6eeb567647ac9a41dd23a78263c1c1643.json
Convert Version test to spec.
Library/Homebrew/test/support/helper/version_assertions.rb
@@ -1,23 +0,0 @@ -require "rubygems" - -module Test - module Helper - module VersionAssertions - def version(v) - Version.create(v) - end - - def assert_version_equal(expected, actual) - assert_equal Version.create(expected), actual - end - - def assert_version_detected(expected, url, specs = {}) - assert_equal expected, Version.detect(url, specs).to_s - end - - def assert_version_nil(url) - assert Version.parse(url).null? - end - end - end -end
true
Other
Homebrew
brew
76acd1e6eeb567647ac9a41dd23a78263c1c1643.json
Convert Version test to spec.
Library/Homebrew/test/version_spec.rb
@@ -0,0 +1,602 @@ +require "version" + +describe Version::Token do + specify "#inspect" do + expect(Version::Token.new("foo").inspect).to eq('#<Version::Token "foo">') + end + + specify "#to_s" do + expect(Version::Token.new("foo").to_s).to eq("foo") + end +end + +describe Version::NULL do + it "is always smaller" do + expect(Version::NULL).to be < Version.create("1") + end + + it "is never greater" do + expect(Version::NULL).not_to be > Version.create("0") + end + + it "isn't equal to itself" do + expect(Version::NULL).not_to eql(Version::NULL) + end + + it "creates an empty string" do + expect(Version::NULL.to_s).to eq("") + end + + it "produces NaN as a Float" do + # Float::NAN is not equal to itself so compare object IDs + expect(Version::NULL.to_f.object_id).to eql(Float::NAN.object_id) + end +end + +describe Version::NullToken do + specify "#inspect" do + expect(subject.inspect).to eq("#<Version::NullToken>") + end + + it "is equal to itself" do + expect(subject).to be == described_class.new + end +end + +describe Version do + specify "comparison" do + expect(Version.create("0.1")).to be == Version.create("0.1.0") + expect(Version.create("0.1")).to be < Version.create("0.2") + expect(Version.create("1.2.3")).to be > Version.create("1.2.2") + expect(Version.create("1.2.4")).to be < Version.create("1.2.4.1") + + expect(Version.create("1.2.3")).to be > Version.create("1.2.3alpha4") + expect(Version.create("1.2.3")).to be > Version.create("1.2.3beta2") + expect(Version.create("1.2.3")).to be > Version.create("1.2.3rc3") + expect(Version.create("1.2.3")).to be < Version.create("1.2.3-p34") + end + + specify "HEAD" do + expect(Version.create("HEAD")).to be > Version.create("1.2.3") + expect(Version.create("HEAD-abcdef")).to be > Version.create("1.2.3") + expect(Version.create("1.2.3")).to be < Version.create("HEAD") + expect(Version.create("1.2.3")).to be < Version.create("HEAD-fedcba") + expect(Version.create("HEAD-abcdef")).to be == Version.create("HEAD-fedcba") + expect(Version.create("HEAD")).to be == Version.create("HEAD-fedcba") + end + + specify "comparing alpha versions" do + expect(Version.create("1.2.3alpha")).to be < Version.create("1.2.3") + expect(Version.create("1.2.3")).to be < Version.create("1.2.3a") + expect(Version.create("1.2.3alpha4")).to be == Version.create("1.2.3a4") + expect(Version.create("1.2.3alpha4")).to be == Version.create("1.2.3A4") + expect(Version.create("1.2.3alpha4")).to be > Version.create("1.2.3alpha3") + expect(Version.create("1.2.3alpha4")).to be < Version.create("1.2.3alpha5") + expect(Version.create("1.2.3alpha4")).to be < Version.create("1.2.3alpha10") + + expect(Version.create("1.2.3alpha4")).to be < Version.create("1.2.3beta2") + expect(Version.create("1.2.3alpha4")).to be < Version.create("1.2.3rc3") + expect(Version.create("1.2.3alpha4")).to be < Version.create("1.2.3") + expect(Version.create("1.2.3alpha4")).to be < Version.create("1.2.3-p34") + end + + specify "comparing beta versions" do + expect(Version.create("1.2.3beta2")).to be == Version.create("1.2.3b2") + expect(Version.create("1.2.3beta2")).to be == Version.create("1.2.3B2") + expect(Version.create("1.2.3beta2")).to be > Version.create("1.2.3beta1") + expect(Version.create("1.2.3beta2")).to be < Version.create("1.2.3beta3") + expect(Version.create("1.2.3beta2")).to be < Version.create("1.2.3beta10") + + expect(Version.create("1.2.3beta2")).to be > Version.create("1.2.3alpha4") + expect(Version.create("1.2.3beta2")).to be < Version.create("1.2.3rc3") + expect(Version.create("1.2.3beta2")).to be < Version.create("1.2.3") + expect(Version.create("1.2.3beta2")).to be < Version.create("1.2.3-p34") + end + + specify "comparing RC versions" do + expect(Version.create("1.2.3rc3")).to be == Version.create("1.2.3RC3") + expect(Version.create("1.2.3rc3")).to be > Version.create("1.2.3rc2") + expect(Version.create("1.2.3rc3")).to be < Version.create("1.2.3rc4") + expect(Version.create("1.2.3rc3")).to be < Version.create("1.2.3rc10") + + expect(Version.create("1.2.3rc3")).to be > Version.create("1.2.3alpha4") + expect(Version.create("1.2.3rc3")).to be > Version.create("1.2.3beta2") + expect(Version.create("1.2.3rc3")).to be < Version.create("1.2.3") + expect(Version.create("1.2.3rc3")).to be < Version.create("1.2.3-p34") + end + + specify "comparing patch-level versions" do + expect(Version.create("1.2.3-p34")).to be == Version.create("1.2.3-P34") + expect(Version.create("1.2.3-p34")).to be > Version.create("1.2.3-p33") + expect(Version.create("1.2.3-p34")).to be < Version.create("1.2.3-p35") + expect(Version.create("1.2.3-p34")).to be > Version.create("1.2.3-p9") + + expect(Version.create("1.2.3-p34")).to be > Version.create("1.2.3alpha4") + expect(Version.create("1.2.3-p34")).to be > Version.create("1.2.3beta2") + expect(Version.create("1.2.3-p34")).to be > Version.create("1.2.3rc3") + expect(Version.create("1.2.3-p34")).to be > Version.create("1.2.3") + end + + specify "comparing unevenly-padded versions" do + expect(Version.create("2.1.0-p194")).to be < Version.create("2.1-p195") + expect(Version.create("2.1-p195")).to be > Version.create("2.1.0-p194") + expect(Version.create("2.1-p194")).to be < Version.create("2.1.0-p195") + expect(Version.create("2.1.0-p195")).to be > Version.create("2.1-p194") + expect(Version.create("2-p194")).to be < Version.create("2.1-p195") + end + + it "can be compared against nil" do + expect(Version.create("2.1.0-p194")).to be > nil + end + + it "can be compared against strings" do + expect(Version.create("2.1.0-p194")).to be == "2.1.0-p194" + expect(Version.create("1")).to be == 1 + end + + specify "comparison returns nil for non-version" do + v = Version.create("1.0") + expect(v <=> Object.new).to be nil + expect { v > Object.new }.to raise_error(ArgumentError) + end + + specify "erlang versions" do + versions = %w[R16B R15B03-1 R15B03 R15B02 R15B01 R14B04 R14B03 + R14B02 R14B01 R14B R13B04 R13B03 R13B02-1].reverse + expect(versions.sort_by { |v| Version.create(v) }).to eq(versions) + end + + specify "hash equality" do + v1 = Version.create("0.1.0") + v2 = Version.create("0.1.0") + v3 = Version.create("0.1.1") + + expect(v1).to eql(v2) + expect(v1).not_to eql(v3) + expect(v1.hash).to eq(v2.hash) + expect(v1.hash).not_to eq(v3.hash) + + h = { v1 => :foo } + expect(h[v2]).to eq(:foo) + end + + describe "::create" do + it "accepts objects responding to #to_str" do + value = double(to_str: "0.1") + expect(Version.create(value).to_s).to eq("0.1") + end + + it "raises a TypeError for non-string objects" do + expect { Version.create(1.1) }.to raise_error(TypeError) + expect { Version.create(1) }.to raise_error(TypeError) + expect { Version.create(:symbol) }.to raise_error(TypeError) + end + + it "parses a version from a string" do + v = Version.create("1.20") + expect(v).not_to be_head + expect(v.to_str).to eq("1.20") + end + + specify "HEAD with commit" do + v = Version.create("HEAD-abcdef") + expect(v.commit).to eq("abcdef") + expect(v.to_str).to eq("HEAD-abcdef") + end + + specify "HEAD without commit" do + v = Version.create("HEAD") + expect(v.commit).to be nil + expect(v.to_str).to eq("HEAD") + end + end + + specify "#detected_from_url?" do + expect(Version.create("1.0")).not_to be_detected_from_url + expect(Version::FromURL.new("1.0")).to be_detected_from_url + end + + specify "#head?" do + v1 = Version.create("HEAD-abcdef") + v2 = Version.create("HEAD") + + expect(v1).to be_head + expect(v2).to be_head + end + + specify "#update_commit" do + v1 = Version.create("HEAD-abcdef") + v2 = Version.create("HEAD") + + v1.update_commit("ffffff") + expect(v1.commit).to eq("ffffff") + expect(v1.to_str).to eq("HEAD-ffffff") + + v2.update_commit("ffffff") + expect(v2.commit).to eq("ffffff") + expect(v2.to_str).to eq("HEAD-ffffff") + end + + describe "::parse" do + it "returns a NULL version when the URL cannot be parsed" do + expect(Version.parse("http://example.com/blah.tar")).to be_null + expect(Version.parse("foo")).to be_null + end + end + + describe "::detect" do + matcher :be_detected_from do |url, specs = {}| + match do |version| + Version.detect(url, specs) == version + end + end + + specify "version all dots" do + expect(Version.create("1.14")) + .to be_detected_from("http://example.com/foo.bar.la.1.14.zip") + end + + specify "version underscore separator" do + expect(Version.create("1.1")) + .to be_detected_from("http://example.com/grc_1.1.tar.gz") + end + + specify "boost version style" do + expect(Version.create("1.39.0")) + .to be_detected_from("http://example.com/boost_1_39_0.tar.bz2") + end + + specify "erlang version style" do + expect(Version.create("R13B")) + .to be_detected_from("http://erlang.org/download/otp_src_R13B.tar.gz") + end + + specify "another erlang version style" do + expect(Version.create("R15B01")) + .to be_detected_from("https://github.com/erlang/otp/tarball/OTP_R15B01") + end + + specify "yet another erlang version style" do + expect(Version.create("R15B03-1")) + .to be_detected_from("https://github.com/erlang/otp/tarball/OTP_R15B03-1") + end + + specify "p7zip version style" do + expect(Version.create("9.04")) + .to be_detected_from("http://kent.dl.sourceforge.net/sourceforge/p7zip/p7zip_9.04_src_all.tar.bz2") + end + + specify "new github style" do + expect(Version.create("1.1.4")) + .to be_detected_from("https://github.com/sam-github/libnet/tarball/libnet-1.1.4") + end + + specify "codeload style" do + expect(Version.create("0.7.1")) + .to be_detected_from("https://codeload.github.com/gsamokovarov/jump/tar.gz/v0.7.1") + end + + specify "elasticsearch alpha style" do + expect(Version.create("5.0.0-alpha5")) + .to be_detected_from("https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/5.0.0-alpha5/elasticsearch-5.0.0-alpha5.tar.gz") + end + + specify "gloox beta style" do + expect(Version.create("1.0-beta7")) + .to be_detected_from("http://camaya.net/download/gloox-1.0-beta7.tar.bz2") + end + + specify "sphinx beta style" do + expect(Version.create("1.10-beta")) + .to be_detected_from("http://sphinxsearch.com/downloads/sphinx-1.10-beta.tar.gz") + end + + specify "astyle version style" do + expect(Version.create("1.23")) + .to be_detected_from("http://kent.dl.sourceforge.net/sourceforge/astyle/astyle_1.23_macosx.tar.gz") + end + + specify "version dos2unix" do + expect(Version.create("3.1")) + .to be_detected_from("http://www.sfr-fresh.com/linux/misc/dos2unix-3.1.tar.gz") + end + + specify "version internal dash" do + expect(Version.create("1.1-2")) + .to be_detected_from("http://example.com/foo-arse-1.1-2.tar.gz") + end + + specify "version single digit" do + expect(Version.create("45")) + .to be_detected_from("http://example.com/foo_bar.45.tar.gz") + end + + specify "noseparator single digit" do + expect(Version.create("45")) + .to be_detected_from("http://example.com/foo_bar45.tar.gz") + end + + specify "version developer that hates us format" do + expect(Version.create("1.2.3")) + .to be_detected_from("http://example.com/foo-bar-la.1.2.3.tar.gz") + end + + specify "version regular" do + expect(Version.create("1.21")) + .to be_detected_from("http://example.com/foo_bar-1.21.tar.gz") + end + + specify "version sourceforge download" do + expect(Version.create("1.21")) + .to be_detected_from("http://sourceforge.net/foo_bar-1.21.tar.gz/download") + expect(Version.create("1.21")) + .to be_detected_from("http://sf.net/foo_bar-1.21.tar.gz/download") + end + + specify "version github" do + expect(Version.create("1.0.5")) + .to be_detected_from("http://github.com/lloyd/yajl/tarball/1.0.5") + end + + specify "version github with high patch number" do + expect(Version.create("1.2.34")) + .to be_detected_from("http://github.com/lloyd/yajl/tarball/v1.2.34") + end + + specify "yet another version" do + expect(Version.create("0.15.1b")) + .to be_detected_from("http://example.com/mad-0.15.1b.tar.gz") + end + + specify "lame version style" do + expect(Version.create("398-2")) + .to be_detected_from("http://kent.dl.sourceforge.net/sourceforge/lame/lame-398-2.tar.gz") + end + + specify "ruby version style" do + expect(Version.create("1.9.1-p243")) + .to be_detected_from("ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz") + end + + specify "omega version style" do + expect(Version.create("0.80.2")) + .to be_detected_from("http://www.alcyone.com/binaries/omega/omega-0.80.2-src.tar.gz") + end + + specify "rc style" do + expect(Version.create("1.2.2rc1")) + .to be_detected_from("http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.2rc1.tar.bz2") + end + + specify "dash rc style" do + expect(Version.create("1.8.0-rc1")) + .to be_detected_from("http://ftp.mozilla.org/pub/mozilla.org/js/js-1.8.0-rc1.tar.gz") + end + + specify "angband version style" do + expect(Version.create("3.0.9b")) + .to be_detected_from("http://rephial.org/downloads/3.0/angband-3.0.9b-src.tar.gz") + end + + specify "stable suffix" do + expect(Version.create("1.4.14b")) + .to be_detected_from("http://www.monkey.org/~provos/libevent-1.4.14b-stable.tar.gz") + end + + specify "debian style 1" do + expect(Version.create("3.03")) + .to be_detected_from("http://ftp.de.debian.org/debian/pool/main/s/sl/sl_3.03.orig.tar.gz") + end + + specify "debian style 2" do + expect(Version.create("1.01b")) + .to be_detected_from("http://ftp.de.debian.org/debian/pool/main/m/mmv/mmv_1.01b.orig.tar.gz") + end + + specify "bottle style" do + expect(Version.create("4.8.0")) + .to be_detected_from("https://homebrew.bintray.com/bottles/qt-4.8.0.lion.bottle.tar.gz") + end + + specify "versioned bottle style" do + expect(Version.create("4.8.1")) + .to be_detected_from("https://homebrew.bintray.com/bottles/qt-4.8.1.lion.bottle.1.tar.gz") + end + + specify "erlang bottle style" do + expect(Version.create("R15B")) + .to be_detected_from("https://homebrew.bintray.com/bottles/erlang-R15B.lion.bottle.tar.gz") + end + + specify "another erlang bottle style" do + expect(Version.create("R15B01")) + .to be_detected_from("https://homebrew.bintray.com/bottles/erlang-R15B01.mountain_lion.bottle.tar.gz") + end + + specify "yet another erlang bottle style" do + expect(Version.create("R15B03-1")) + .to be_detected_from("https://homebrew.bintray.com/bottles/erlang-R15B03-1.mountainlion.bottle.tar.gz") + end + + specify "imagemagick style" do + expect(Version.create("6.7.5-7")) + .to be_detected_from("http://downloads.sf.net/project/machomebrew/mirror/ImageMagick-6.7.5-7.tar.bz2") + end + + specify "imagemagick bottle style" do + expect(Version.create("6.7.5-7")) + .to be_detected_from("https://homebrew.bintray.com/bottles/imagemagick-6.7.5-7.lion.bottle.tar.gz") + end + + specify "imagemagick versioned bottle style" do + expect(Version.create("6.7.5-7")) + .to be_detected_from("https://homebrew.bintray.com/bottles/imagemagick-6.7.5-7.lion.bottle.1.tar.gz") + end + + specify "dash version style" do + expect(Version.create("3.4")) + .to be_detected_from("http://www.antlr.org/download/antlr-3.4-complete.jar") + end + + specify "jenkins version style" do + expect(Version.create("1.486")) + .to be_detected_from("http://mirrors.jenkins-ci.org/war/1.486/jenkins.war") + expect(Version.create("0.10.11")) + .to be_detected_from("https://github.com/hechoendrupal/DrupalConsole/releases/download/0.10.11/drupal.phar") + end + + specify "apache version style" do + expect(Version.create("1.2.0-rc2")) + .to be_detected_from("http://www.apache.org/dyn/closer.cgi?path=/cassandra/1.2.0/apache-cassandra-1.2.0-rc2-bin.tar.gz") + end + + specify "jpeg version style" do + expect(Version.create("8d")) + .to be_detected_from("http://www.ijg.org/files/jpegsrc.v8d.tar.gz") + end + + specify "ghc version style" do + expect(Version.create("7.0.4")) + .to be_detected_from("http://www.haskell.org/ghc/dist/7.0.4/ghc-7.0.4-x86_64-apple-darwin.tar.bz2") + expect(Version.create("7.0.4")) + .to be_detected_from("http://www.haskell.org/ghc/dist/7.0.4/ghc-7.0.4-i386-apple-darwin.tar.bz2") + end + + specify "pypy version style" do + expect(Version.create("1.4.1")) + .to be_detected_from("http://pypy.org/download/pypy-1.4.1-osx.tar.bz2") + end + + specify "openssl version style" do + expect(Version.create("0.9.8s")) + .to be_detected_from("http://www.openssl.org/source/openssl-0.9.8s.tar.gz") + end + + specify "xaw3d version style" do + expect(Version.create("1.5E")) + .to be_detected_from("ftp://ftp.visi.com/users/hawkeyd/X/Xaw3d-1.5E.tar.gz") + end + + specify "assimp version style" do + expect(Version.create("2.0.863")) + .to be_detected_from("http://downloads.sourceforge.net/project/assimp/assimp-2.0/assimp--2.0.863-sdk.zip") + end + + specify "cmucl version style" do + expect(Version.create("20c")) + .to be_detected_from("http://common-lisp.net/project/cmucl/downloads/release/20c/cmucl-20c-x86-darwin.tar.bz2") + end + + specify "fann version style" do + expect(Version.create("2.1.0beta")) + .to be_detected_from("http://downloads.sourceforge.net/project/fann/fann/2.1.0beta/fann-2.1.0beta.zip") + end + + specify "grads version style" do + expect(Version.create("2.0.1")) + .to be_detected_from("ftp://iges.org/grads/2.0/grads-2.0.1-bin-darwin9.8-intel.tar.gz") + end + + specify "haxe version style" do + expect(Version.create("2.08")) + .to be_detected_from("http://haxe.org/file/haxe-2.08-osx.tar.gz") + end + + specify "imap version style" do + expect(Version.create("2007f")) + .to be_detected_from("ftp://ftp.cac.washington.edu/imap/imap-2007f.tar.gz") + end + + specify "suite3270 version style" do + expect(Version.create("3.3.12ga7")) + .to be_detected_from("http://downloads.sourceforge.net/project/x3270/x3270/3.3.12ga7/suite3270-3.3.12ga7-src.tgz") + end + + specify "wwwoffle version style" do + expect(Version.create("2.9h")) + .to be_detected_from("http://www.gedanken.demon.co.uk/download-wwwoffle/wwwoffle-2.9h.tgz") + end + + specify "synergy version style" do + expect(Version.create("1.3.6p2")) + .to be_detected_from("http://synergy.googlecode.com/files/synergy-1.3.6p2-MacOSX-Universal.zip") + end + + specify "fontforge version style" do + expect(Version.create("20120731")) + .to be_detected_from("http://downloads.sourceforge.net/project/fontforge/fontforge-source/fontforge_full-20120731-b.tar.bz2") + end + + specify "ezlupdate version style" do + expect(Version.create("2011.10")) + .to be_detected_from("https://github.com/downloads/ezsystems/ezpublish-legacy/ezpublish_community_project-2011.10-with_ezc.tar.bz2") + end + + specify "aespipe version style" do + expect(Version.create("2.4c")) + .to be_detected_from("http://loop-aes.sourceforge.net/aespipe/aespipe-v2.4c.tar.bz2") + end + + specify "win version style" do + expect(Version.create("0.9.17")) + .to be_detected_from("http://ftpmirror.gnu.org/libmicrohttpd/libmicrohttpd-0.9.17-w32.zip") + expect(Version.create("1.29")) + .to be_detected_from("http://ftpmirror.gnu.org/libidn/libidn-1.29-win64.zip") + end + + specify "with arch" do + expect(Version.create("4.0.18-1")) + .to be_detected_from("http://ftpmirror.gnu.org/mtools/mtools-4.0.18-1.i686.rpm") + expect(Version.create("5.5.7-5")) + .to be_detected_from("http://ftpmirror.gnu.org/autogen/autogen-5.5.7-5.i386.rpm") + expect(Version.create("2.8")) + .to be_detected_from("http://ftpmirror.gnu.org/libtasn1/libtasn1-2.8-x86.zip") + expect(Version.create("2.8")) + .to be_detected_from("http://ftpmirror.gnu.org/libtasn1/libtasn1-2.8-x64.zip") + expect(Version.create("4.0.18")) + .to be_detected_from("http://ftpmirror.gnu.org/mtools/mtools_4.0.18_i386.deb") + end + + specify "opam version" do + expect(Version.create("2.18.3")) + .to be_detected_from("https://opam.ocaml.org/archives/lablgtk.2.18.3+opam.tar.gz") + expect(Version.create("1.9")) + .to be_detected_from("https://opam.ocaml.org/archives/sha.1.9+opam.tar.gz") + expect(Version.create("0.99.2")) + .to be_detected_from("https://opam.ocaml.org/archives/ppx_tools.0.99.2+opam.tar.gz") + expect(Version.create("1.0.2")) + .to be_detected_from("https://opam.ocaml.org/archives/easy-format.1.0.2+opam.tar.gz") + end + + specify "no extension version" do + expect(Version.create("1.8.12")) + .to be_detected_from("https://waf.io/waf-1.8.12") + expect(Version.create("0.7.1")) + .to be_detected_from("https://codeload.github.com/gsamokovarov/jump/tar.gz/v0.7.1") + expect(Version.create("0.9.1234")) + .to be_detected_from("https://my.datomic.com/downloads/free/0.9.1234") + expect(Version.create("0.9")) + .to be_detected_from("https://my.datomic.com/downloads/free/0.9.1t34") + expect(Version.create("1.2.3")) + .to be_detected_from("https://my.datomic.com/downloads/free/1.2.3") + end + + specify "dash separated version" do + expect(Version.create("6-20151227")) + .to be_detected_from("ftp://gcc.gnu.org/pub/gcc/snapshots/6-20151227/gcc-6-20151227.tar.bz2") + end + + specify "from URL" do + expect(Version.create("1.2.3")) + .to be_detected_from("http://github.com/foo/bar.git", tag: "v1.2.3") + end + end +end + +describe Pathname do + specify "#version" do + d = HOMEBREW_CELLAR/"foo-0.1.9" + d.mkpath + expect(d.version).to eq(Version.create("0.1.9")) + end +end
true
Other
Homebrew
brew
76acd1e6eeb567647ac9a41dd23a78263c1c1643.json
Convert Version test to spec.
Library/Homebrew/test/versions_test.rb
@@ -1,528 +0,0 @@ -require "testing_env" -require "version" - -class VersionTests < Homebrew::TestCase - def test_accepts_objects_responding_to_to_str - value = stub(to_str: "0.1") - assert_equal "0.1", Version.create(value).to_s - end - - def test_raises_for_non_string_objects - assert_raises(TypeError) { Version.create(1.1) } - assert_raises(TypeError) { Version.create(1) } - assert_raises(TypeError) { Version.create(:symbol) } - end - - def test_detected_from_url? - refute Version.create("1.0").detected_from_url? - assert Version::FromURL.new("1.0").detected_from_url? - end -end - -class VersionTokenTests < Homebrew::TestCase - def test_inspect - assert_equal '#<Version::Token "foo">', - Version::Token.new("foo").inspect - end - - def test_to_s - assert_equal "foo", Version::Token.new("foo").to_s - end -end - -class NullVersionTests < Homebrew::TestCase - def test_null_version_is_always_smaller - assert_operator Version::NULL, :<, version("1") - end - - def test_null_version_is_never_greater - refute_operator Version::NULL, :>, version("0") - end - - def test_null_version_is_not_equal_to_itself - refute_eql Version::NULL, Version::NULL - end - - def test_null_version_creates_an_empty_string - assert_eql "", Version::NULL.to_s - end - - def test_null_version_produces_nan_as_a_float - # Float::NAN is not equal to itself so compare object IDs - assert_eql Float::NAN.object_id, Version::NULL.to_f.object_id - end -end - -class VersionNullTokenTests < Homebrew::TestCase - def test_inspect - assert_equal "#<Version::NullToken>", Version::NullToken.new.inspect - end - - def test_comparing_null - assert_operator Version::NullToken.new, :==, Version::NullToken.new - end -end - -class VersionComparisonTests < Homebrew::TestCase - def test_comparing_regular_versions - assert_operator version("0.1"), :==, version("0.1.0") - assert_operator version("0.1"), :<, version("0.2") - assert_operator version("1.2.3"), :>, version("1.2.2") - assert_operator version("1.2.4"), :<, version("1.2.4.1") - - assert_operator version("1.2.3"), :>, version("1.2.3alpha4") - assert_operator version("1.2.3"), :>, version("1.2.3beta2") - assert_operator version("1.2.3"), :>, version("1.2.3rc3") - assert_operator version("1.2.3"), :<, version("1.2.3-p34") - end - - def test_head - assert_operator version("HEAD"), :>, version("1.2.3") - assert_operator version("HEAD-abcdef"), :>, version("1.2.3") - assert_operator version("1.2.3"), :<, version("HEAD") - assert_operator version("1.2.3"), :<, version("HEAD-fedcba") - assert_operator version("HEAD-abcdef"), :==, version("HEAD-fedcba") - assert_operator version("HEAD"), :==, version("HEAD-fedcba") - end - - def test_comparing_alpha_versions - assert_operator version("1.2.3alpha"), :<, version("1.2.3") - assert_operator version("1.2.3"), :<, version("1.2.3a") - assert_operator version("1.2.3alpha4"), :==, version("1.2.3a4") - assert_operator version("1.2.3alpha4"), :==, version("1.2.3A4") - assert_operator version("1.2.3alpha4"), :>, version("1.2.3alpha3") - assert_operator version("1.2.3alpha4"), :<, version("1.2.3alpha5") - assert_operator version("1.2.3alpha4"), :<, version("1.2.3alpha10") - - assert_operator version("1.2.3alpha4"), :<, version("1.2.3beta2") - assert_operator version("1.2.3alpha4"), :<, version("1.2.3rc3") - assert_operator version("1.2.3alpha4"), :<, version("1.2.3") - assert_operator version("1.2.3alpha4"), :<, version("1.2.3-p34") - end - - def test_comparing_beta_versions - assert_operator version("1.2.3beta2"), :==, version("1.2.3b2") - assert_operator version("1.2.3beta2"), :==, version("1.2.3B2") - assert_operator version("1.2.3beta2"), :>, version("1.2.3beta1") - assert_operator version("1.2.3beta2"), :<, version("1.2.3beta3") - assert_operator version("1.2.3beta2"), :<, version("1.2.3beta10") - - assert_operator version("1.2.3beta2"), :>, version("1.2.3alpha4") - assert_operator version("1.2.3beta2"), :<, version("1.2.3rc3") - assert_operator version("1.2.3beta2"), :<, version("1.2.3") - assert_operator version("1.2.3beta2"), :<, version("1.2.3-p34") - end - - def test_comparing_rc_versions - assert_operator version("1.2.3rc3"), :==, version("1.2.3RC3") - assert_operator version("1.2.3rc3"), :>, version("1.2.3rc2") - assert_operator version("1.2.3rc3"), :<, version("1.2.3rc4") - assert_operator version("1.2.3rc3"), :<, version("1.2.3rc10") - - assert_operator version("1.2.3rc3"), :>, version("1.2.3alpha4") - assert_operator version("1.2.3rc3"), :>, version("1.2.3beta2") - assert_operator version("1.2.3rc3"), :<, version("1.2.3") - assert_operator version("1.2.3rc3"), :<, version("1.2.3-p34") - end - - def test_comparing_patchlevel_versions - assert_operator version("1.2.3-p34"), :==, version("1.2.3-P34") - assert_operator version("1.2.3-p34"), :>, version("1.2.3-p33") - assert_operator version("1.2.3-p34"), :<, version("1.2.3-p35") - assert_operator version("1.2.3-p34"), :>, version("1.2.3-p9") - - assert_operator version("1.2.3-p34"), :>, version("1.2.3alpha4") - assert_operator version("1.2.3-p34"), :>, version("1.2.3beta2") - assert_operator version("1.2.3-p34"), :>, version("1.2.3rc3") - assert_operator version("1.2.3-p34"), :>, version("1.2.3") - end - - def test_comparing_unevenly_padded_versions - assert_operator version("2.1.0-p194"), :<, version("2.1-p195") - assert_operator version("2.1-p195"), :>, version("2.1.0-p194") - assert_operator version("2.1-p194"), :<, version("2.1.0-p195") - assert_operator version("2.1.0-p195"), :>, version("2.1-p194") - assert_operator version("2-p194"), :<, version("2.1-p195") - end - - def test_comparing_against_nil - assert_operator version("2.1.0-p194"), :>, nil - end - - def test_comparing_against_strings - assert_operator version("2.1.0-p194"), :==, "2.1.0-p194" - assert_operator version("1"), :==, 1 - end - - def test_comparison_returns_nil_for_non_version - v = version("1.0") - assert_nil v <=> Object.new - assert_raises(ArgumentError) { v > Object.new } - end - - def test_erlang_version - versions = %w[R16B R15B03-1 R15B03 R15B02 R15B01 R14B04 R14B03 - R14B02 R14B01 R14B R13B04 R13B03 R13B02-1].reverse - assert_equal versions, versions.sort_by { |v| version(v) } - end - - def test_hash_equality - v1 = version("0.1.0") - v2 = version("0.1.0") - v3 = version("0.1.1") - - assert_eql v1, v2 - refute_eql v1, v3 - assert_equal v1.hash, v2.hash - - h = { v1 => :foo } - assert_equal :foo, h[v2] - end -end - -class VersionParsingTests < Homebrew::TestCase - def test_pathname_version - d = HOMEBREW_CELLAR/"foo-0.1.9" - d.mkpath - assert_equal version("0.1.9"), d.version - end - - def test_no_version - assert_version_nil "http://example.com/blah.tar" - assert_version_nil "foo" - end - - def test_create - v = Version.create("1.20") - refute_predicate v, :head? - assert_equal "1.20", v.to_str - end - - def test_version_all_dots - assert_version_detected "1.14", "http://example.com/foo.bar.la.1.14.zip" - end - - def test_version_underscore_separator - assert_version_detected "1.1", "http://example.com/grc_1.1.tar.gz" - end - - def test_boost_version_style - assert_version_detected "1.39.0", "http://example.com/boost_1_39_0.tar.bz2" - end - - def test_erlang_version_style - assert_version_detected "R13B", "http://erlang.org/download/otp_src_R13B.tar.gz" - end - - def test_another_erlang_version_style - assert_version_detected "R15B01", "https://github.com/erlang/otp/tarball/OTP_R15B01" - end - - def test_yet_another_erlang_version_style - assert_version_detected "R15B03-1", "https://github.com/erlang/otp/tarball/OTP_R15B03-1" - end - - def test_p7zip_version_style - assert_version_detected "9.04", - "http://kent.dl.sourceforge.net/sourceforge/p7zip/p7zip_9.04_src_all.tar.bz2" - end - - def test_new_github_style - assert_version_detected "1.1.4", "https://github.com/sam-github/libnet/tarball/libnet-1.1.4" - end - - def test_codeload_style - assert_version_detected "0.7.1", "https://codeload.github.com/gsamokovarov/jump/tar.gz/v0.7.1" - end - - def test_elasticsearch_alpha_style - assert_version_detected "5.0.0-alpha5", "https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/5.0.0-alpha5/elasticsearch-5.0.0-alpha5.tar.gz" - end - - def test_gloox_beta_style - assert_version_detected "1.0-beta7", "http://camaya.net/download/gloox-1.0-beta7.tar.bz2" - end - - def test_sphinx_beta_style - assert_version_detected "1.10-beta", "http://sphinxsearch.com/downloads/sphinx-1.10-beta.tar.gz" - end - - def test_astyle_verson_style - assert_version_detected "1.23", "http://kent.dl.sourceforge.net/sourceforge/astyle/astyle_1.23_macosx.tar.gz" - end - - def test_version_dos2unix - assert_version_detected "3.1", "http://www.sfr-fresh.com/linux/misc/dos2unix-3.1.tar.gz" - end - - def test_version_internal_dash - assert_version_detected "1.1-2", "http://example.com/foo-arse-1.1-2.tar.gz" - end - - def test_version_single_digit - assert_version_detected "45", "http://example.com/foo_bar.45.tar.gz" - end - - def test_noseparator_single_digit - assert_version_detected "45", "http://example.com/foo_bar45.tar.gz" - end - - def test_version_developer_that_hates_us_format - assert_version_detected "1.2.3", "http://example.com/foo-bar-la.1.2.3.tar.gz" - end - - def test_version_regular - assert_version_detected "1.21", "http://example.com/foo_bar-1.21.tar.gz" - end - - def test_version_sourceforge_download - assert_version_detected "1.21", "http://sourceforge.net/foo_bar-1.21.tar.gz/download" - assert_version_detected "1.21", "http://sf.net/foo_bar-1.21.tar.gz/download" - end - - def test_version_github - assert_version_detected "1.0.5", "http://github.com/lloyd/yajl/tarball/1.0.5" - end - - def test_version_github_with_high_patch_number - assert_version_detected "1.2.34", "http://github.com/lloyd/yajl/tarball/v1.2.34" - end - - def test_yet_another_version - assert_version_detected "0.15.1b", "http://example.com/mad-0.15.1b.tar.gz" - end - - def test_lame_version_style - assert_version_detected "398-2", "http://kent.dl.sourceforge.net/sourceforge/lame/lame-398-2.tar.gz" - end - - def test_ruby_version_style - assert_version_detected "1.9.1-p243", "ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz" - end - - def test_omega_version_style - assert_version_detected "0.80.2", "http://www.alcyone.com/binaries/omega/omega-0.80.2-src.tar.gz" - end - - def test_rc_style - assert_version_detected "1.2.2rc1", "http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.2rc1.tar.bz2" - end - - def test_dash_rc_style - assert_version_detected "1.8.0-rc1", "http://ftp.mozilla.org/pub/mozilla.org/js/js-1.8.0-rc1.tar.gz" - end - - def test_angband_version_style - assert_version_detected "3.0.9b", "http://rephial.org/downloads/3.0/angband-3.0.9b-src.tar.gz" - end - - def test_stable_suffix - assert_version_detected "1.4.14b", "http://www.monkey.org/~provos/libevent-1.4.14b-stable.tar.gz" - end - - def test_debian_style_1 - assert_version_detected "3.03", "http://ftp.de.debian.org/debian/pool/main/s/sl/sl_3.03.orig.tar.gz" - end - - def test_debian_style_2 - assert_version_detected "1.01b", "http://ftp.de.debian.org/debian/pool/main/m/mmv/mmv_1.01b.orig.tar.gz" - end - - def test_bottle_style - assert_version_detected "4.8.0", "https://homebrew.bintray.com/bottles/qt-4.8.0.lion.bottle.tar.gz" - end - - def test_versioned_bottle_style - assert_version_detected "4.8.1", "https://homebrew.bintray.com/bottles/qt-4.8.1.lion.bottle.1.tar.gz" - end - - def test_erlang_bottle_style - assert_version_detected "R15B", "https://homebrew.bintray.com/bottles/erlang-R15B.lion.bottle.tar.gz" - end - - def test_another_erlang_bottle_style - assert_version_detected "R15B01", "https://homebrew.bintray.com/bottles/erlang-R15B01.mountain_lion.bottle.tar.gz" - end - - def test_yet_another_erlang_bottle_style - assert_version_detected "R15B03-1", "https://homebrew.bintray.com/bottles/erlang-R15B03-1.mountainlion.bottle.tar.gz" - end - - def test_imagemagick_style - assert_version_detected "6.7.5-7", "http://downloads.sf.net/project/machomebrew/mirror/ImageMagick-6.7.5-7.tar.bz2" - end - - def test_imagemagick_bottle_style - assert_version_detected "6.7.5-7", "https://homebrew.bintray.com/bottles/imagemagick-6.7.5-7.lion.bottle.tar.gz" - end - - def test_imagemagick_versioned_bottle_style - assert_version_detected "6.7.5-7", "https://homebrew.bintray.com/bottles/imagemagick-6.7.5-7.lion.bottle.1.tar.gz" - end - - def test_dash_version_dash_style - assert_version_detected "3.4", "http://www.antlr.org/download/antlr-3.4-complete.jar" - end - - def test_jenkins_version_style - assert_version_detected "1.486", "http://mirrors.jenkins-ci.org/war/1.486/jenkins.war" - assert_version_detected "0.10.11", "https://github.com/hechoendrupal/DrupalConsole/releases/download/0.10.11/drupal.phar" - end - - def test_apache_version_style - assert_version_detected "1.2.0-rc2", "http://www.apache.org/dyn/closer.cgi?path=/cassandra/1.2.0/apache-cassandra-1.2.0-rc2-bin.tar.gz" - end - - def test_jpeg_style - assert_version_detected "8d", "http://www.ijg.org/files/jpegsrc.v8d.tar.gz" - end - - def test_version_ghc_style - assert_version_detected "7.0.4", "http://www.haskell.org/ghc/dist/7.0.4/ghc-7.0.4-x86_64-apple-darwin.tar.bz2" - assert_version_detected "7.0.4", "http://www.haskell.org/ghc/dist/7.0.4/ghc-7.0.4-i386-apple-darwin.tar.bz2" - end - - def test_pypy_version - assert_version_detected "1.4.1", "http://pypy.org/download/pypy-1.4.1-osx.tar.bz2" - end - - def test_openssl_version - assert_version_detected "0.9.8s", "http://www.openssl.org/source/openssl-0.9.8s.tar.gz" - end - - def test_xaw3d_version - assert_version_detected "1.5E", "ftp://ftp.visi.com/users/hawkeyd/X/Xaw3d-1.5E.tar.gz" - end - - def test_assimp_version - assert_version_detected "2.0.863", "http://downloads.sourceforge.net/project/assimp/assimp-2.0/assimp--2.0.863-sdk.zip" - end - - def test_cmucl_version - assert_version_detected "20c", "http://common-lisp.net/project/cmucl/downloads/release/20c/cmucl-20c-x86-darwin.tar.bz2" - end - - def test_fann_version - assert_version_detected "2.1.0beta", "http://downloads.sourceforge.net/project/fann/fann/2.1.0beta/fann-2.1.0beta.zip" - end - - def test_grads_version - assert_version_detected "2.0.1", "ftp://iges.org/grads/2.0/grads-2.0.1-bin-darwin9.8-intel.tar.gz" - end - - def test_haxe_version - assert_version_detected "2.08", "http://haxe.org/file/haxe-2.08-osx.tar.gz" - end - - def test_imap_version - assert_version_detected "2007f", "ftp://ftp.cac.washington.edu/imap/imap-2007f.tar.gz" - end - - def test_suite3270_version - assert_version_detected "3.3.12ga7", "http://downloads.sourceforge.net/project/x3270/x3270/3.3.12ga7/suite3270-3.3.12ga7-src.tgz" - end - - def test_wwwoffle_version - assert_version_detected "2.9h", "http://www.gedanken.demon.co.uk/download-wwwoffle/wwwoffle-2.9h.tgz" - end - - def test_synergy_version - assert_version_detected "1.3.6p2", "http://synergy.googlecode.com/files/synergy-1.3.6p2-MacOSX-Universal.zip" - end - - def test_fontforge_version - assert_version_detected "20120731", "http://downloads.sourceforge.net/project/fontforge/fontforge-source/fontforge_full-20120731-b.tar.bz2" - end - - def test_ezlupdate_version - assert_version_detected "2011.10", "https://github.com/downloads/ezsystems/ezpublish-legacy/ezpublish_community_project-2011.10-with_ezc.tar.bz2" - end - - def test_aespipe_version_style - assert_version_detected "2.4c", - "http://loop-aes.sourceforge.net/aespipe/aespipe-v2.4c.tar.bz2" - end - - def test_win_style - assert_version_detected "0.9.17", - "http://ftpmirror.gnu.org/libmicrohttpd/libmicrohttpd-0.9.17-w32.zip" - assert_version_detected "1.29", - "http://ftpmirror.gnu.org/libidn/libidn-1.29-win64.zip" - end - - def test_with_arch - assert_version_detected "4.0.18-1", - "http://ftpmirror.gnu.org/mtools/mtools-4.0.18-1.i686.rpm" - assert_version_detected "5.5.7-5", - "http://ftpmirror.gnu.org/autogen/autogen-5.5.7-5.i386.rpm" - assert_version_detected "2.8", - "http://ftpmirror.gnu.org/libtasn1/libtasn1-2.8-x86.zip" - assert_version_detected "2.8", - "http://ftpmirror.gnu.org/libtasn1/libtasn1-2.8-x64.zip" - assert_version_detected "4.0.18", - "http://ftpmirror.gnu.org/mtools/mtools_4.0.18_i386.deb" - end - - def test_opam_version - assert_version_detected "2.18.3", - "https://opam.ocaml.org/archives/lablgtk.2.18.3+opam.tar.gz" - assert_version_detected "1.9", - "https://opam.ocaml.org/archives/sha.1.9+opam.tar.gz" - assert_version_detected "0.99.2", - "https://opam.ocaml.org/archives/ppx_tools.0.99.2+opam.tar.gz" - assert_version_detected "1.0.2", - "https://opam.ocaml.org/archives/easy-format.1.0.2+opam.tar.gz" - end - - def test_no_extension_version - assert_version_detected "1.8.12", "https://waf.io/waf-1.8.12" - assert_version_detected "0.7.1", "https://codeload.github.com/gsamokovarov/jump/tar.gz/v0.7.1" - assert_version_detected "0.9.1234", "https://my.datomic.com/downloads/free/0.9.1234" - assert_version_detected "0.9", "https://my.datomic.com/downloads/free/0.9.1t34" - assert_version_detected "1.2.3", "https://my.datomic.com/downloads/free/1.2.3" - end - - def test_dash_separated_version - assert_version_detected "6-20151227", "ftp://gcc.gnu.org/pub/gcc/snapshots/6-20151227/gcc-6-20151227.tar.bz2" - end - - def test_from_url - assert_version_detected "1.2.3", - "http://github.com/foo/bar.git", tag: "v1.2.3" - end -end - -class HeadVersionTests < Homebrew::TestCase - def test_create_head - v1 = Version.create("HEAD-abcdef") - v2 = Version.create("HEAD") - - assert_predicate v1, :head? - assert_predicate v2, :head? - end - - def test_commit_assigned - v = Version.create("HEAD-abcdef") - assert_equal "abcdef", v.commit - assert_equal "HEAD-abcdef", v.to_str - end - - def test_no_commit - v = Version.create("HEAD") - assert_nil v.commit - assert_equal "HEAD", v.to_str - end - - def test_update_commit - v1 = Version.create("HEAD-abcdef") - v2 = Version.create("HEAD") - - v1.update_commit("ffffff") - assert_equal "ffffff", v1.commit - assert_equal "HEAD-ffffff", v1.to_str - - v2.update_commit("ffffff") - assert_equal "ffffff", v2.commit - assert_equal "HEAD-ffffff", v2.to_str - end -end
true
Other
Homebrew
brew
dda5d3ac0564cb491f9d55f2b0d2476d40ee1ee9.json
Convert DependencyCollector test to spec.
Library/Homebrew/test/dependency_collector_spec.rb
@@ -0,0 +1,137 @@ +require "dependency_collector" + +RSpec::Matchers.alias_matcher :be_a_build_requirement, :be_build + +describe DependencyCollector do + def find_dependency(name) + subject.deps.find { |dep| dep.name == name } + end + + def find_requirement(klass) + subject.requirements.find { |req| req.is_a? klass } + end + + after(:each) do + described_class.clear_cache + end + + describe "#add" do + specify "dependency creation" do + subject.add "foo" => :build + subject.add "bar" => ["--universal", :optional] + expect(find_dependency("foo")).to be_an_instance_of(Dependency) + expect(find_dependency("bar").tags.count).to eq(2) + end + + it "returns the created dependency" do + expect(subject.add("foo")).to eq(Dependency.new("foo")) + end + + specify "requirement creation" do + subject.add :x11 + expect(find_requirement(X11Requirement)).to be_an_instance_of(X11Requirement) + end + + it "deduplicates requirements" do + 2.times { subject.add :x11 } + expect(subject.requirements.count).to eq(1) + end + + specify "requirement tags" do + subject.add x11: "2.5.1" + subject.add xcode: :build + expect(find_requirement(X11Requirement).tags).to be_empty + expect(find_requirement(XcodeRequirement)).to be_a_build_requirement + end + + specify "x11 without tag" do + subject.add :x11 + expect(find_requirement(X11Requirement).tags).to be_empty + end + + specify "x11 with minimum version" do + subject.add x11: "2.5.1" + expect(find_requirement(X11Requirement).min_version.to_s).to eq("2.5.1") + end + + specify "x11 with tag" do + subject.add x11: :optional + expect(find_requirement(X11Requirement)).to be_optional + end + + specify "x11 with minimum version and tag" do + subject.add x11: ["2.5.1", :optional] + dep = find_requirement(X11Requirement) + expect(dep.min_version.to_s).to eq("2.5.1") + expect(dep).to be_optional + end + + specify "ant dependency" do + subject.add ant: :build + expect(find_dependency("ant")).to eq(Dependency.new("ant", [:build])) + end + + it "doesn't mutate the dependency spec" do + spec = { "foo" => :optional } + copy = spec.dup + subject.add(spec) + expect(spec).to eq(copy) + end + + it "creates a resource dependency from a '.git' URL" do + resource = Resource.new + resource.url("git://example.com/foo/bar.git") + expect(subject.add(resource)).to be_an_instance_of(GitRequirement) + end + + it "creates a resource dependency from a '.7z' URL" do + resource = Resource.new + resource.url("http://example.com/foo.7z") + expect(subject.add(resource)).to eq(Dependency.new("p7zip", [:build])) + end + + it "creates a resource dependency from a '.gz' URL" do + resource = Resource.new + resource.url("http://example.com/foo.tar.gz") + expect(subject.add(resource)).to be nil + end + + it "creates a resource dependency from a '.lz' URL" do + resource = Resource.new + resource.url("http://example.com/foo.lz") + expect(subject.add(resource)).to eq(Dependency.new("lzip", [:build])) + end + + it "creates a resource dependency from a '.lha' URL" do + resource = Resource.new + resource.url("http://example.com/foo.lha") + expect(subject.add(resource)).to eq(Dependency.new("lha", [:build])) + end + + it "creates a resource dependency from a '.lzh' URL" do + resource = Resource.new + resource.url("http://example.com/foo.lzh") + expect(subject.add(resource)).to eq(Dependency.new("lha", [:build])) + end + + it "creates a resource dependency from a '.rar' URL" do + resource = Resource.new + resource.url("http://example.com/foo.rar") + expect(subject.add(resource)).to eq(Dependency.new("unrar", [:build])) + end + + it "raises a TypeError for unknown classes" do + expect { subject.add(Class.new) }.to raise_error(TypeError) + end + + it "raises a TypeError for unknown Types" do + expect { subject.add(Object.new) }.to raise_error(TypeError) + end + + it "raises a TypeError for a Resource with an unknown download strategy" do + resource = Resource.new + resource.download_strategy = Class.new + expect { subject.add(resource) }.to raise_error(TypeError) + end + end +end
true
Other
Homebrew
brew
dda5d3ac0564cb491f9d55f2b0d2476d40ee1ee9.json
Convert DependencyCollector test to spec.
Library/Homebrew/test/dependency_collector_test.rb
@@ -1,148 +0,0 @@ -require "testing_env" -require "dependency_collector" - -class DependencyCollectorTests < Homebrew::TestCase - def find_dependency(name) - @d.deps.find { |dep| dep.name == name } - end - - def find_requirement(klass) - @d.requirements.find { |req| req.is_a? klass } - end - - def setup - super - @d = DependencyCollector.new - end - - def teardown - DependencyCollector.clear_cache - super - end - - def test_dependency_creation - @d.add "foo" => :build - @d.add "bar" => ["--universal", :optional] - assert_instance_of Dependency, find_dependency("foo") - assert_equal 2, find_dependency("bar").tags.length - end - - def test_add_returns_created_dep - ret = @d.add "foo" - assert_equal Dependency.new("foo"), ret - end - - def test_dependency_tags - assert_predicate Dependency.new("foo", [:build]), :build? - assert_predicate Dependency.new("foo", [:build, :optional]), :optional? - assert_includes Dependency.new("foo", ["universal"]).options, "--universal" - assert_empty Dependency.new("foo").tags - end - - def test_requirement_creation - @d.add :x11 - assert_instance_of X11Requirement, find_requirement(X11Requirement) - end - - def test_no_duplicate_requirements - 2.times { @d.add :x11 } - assert_equal 1, @d.requirements.count - end - - def test_requirement_tags - @d.add x11: "2.5.1" - @d.add xcode: :build - assert_empty find_requirement(X11Requirement).tags - assert_predicate find_requirement(XcodeRequirement), :build? - end - - def test_x11_no_tag - @d.add :x11 - assert_empty find_requirement(X11Requirement).tags - end - - def test_x11_min_version - @d.add x11: "2.5.1" - assert_equal "2.5.1", find_requirement(X11Requirement).min_version.to_s - end - - def test_x11_tag - @d.add x11: :optional - assert_predicate find_requirement(X11Requirement), :optional? - end - - def test_x11_min_version_and_tag - @d.add x11: ["2.5.1", :optional] - dep = find_requirement(X11Requirement) - assert_equal "2.5.1", dep.min_version.to_s - assert_predicate dep, :optional? - end - - def test_ant_dep - @d.add ant: :build - assert_equal find_dependency("ant"), Dependency.new("ant", [:build]) - end - - def test_raises_typeerror_for_unknown_classes - assert_raises(TypeError) { @d.add(Class.new) } - end - - def test_raises_typeerror_for_unknown_types - assert_raises(TypeError) { @d.add(Object.new) } - end - - def test_does_not_mutate_dependency_spec - spec = { "foo" => :optional } - copy = spec.dup - @d.add(spec) - assert_equal copy, spec - end - - def test_resource_dep_git_url - resource = Resource.new - resource.url("git://example.com/foo/bar.git") - assert_instance_of GitRequirement, @d.add(resource) - end - - def test_resource_dep_7z_url - resource = Resource.new - resource.url("http://example.com/foo.7z") - assert_equal Dependency.new("p7zip", [:build]), @d.add(resource) - end - - def test_resource_dep_gzip_url - resource = Resource.new - resource.url("http://example.com/foo.tar.gz") - assert_nil @d.add(resource) - end - - def test_resource_dep_lz_url - resource = Resource.new - resource.url("http://example.com/foo.lz") - assert_equal Dependency.new("lzip", [:build]), @d.add(resource) - end - - def test_resource_dep_lha_url - resource = Resource.new - resource.url("http://example.com/foo.lha") - assert_equal Dependency.new("lha", [:build]), @d.add(resource) - end - - def test_resource_dep_lzh_url - resource = Resource.new - resource.url("http://example.com/foo.lzh") - assert_equal Dependency.new("lha", [:build]), @d.add(resource) - end - - def test_resource_dep_rar_url - resource = Resource.new - resource.url("http://example.com/foo.rar") - assert_equal Dependency.new("unrar", [:build]), @d.add(resource) - end - - def test_resource_dep_raises_for_unknown_classes - resource = Resource.new - resource.download_strategy = Class.new - assert_raises(TypeError) { @d.add(resource) } - end -end
true
Other
Homebrew
brew
3abfdc9e8012fb7d36010237323a054306a1ea83.json
Convert Dependency test to spec.
Library/Homebrew/test/dependable_spec.rb
@@ -0,0 +1,24 @@ +require "dependable" + +RSpec::Matchers.alias_matcher :be_a_build_dependency, :be_build + +describe Dependable do + subject { double(tags: tags).extend(described_class) } + let(:tags) { ["foo", "bar", :build] } + + specify "#options" do + expect(subject.options.as_flags.sort).to eq(%w[--foo --bar].sort) + end + + specify "#build?" do + expect(subject).to be_a_build_dependency + end + + specify "#optional?" do + expect(subject).not_to be_optional + end + + specify "#recommended?" do + expect(subject).not_to be_recommended + end +end
true
Other
Homebrew
brew
3abfdc9e8012fb7d36010237323a054306a1ea83.json
Convert Dependency test to spec.
Library/Homebrew/test/dependency_spec.rb
@@ -0,0 +1,121 @@ +require "dependency" + +RSpec::Matchers.alias_matcher :be_a_build_dependency, :be_build +RSpec::Matchers.alias_matcher :be_a_runtime_dependency, :be_run + +describe Dependency do + describe "::new" do + it "accepts a single tag" do + dep = described_class.new("foo", %w[bar]) + expect(dep.tags).to eq(%w[bar]) + end + + it "accepts multiple tags" do + dep = described_class.new("foo", %w[bar baz]) + expect(dep.tags.sort).to eq(%w[bar baz].sort) + end + + it "preserves symbol tags" do + dep = described_class.new("foo", [:build]) + expect(dep.tags).to eq([:build]) + end + + it "accepts symbol and string tags" do + dep = described_class.new("foo", [:build, "bar"]) + expect(dep.tags).to eq([:build, "bar"]) + end + end + + describe "::merge_repeats" do + it "merges duplicate dependencies" do + dep = described_class.new("foo", [:build], nil, "foo") + dep2 = described_class.new("foo", ["bar"], nil, "foo2") + dep3 = described_class.new("xyz", ["abc"], nil, "foo") + merged = described_class.merge_repeats([dep, dep2, dep3]) + expect(merged.count).to eq(2) + expect(merged.first).to be_a described_class + + foo_named_dep = merged.find { |d| d.name == "foo" } + expect(foo_named_dep.tags).to eq(["bar"]) + expect(foo_named_dep.option_names).to include("foo") + expect(foo_named_dep.option_names).to include("foo2") + + xyz_named_dep = merged.find { |d| d.name == "xyz" } + expect(xyz_named_dep.tags).to eq(["abc"]) + expect(xyz_named_dep.option_names).to include("foo") + expect(xyz_named_dep.option_names).not_to include("foo2") + end + + it "merges necessity tags" do + required_dep = described_class.new("foo") + recommended_dep = described_class.new("foo", [:recommended]) + optional_dep = described_class.new("foo", [:optional]) + + deps = described_class.merge_repeats([required_dep, recommended_dep]) + expect(deps.count).to eq(1) + expect(deps.first).to be_required + expect(deps.first).not_to be_recommended + expect(deps.first).not_to be_optional + + deps = described_class.merge_repeats([required_dep, optional_dep]) + expect(deps.count).to eq(1) + expect(deps.first).to be_required + expect(deps.first).not_to be_recommended + expect(deps.first).not_to be_optional + + deps = described_class.merge_repeats([recommended_dep, optional_dep]) + expect(deps.count).to eq(1) + expect(deps.first).not_to be_required + expect(deps.first).to be_recommended + expect(deps.first).not_to be_optional + end + + it "merges temporality tags" do + normal_dep = described_class.new("foo") + build_dep = described_class.new("foo", [:build]) + run_dep = described_class.new("foo", [:run]) + + deps = described_class.merge_repeats([normal_dep, build_dep]) + expect(deps.count).to eq(1) + expect(deps.first).not_to be_a_build_dependency + expect(deps.first).not_to be_a_runtime_dependency + + deps = described_class.merge_repeats([normal_dep, run_dep]) + expect(deps.count).to eq(1) + expect(deps.first).not_to be_a_build_dependency + expect(deps.first).not_to be_a_runtime_dependency + + deps = described_class.merge_repeats([build_dep, run_dep]) + expect(deps.count).to eq(1) + expect(deps.first).not_to be_a_build_dependency + expect(deps.first).not_to be_a_runtime_dependency + end + end + + specify "equality" do + foo1 = described_class.new("foo") + foo2 = described_class.new("foo") + expect(foo1).to eq(foo2) + expect(foo1).to eql(foo2) + + bar = described_class.new("bar") + expect(foo1).not_to eq(bar) + expect(foo1).not_to eql(bar) + + foo3 = described_class.new("foo", [:build]) + expect(foo1).not_to eq(foo3) + expect(foo1).not_to eql(foo3) + end +end + +describe TapDependency do + subject { described_class.new("foo/bar/dog") } + + specify "#tap" do + expect(subject.tap).to eq(Tap.new("foo", "bar")) + end + + specify "#option_names" do + expect(subject.option_names).to eq(%w[dog]) + end +end
true