Skip to content

Commit

Permalink
Add Elixir 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 12, 2024
1 parent fee8bcf commit 68d69a0
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
9 changes: 9 additions & 0 deletions checks/raw/fuzzing.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ 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 JavaScript and TypeScript based on property-based testing.
//
// Based on the import of one of these packages:
Expand Down
37 changes: 37 additions & 0 deletions checks/raw/fuzzing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,43 @@ 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"},
wantErr: true,
langs: []clients.Language{
{
Name: clients.Haskell,
NumLines: 50,
},
},
fileContent: "use ExUnit.Case, async: true",
},
{
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 @@ -80,6 +80,9 @@ const (
// Haskell: https://www.haskell.org/
Haskell LanguageName = "haskell"

// Elixir: https://www.elixir.org/
Elixir LanguageName = "elixir"

// 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 @@ -21,6 +21,7 @@ const (
BuiltInGo = "GoBuiltInFuzzer"
PropertyBasedErlang = "ErlangPropertyBasedTesting"
PropertyBasedHaskell = "HaskellPropertyBasedTesting"
PropertyBasedElixir = "ElixirPropertyBasedTesting"
PropertyBasedJavaScript = "JavaScriptPropertyBasedTesting"
PropertyBasedTypeScript = "TypeScriptPropertyBasedTesting"
PythonAtheris = "PythonAtherisFuzzer"
Expand Down

0 comments on commit 68d69a0

Please sign in to comment.