Skip to content

Commit

Permalink
Adds Gleam as a language
Browse files Browse the repository at this point in the history
Signed-off-by: Kiko Fernandez-Reyes <[email protected]>
  • Loading branch information
kikofernandez committed Nov 11, 2024
1 parent 1c453f4 commit f2548b4
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
11 changes: 11 additions & 0 deletions checks/raw/fuzzing.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,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:
Expand Down
73 changes: 73 additions & 0 deletions checks/raw/fuzzing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,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,
Expand Down
3 changes: 3 additions & 0 deletions clients/languages.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,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"

Expand Down
1 change: 1 addition & 0 deletions internal/fuzzers/fuzzers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const (
PropertyBasedErlang = "ErlangPropertyBasedTesting"
PropertyBasedHaskell = "HaskellPropertyBasedTesting"
PropertyBasedElixir = "ElixirPropertyBasedTesting"
PropertyBasedGleam = "GleamPropertyBasedTesting"
PropertyBasedJavaScript = "JavaScriptPropertyBasedTesting"
PropertyBasedTypeScript = "TypeScriptPropertyBasedTesting"
PythonAtheris = "PythonAtherisFuzzer"
Expand Down

0 comments on commit f2548b4

Please sign in to comment.