| 
									
										
										
										
											2010-02-18 11:40:59 -08:00
										 |  |  | require 'testing_env' | 
					
						
							|  |  |  | require 'formula' | 
					
						
							| 
									
										
										
										
											2010-03-02 22:54:12 -08:00
										 |  |  | require 'test/testball' | 
					
						
							| 
									
										
										
										
											2010-02-18 11:40:59 -08:00
										 |  |  | require 'keg' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-18 20:32:51 -05:00
										 |  |  | class InstallTests < Homebrew::TestCase | 
					
						
							| 
									
										
										
										
											2010-02-18 11:40:59 -08:00
										 |  |  |   def temporary_install f | 
					
						
							| 
									
										
										
										
											2014-06-12 21:33:55 -05:00
										 |  |  |     f.prefix.mkpath | 
					
						
							|  |  |  |     keg = Keg.new(f.prefix) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-01 12:15:29 -05:00
										 |  |  |     shutup do | 
					
						
							| 
									
										
										
										
											2010-02-18 11:40:59 -08:00
										 |  |  |       f.brew { f.install } | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-12 21:33:55 -05:00
										 |  |  |     begin | 
					
						
							|  |  |  |       yield | 
					
						
							|  |  |  |     ensure | 
					
						
							|  |  |  |       keg.unlink | 
					
						
							|  |  |  |       keg.uninstall | 
					
						
							| 
									
										
										
										
											2014-06-23 21:26:08 -05:00
										 |  |  |       f.clear_cache | 
					
						
							| 
									
										
										
										
											2014-06-12 21:33:55 -05:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2012-06-20 00:51:01 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-11 12:21:03 -05:00
										 |  |  |     refute_predicate keg, :exist? | 
					
						
							|  |  |  |     refute_predicate f, :installed? | 
					
						
							| 
									
										
										
										
											2010-02-18 11:40:59 -08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_a_basic_install | 
					
						
							| 
									
										
										
										
											2014-06-23 21:26:08 -05:00
										 |  |  |     f = TestBall.new | 
					
						
							| 
									
										
										
										
											2012-06-20 00:51:01 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-11 12:21:03 -05:00
										 |  |  |     refute_predicate f, :installed? | 
					
						
							| 
									
										
										
										
											2012-06-20 00:51:01 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-18 11:40:59 -08:00
										 |  |  |     temporary_install f do | 
					
						
							|  |  |  |       # Test that things made it into the Keg | 
					
						
							| 
									
										
										
										
											2014-06-11 12:21:03 -05:00
										 |  |  |       assert_predicate f.bin, :directory? | 
					
						
							| 
									
										
										
										
											2010-02-18 11:40:59 -08:00
										 |  |  |       assert_equal 3, f.bin.children.length | 
					
						
							| 
									
										
										
										
											2014-06-11 12:21:03 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |       libexec = f.prefix+'libexec' | 
					
						
							|  |  |  |       assert_predicate libexec, :directory? | 
					
						
							| 
									
										
										
										
											2010-02-18 11:40:59 -08:00
										 |  |  |       assert_equal 1, libexec.children.length | 
					
						
							| 
									
										
										
										
											2014-06-11 12:21:03 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |       refute_predicate f.prefix+'main.c', :exist? | 
					
						
							|  |  |  |       assert_predicate f, :installed? | 
					
						
							| 
									
										
										
										
											2012-06-20 00:51:01 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-18 11:40:59 -08:00
										 |  |  |       # Test that things make it into the Cellar | 
					
						
							| 
									
										
										
										
											2014-06-11 12:21:03 -05:00
										 |  |  |       keg = Keg.new f.prefix | 
					
						
							| 
									
										
										
										
											2010-02-18 11:40:59 -08:00
										 |  |  |       keg.link | 
					
						
							| 
									
										
										
										
											2012-08-29 15:37:58 -05:00
										 |  |  |       assert_equal 3, HOMEBREW_PREFIX.children.length | 
					
						
							| 
									
										
										
										
											2014-06-11 12:21:03 -05:00
										 |  |  |       assert_predicate HOMEBREW_PREFIX+'bin', :directory? | 
					
						
							| 
									
										
										
										
											2010-02-18 11:40:59 -08:00
										 |  |  |       assert_equal 3, (HOMEBREW_PREFIX+'bin').children.length | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2012-06-20 00:51:01 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-18 11:40:59 -08:00
										 |  |  |   def test_script_install | 
					
						
							| 
									
										
										
										
											2014-06-12 17:58:12 -05:00
										 |  |  |     f = Class.new(ScriptFileFormula) do | 
					
						
							| 
									
										
										
										
											2014-06-12 18:14:48 -05:00
										 |  |  |       url "file://#{File.expand_path(__FILE__)}" | 
					
						
							| 
									
										
										
										
											2014-06-12 17:58:12 -05:00
										 |  |  |       version "1" | 
					
						
							|  |  |  |       def initialize | 
					
						
							| 
									
										
										
										
											2014-06-19 21:35:46 -05:00
										 |  |  |         super "test_script_formula", Pathname.new(__FILE__).expand_path, :stable | 
					
						
							| 
									
										
										
										
											2014-06-12 17:58:12 -05:00
										 |  |  |       end | 
					
						
							|  |  |  |     end.new | 
					
						
							| 
									
										
										
										
											2012-06-20 00:51:01 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-12 21:31:51 -05:00
										 |  |  |     temporary_install(f) { assert_equal 1, f.bin.children.length } | 
					
						
							| 
									
										
										
										
											2010-02-18 11:40:59 -08:00
										 |  |  |   end | 
					
						
							|  |  |  | end |