You've already forked goreleaser
							
							
				mirror of
				https://github.com/goreleaser/goreleaser.git
				synced 2025-10-30 23:58:09 +02:00 
			
		
		
		
	test: fuzz
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
		| @@ -47,10 +47,15 @@ tasks: | ||||
|     cmds: | ||||
|       - scripts/fuzz.sh ./internal/tmpl 30s | ||||
|  | ||||
|   fuzz:artifact: | ||||
|     cmds: | ||||
|       - scripts/fuzz.sh ./internal/artifact 30s | ||||
|  | ||||
|   fuzz: | ||||
|     desc: Run fuzz tests | ||||
|   cmds: | ||||
|     - task: fuzz:tmpl | ||||
|     - task: fuzz:artifact | ||||
|  | ||||
|   test:golden:update: | ||||
|     desc: Run all tests that write goldne files, updating the files. | ||||
|   | ||||
| @@ -4,7 +4,6 @@ import ( | ||||
| 	"crypto/rand" | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
| 	"strings" | ||||
| 	"testing" | ||||
| ) | ||||
|  | ||||
| @@ -36,11 +35,9 @@ func FuzzChecksum(f *testing.F) { | ||||
| 			"blake2s":    true, | ||||
| 			"sha224":     true, | ||||
| 			"sha384":     true, | ||||
| 			"sha3-256":   true, | ||||
| 			"sha3-512":   true, | ||||
| 			"sha3-224":   true, | ||||
| 			"sha3-384":   true, | ||||
| 			"sha3-256":   true, | ||||
| 			"sha3-384":   true, | ||||
| 			"sha3-512":   true, | ||||
| 		} | ||||
| 		 | ||||
| @@ -81,6 +78,28 @@ func FuzzChecksumLargeData(f *testing.F) { | ||||
| 			t.Skip() | ||||
| 		} | ||||
| 		 | ||||
| 		// Skip invalid algorithms | ||||
| 		validAlgorithms := map[string]bool{ | ||||
| 			"sha256":     true, | ||||
| 			"md5":        true, | ||||
| 			"sha1":       true, | ||||
| 			"crc32":      true, | ||||
| 			"sha512":     true, | ||||
| 			"blake2b":    true, | ||||
| 			"blake2s":    true, | ||||
| 			"sha224":     true, | ||||
| 			"sha384":     true, | ||||
| 			"sha3-224":   true, | ||||
| 			"sha3-256":   true, | ||||
| 			"sha3-384":   true, | ||||
| 			"sha3-512":   true, | ||||
| 		} | ||||
| 		 | ||||
| 		// Only test with valid algorithms to avoid expected errors | ||||
| 		if !validAlgorithms[algorithm] { | ||||
| 			t.Skip() | ||||
| 		} | ||||
| 		 | ||||
| 		// Generate random data of specified size | ||||
| 		data := make([]byte, size) | ||||
| 		if _, err := rand.Read(data); err != nil { | ||||
|   | ||||
							
								
								
									
										3
									
								
								internal/artifact/testdata/fuzz/FuzzChecksumLargeData/9f2a0bc58229b2e8
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								internal/artifact/testdata/fuzz/FuzzChecksumLargeData/9f2a0bc58229b2e8
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| go test fuzz v1 | ||||
| string("0") | ||||
| int(50000) | ||||
| @@ -1,10 +1,11 @@ | ||||
| #!/bin/bash | ||||
| pkg="$1" | ||||
| timeout="$1" | ||||
| timeout="$2" | ||||
|  | ||||
| grep "func Fuzz" "$pkg" | | ||||
| 	cut -f1 -d'(' | | ||||
| grep "func Fuzz" "$pkg"/*.go | | ||||
| 	cut -f2 -d' ' | | ||||
| 	cut -f1 -d'(' | | ||||
| 	while read -r f; do | ||||
| 		go test -fuzztime="$timeout" -fuzz="$f" "$pkg"/... | ||||
| 	done | ||||
| go test "$pkg"/... | ||||
|   | ||||
		Reference in New Issue
	
	Block a user