Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Adds Elixir and Gleam as languages #4408

Merged
merged 4 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading