Improved formula attribute validation
The initializer for Formula does a number of validations, but it does them in a weird order, and some attributes aren't validated under certain circumstances. This became even more of a mess when most software package attributes were moved into the SoftwareSpec class. This commit removes the last vestiges of storing these attributes as instance variables. In particular, it eliminates #set_instance_variable and #validate_variable, replacing them with methods that operate on SoftwareSpec instances, and generate more useful errors. Doing these validations unconditionally in the initializer means we bail out much earlier if the formula has invalid attributes or is not fully specified, and no longer need to validate in #prefix. Technically we don't need to validate in #brew either, but we continue to do so anyway as a safety measure, and because we cannot enforce calls to super in subclasses.
Showing
- Library/Homebrew/exceptions.rb 11 additions, 0 deletionsLibrary/Homebrew/exceptions.rb
- Library/Homebrew/formula.rb 64 additions, 65 deletionsLibrary/Homebrew/formula.rb
- Library/Homebrew/formula_specialties.rb 3 additions, 4 deletionsLibrary/Homebrew/formula_specialties.rb
- Library/Homebrew/test/test_formula.rb 1 addition, 18 deletionsLibrary/Homebrew/test/test_formula.rb
- Library/Homebrew/test/test_formula_validation.rb 69 additions, 0 deletionsLibrary/Homebrew/test/test_formula_validation.rb
- Library/Homebrew/test/test_versions.rb 0 additions, 8 deletionsLibrary/Homebrew/test/test_versions.rb
Loading
Please register or sign in to comment