diff --git a/checks/raw/fuzzing.go b/checks/raw/fuzzing.go index 93094d0739f..9ae228cc1e1 100644 --- a/checks/raw/fuzzing.go +++ b/checks/raw/fuzzing.go @@ -86,6 +86,17 @@ var languageFuzzSpecs = map[clients.LanguageName]languageFuzzConfig{ Name: fuzzers.PropertyBasedElixir, Desc: propertyBasedDescription("Elixir"), }, + + // Fuzz patterns for Gleam based on property-based testing. + clients.Gleam: { + filePatterns: []string{"*.ex", "*.exs", "*.erl", "*.hrl"}, + // Look for direct imports of PropCheck, and StreamData. + funcPattern: `(use\s+(PropCheck|ExUnitProperties)|` + // Elixir libraries + `-include_lib\("(eqc|proper)/include/(eqc|proper).hrl"\)\.|` + // Erlang libraries + `import\s+qcheck)`, // Gleam library + Name: fuzzers.PropertyBasedGleam, + Desc: propertyBasedDescription("Gleam"), + }, // Fuzz patterns for JavaScript and TypeScript based on property-based testing. // // Based on the import of one of these packages: diff --git a/checks/raw/fuzzing_test.go b/checks/raw/fuzzing_test.go index 40378f652a0..bb5d60dc1ba 100644 --- a/checks/raw/fuzzing_test.go +++ b/checks/raw/fuzzing_test.go @@ -394,6 +394,79 @@ func Test_checkFuzzFunc(t *testing.T) { }, fileContent: "use ExUnit.Case, async: true", }, + { + name: "Gleam QuickCheck through Erlang", + want: true, + fileName: []string{"gleam-erlang-eqc.erl"}, + langs: []clients.Language{ + { + Name: clients.Gleam, + NumLines: 50, + }, + }, + fileContent: "-include_lib(\"eqc/include/eqc.hrl\").", + }, + { + name: "Gleam Proper through Erlang", + want: true, + fileName: []string{"gleam-erlang-proper.erl"}, + langs: []clients.Language{ + { + Name: clients.Gleam, + NumLines: 50, + }, + }, + fileContent: "-include_lib(\"proper/include/proper.hrl\").", + }, + { + name: "Gleam with no property-based testing", + want: false, + fileName: []string{"test.gleam"}, + wantErr: true, + langs: []clients.Language{ + { + Name: clients.Gleam, + NumLines: 50, + }, + }, + fileContent: "import gleeunit", + }, + { + name: "Gleam QuickCheck through StreamData", + want: true, + fileName: []string{"gleam-elixir-streamdata.exs"}, + langs: []clients.Language{ + { + Name: clients.Gleam, + NumLines: 50, + }, + }, + fileContent: "use ExUnitProperties", + }, + { + name: "Gleam Proper through Elixir", + want: true, + fileName: []string{"gleam-elixir-proper.exs"}, + langs: []clients.Language{ + { + Name: clients.Gleam, + NumLines: 50, + }, + }, + fileContent: "use PropCheck", + }, + { + name: "Gleam QCheck", + want: true, + fileName: []string{"gleam-qcheck.gleam"}, + langs: []clients.Language{ + { + Name: clients.Gleam, + NumLines: 50, + }, + }, + fileContent: "import qcheck", + }, { name: "JavaScript fast-check via require", want: true, diff --git a/clients/languages.go b/clients/languages.go index 78c877395f8..784faa20793 100644 --- a/clients/languages.go +++ b/clients/languages.go @@ -80,6 +80,9 @@ const ( // Elixir: https://www.elixir.org/ Elixir LanguageName = "elixir" + // Gleam: https://www.gleam.org/ + Gleam LanguageName = "gleam" + // Other indicates other languages not listed by the GitHub API. Other LanguageName = "other" diff --git a/internal/fuzzers/fuzzers.go b/internal/fuzzers/fuzzers.go index d7f3577f667..7dafbf2ee08 100644 --- a/internal/fuzzers/fuzzers.go +++ b/internal/fuzzers/fuzzers.go @@ -21,6 +21,7 @@ const ( BuiltInGo = "GoBuiltInFuzzer" PropertyBasedHaskell = "HaskellPropertyBasedTesting" PropertyBasedElixir = "ElixirPropertyBasedTesting" + PropertyBasedGleam = "GleamPropertyBasedTesting" PropertyBasedJavaScript = "JavaScriptPropertyBasedTesting" PropertyBasedTypeScript = "TypeScriptPropertyBasedTesting" PythonAtheris = "PythonAtherisFuzzer"