refactoring testball
This commit is contained in:
		
							parent
							
								
									4651b961fa
								
							
						
					
					
						commit
						e5e647d950
					
				| @ -134,65 +134,37 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin | ||||
|                          bottle_block: nil, tab_attributes: nil) | ||||
|     case name | ||||
|     when /^testball/ | ||||
|       if name == "testball5" || name == "testball4" | ||||
|         tarball = if OS.linux? | ||||
|                     TEST_FIXTURE_DIR/"tarballs/#{name}-0.1-linux.tbz" | ||||
|                   else | ||||
|                     TEST_FIXTURE_DIR/"tarballs/#{name}-0.1.tbz" | ||||
|                   end | ||||
|         content = <<~RUBY | ||||
|         desc "Some test" | ||||
|         homepage "https://brew.sh/#{name}" | ||||
|         url "file://#{tarball}" | ||||
|         sha256 "#{tarball.sha256}" | ||||
| 
 | ||||
|         option "with-foo", "Build with foo" | ||||
|         #{bottle_block} | ||||
|         def install | ||||
|           STDERR.puts prefix | ||||
|           (prefix/"foo"/"#{name}").write("#{name}") if build.with? "foo" | ||||
|           prefix.install Dir["*"] | ||||
|           (buildpath/"#{name}.c").write \ | ||||
|             "#include <stdio.h>\\nint main(){printf(\\"#{name}\\");return 0;}" | ||||
|           bin.mkpath | ||||
|           system ENV.cc, "#{name}.c", "-o", bin/"#{name}" | ||||
|         end | ||||
| 
 | ||||
|         #{content} | ||||
| 
 | ||||
|         # something here | ||||
|         RUBY | ||||
|       case name | ||||
|       when "testball4", "testball5", "testball2" | ||||
|         prefix = name | ||||
|       else | ||||
|         # Use a different tarball for testball2 to avoid lock errors when writing concurrency tests | ||||
|         prefix = (name == "testball2") ? "testball2" : "testball" | ||||
|         tarball = if OS.linux? | ||||
|                     TEST_FIXTURE_DIR/"tarballs/#{prefix}-0.1-linux.tbz" | ||||
|                   else | ||||
|                     TEST_FIXTURE_DIR/"tarballs/#{prefix}-0.1.tbz" | ||||
|                   end | ||||
| 
 | ||||
|         content = <<~RUBY | ||||
|         desc "Some test" | ||||
|         homepage "https://brew.sh/#{name}" | ||||
|         url "file://#{tarball}" | ||||
|         sha256 "#{tarball.sha256}" | ||||
| 
 | ||||
|         option "with-foo", "Build with foo" | ||||
|         #{bottle_block} | ||||
|         def install | ||||
|           (prefix/"foo"/"test").write("test") if build.with? "foo" | ||||
|           prefix.install Dir["*"] | ||||
|           (buildpath/"test.c").write \ | ||||
|             "#include <stdio.h>\\nint main(){printf(\\"test\\");return 0;}" | ||||
|           bin.mkpath | ||||
|           system ENV.cc, "test.c", "-o", bin/"test" | ||||
|         end | ||||
| 
 | ||||
|         #{content} | ||||
| 
 | ||||
|         # something here | ||||
|         RUBY | ||||
|         prefix = "testball" | ||||
|       end | ||||
|       tarball_name = "#{prefix}-0.1#{'-linux' if OS.linux?}.tbz" | ||||
|       tarball = TEST_FIXTURE_DIR/"tarballs/#{tarball_name}" | ||||
| 
 | ||||
|       content = <<~RUBY | ||||
|     desc "Some test" | ||||
|     homepage "https://brew.sh/#{name}" | ||||
|     url "file://#{tarball}" | ||||
|     sha256 "#{tarball.sha256}" | ||||
| 
 | ||||
|     option "with-foo", "Build with foo" | ||||
|     #{bottle_block} | ||||
| 
 | ||||
|     def install | ||||
|       (prefix/"foo"/"#{prefix}").write("#{prefix}") if build.with? "foo" | ||||
|       prefix.install Dir["*"] | ||||
|       (buildpath/"#{prefix}.c").write \\ | ||||
|         "#include <stdio.h>\\nint main(){printf(\\"#{prefix}\\");return 0;}" | ||||
|       bin.mkpath | ||||
|       system ENV.cc, "#{prefix}.c", "-o", bin/"#{prefix}" | ||||
|     end | ||||
| 
 | ||||
|     #{content} | ||||
| 
 | ||||
|     # something here | ||||
|     RUBY | ||||
|     when "bar" | ||||
|       content = <<~RUBY | ||||
|         url "https://brew.sh/#{name}-1.0" | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 thibhero
						thibhero