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 3 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
20 changes: 20 additions & 0 deletions checks/raw/fuzzing.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,26 @@ 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{"*.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
110 changes: 110 additions & 0 deletions checks/raw/fuzzing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,116 @@ 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.Elixir,
NumLines: 50,
},
},
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
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