Skip to content

Commit

Permalink
✨ Add Erlang as a language (#4406)
Browse files Browse the repository at this point in the history
Signed-off-by: Kiko Fernandez-Reyes <[email protected]>
  • Loading branch information
kikofernandez authored Nov 10, 2024
1 parent 2f6a76c commit 965d15b
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
8 changes: 8 additions & 0 deletions checks/raw/fuzzing.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ var languageFuzzSpecs = map[clients.LanguageName]languageFuzzConfig{
Desc: asPointer(
"Go fuzzing intelligently walks through the source code to report failures and find vulnerabilities."),
},
// Fuzz patterns for Erlang based on property-based testing.
clients.Erlang: {
filePatterns: []string{"*.erl", "*.hrl"},
// Look for direct imports of QuickCheck or Proper,
funcPattern: `-include_lib\("(eqc|proper)/include/(eqc|proper).hrl"\)\.`,
Name: fuzzers.PropertyBasedErlang,
Desc: propertyBasedDescription("Erlang"),
},
// Fuzz patterns for Haskell 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 @@ -260,6 +260,43 @@ func Test_checkFuzzFunc(t *testing.T) {
},
fileContent: "func TestFoo (t *testing.T)",
},
{
name: "Erlang QuickCheck",
want: true,
fileName: []string{"erlang-eqc.hs"},
langs: []clients.Language{
{
Name: clients.Erlang,
NumLines: 50,
},
},
fileContent: "-include_lib(\"eqc/include/eqc.hrl\").",
},
{
name: "Erlang Proper",
want: true,
fileName: []string{"erlang-proper.hs"},
langs: []clients.Language{
{
Name: clients.Erlang,
NumLines: 50,
},
},
fileContent: "-include_lib(\"proper/include/proper.hrl\").",
},
{
name: "Erlang with no property-based testing",
want: false,
fileName: []string{"erlang-ct.erl"},
wantErr: true,
langs: []clients.Language{
{
Name: clients.Erlang,
NumLines: 50,
},
},
fileContent: "-include_lib(\"common_test/include/ct.hrl\").",
},
{
name: "Haskell QuickCheck",
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 @@ -74,6 +74,9 @@ const (
// Dockerfile: https://docs.docker.com/engine/reference/builder/
Dockerfile LanguageName = "dockerfile"

// Erlang: https://www.erlang.org/
Erlang LanguageName = "erlang"

// Haskell: https://www.haskell.org/
Haskell LanguageName = "haskell"

Expand Down
1 change: 1 addition & 0 deletions docs/checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ This check tries to determine if the project uses
- currently only supports [Go fuzzing](https://go.dev/doc/fuzz/),
- a limited set of property-based testing libraries for Haskell including [QuickCheck](https://hackage.haskell.org/package/QuickCheck), [Hedgehog](https://hedgehog.qa/), [validity](https://hackage.haskell.org/package/validity) or [SmallCheck](https://hackage.haskell.org/package/smallcheck),
- a limited set of property-based testing libraries for JavaScript and TypeScript including [fast-check](https://fast-check.dev/).
- a limited set of property-based testing libraries for Erlang, including proper and quickcheck.

Fuzzing, or fuzz testing, is the practice of feeding unexpected or random data
into a program to expose bugs. Regular fuzzing is important to detect
Expand Down
1 change: 1 addition & 0 deletions docs/checks/internal/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ checks:
- currently only supports [Go fuzzing](https://go.dev/doc/fuzz/),
- a limited set of property-based testing libraries for Haskell including [QuickCheck](https://hackage.haskell.org/package/QuickCheck), [Hedgehog](https://hedgehog.qa/), [validity](https://hackage.haskell.org/package/validity) or [SmallCheck](https://hackage.haskell.org/package/smallcheck),
- a limited set of property-based testing libraries for JavaScript and TypeScript including [fast-check](https://fast-check.dev/).
- a limited set of property-based testing libraries for Erlang, including proper and quickcheck.
Fuzzing, or fuzz testing, is the practice of feeding unexpected or random data
into a program to expose bugs. Regular fuzzing is important to detect
Expand Down
1 change: 1 addition & 0 deletions internal/fuzzers/fuzzers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
OSSFuzz = "OSSFuzz"
ClusterFuzzLite = "ClusterFuzzLite"
BuiltInGo = "GoBuiltInFuzzer"
PropertyBasedErlang = "ErlangPropertyBasedTesting"
PropertyBasedHaskell = "HaskellPropertyBasedTesting"
PropertyBasedJavaScript = "JavaScriptPropertyBasedTesting"
PropertyBasedTypeScript = "TypeScriptPropertyBasedTesting"
Expand Down

0 comments on commit 965d15b

Please sign in to comment.