Skip to content

Commit

Permalink
✨ Adds Elixir and Gleam as languages (#4408)
Browse files Browse the repository at this point in the history
* Add Elixir as a language

Signed-off-by: Kiko Fernandez-Reyes <[email protected]>

* Adds Gleam as a language

Signed-off-by: Kiko Fernandez-Reyes <[email protected]>

* fixes typo in client

Co-authored-by: Bram Verburg <[email protected]>
Signed-off-by: Kiko Fernandez-Reyes <[email protected]>

* fix tests

Signed-off-by: Kiko Fernandez-Reyes <[email protected]>

---------

Signed-off-by: Kiko Fernandez-Reyes <[email protected]>
Signed-off-by: Kiko Fernandez-Reyes <[email protected]>
Co-authored-by: Bram Verburg <[email protected]>
  • Loading branch information
kikofernandez and voltone authored Nov 15, 2024
1 parent fee8bcf commit 390e7e4
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 1 deletion.
18 changes: 18 additions & 0 deletions checks/raw/fuzzing.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,24 @@ var languageFuzzSpecs = map[clients.LanguageName]languageFuzzConfig{
Name: fuzzers.PropertyBasedHaskell,
Desc: propertyBasedDescription("Haskell"),
},

// Fuzz patterns for Elixir based on property-based testing.
clients.Elixir: {
filePatterns: []string{"*.ex", "*.exs"},
// Look for direct imports of PropCheck, and StreamData.
funcPattern: `use\s+(PropCheck|ExUnitProperties)`,
Name: fuzzers.PropertyBasedElixir,
Desc: propertyBasedDescription("Elixir"),
},

// Fuzz patterns for Gleam based on property-based testing.
clients.Gleam: {
filePatterns: []string{"*.gleam"},
// Look for direct imports of PropCheck, and StreamData.
funcPattern: `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
61 changes: 60 additions & 1 deletion checks/raw/fuzzing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ func Test_checkFuzzFunc(t *testing.T) {
name: "Erlang with no property-based testing",
want: false,
fileName: []string{"erlang-ct.erl"},
wantErr: true,
langs: []clients.Language{
{
Name: clients.Erlang,
Expand Down Expand Up @@ -394,6 +393,66 @@ func Test_checkFuzzFunc(t *testing.T) {
},
fileContent: "import Test.Hspec",
},
{
name: "Elixir QuickCheck through PropCheck",
want: true,
fileName: []string{"Test.exs"},
langs: []clients.Language{
{
Name: clients.Elixir,
NumLines: 50,
},
},
fileContent: "use PropCheck, default_opts: &PropCheck.TestHelpers.config/0",
},
{
name: "Elixir QuickCheck through StreamData",
want: true,
fileName: []string{"Test.exs"},
langs: []clients.Language{
{
Name: clients.Elixir,
NumLines: 50,
},
},
fileContent: "use ExUnitProperties",
},
{
name: "Elixir with no property-based testing",
want: false,
fileName: []string{"NoPropTest.exs"},
langs: []clients.Language{
{
Name: clients.Elixir,
NumLines: 50,
},
},
fileContent: "use ExUnit.Case, async: true",
},
{
name: "Gleam with no property-based testing",
want: false,
fileName: []string{"test.gleam"},
langs: []clients.Language{
{
Name: clients.Gleam,
NumLines: 50,
},
},
fileContent: "import gleeunit",
},
{
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
6 changes: 6 additions & 0 deletions clients/languages.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ const (
// Haskell: https://www.haskell.org/
Haskell LanguageName = "haskell"

// 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
2 changes: 2 additions & 0 deletions internal/fuzzers/fuzzers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const (
BuiltInGo = "GoBuiltInFuzzer"
PropertyBasedErlang = "ErlangPropertyBasedTesting"
PropertyBasedHaskell = "HaskellPropertyBasedTesting"
PropertyBasedElixir = "ElixirPropertyBasedTesting"
PropertyBasedGleam = "GleamPropertyBasedTesting"
PropertyBasedJavaScript = "JavaScriptPropertyBasedTesting"
PropertyBasedTypeScript = "TypeScriptPropertyBasedTesting"
PythonAtheris = "PythonAtherisFuzzer"
Expand Down

0 comments on commit 390e7e4

Please sign in to comment.