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

Support custom rewrite rule sets as input #26

Merged
merged 27 commits into from
Jan 25, 2024
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b4ca57e
Sketch user-defined rule set YAML
fizruk Jan 11, 2024
1de94a0
WIP Parse and sketch conversion for user-defined rule sets
fizruk Jan 11, 2024
694e52f
Update yegor.yaml rule set
fizruk Jan 11, 2024
3f2e27d
WIP matchObject implementation
fizruk Jan 15, 2024
e8156e5
feat: use the meta syntax as the main syntax
deemp Jan 16, 2024
4f98133
refactor: remove old files
deemp Jan 16, 2024
5ca1c7b
refactor: run bnfc
deemp Jan 16, 2024
d0c354f
refactor: generate a single parser
deemp Jan 16, 2024
d91e9ac
refactor: remove generated rules syntax files
deemp Jan 16, 2024
eccf0b9
refactor: use only meta syntax
deemp Jan 16, 2024
e003d2f
refactor: simplify code
deemp Jan 16, 2024
f4c4b11
refactor: pattern match Meta-things
deemp Jan 16, 2024
54ac539
refactor: support unit tests for custom rules
deemp Jan 16, 2024
97a8c7f
refactor: add unit tests for the rule 6
deemp Jan 16, 2024
e6ab161
fix: pre-defined rules tests
deemp Jan 16, 2024
1481ad7
feat: run user-defined tests
deemp Jan 16, 2024
cf6d2b9
chore: update the cabal file
deemp Jan 16, 2024
2a7f2f1
Fix matching
fizruk Jan 18, 2024
2f618bf
feat: add CLI
deemp Jan 18, 2024
1481558
Merge pull request #47 from objectionary/custom-rules-single-syntax
fizruk Jan 23, 2024
fd37bd1
Support --chain option, sketch more rules in yegor.yaml
fizruk Jan 23, 2024
cab3d70
Apply formatting
fizruk Jan 25, 2024
db87625
feat: enable ImportQualifiedPost
deemp Jan 25, 2024
5309a64
Apply formatting to Test.EO.Phi
fizruk Jan 25, 2024
f8c36a5
Add missing key in test
aabounegm Jan 25, 2024
5602f56
Specify Haskell extension as formatter for Haskell
aabounegm Jan 25, 2024
5c4a8a1
Move reading source to case when yaml is provided
aabounegm Jan 25, 2024
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
Prev Previous commit
Next Next commit
feat: run user-defined tests
Co-authored-by: Abdelrahman Abounegm <[email protected]>
deemp and aabounegm committed Jan 16, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 1481ad704b5a37ceff88e4a316438de7204bc4da
20 changes: 20 additions & 0 deletions eo-phi-normalizer/test/Language/EO/YamlSpec.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE OverloadedRecordDot #-}

module Language.EO.YamlSpec where

import Control.Monad (forM_)
import Language.EO.Phi.Rules.Common (Context (..))
import Language.EO.Phi.Rules.Yaml (Rule (..), RuleSet (..), RuleTest (..), convertRule)
import Test.EO.Yaml
import Test.Hspec

spec :: Spec
spec = describe "User-defined rules unit tests" do
ruleset <- runIO $ fileTests "test/eo/phi/rules/yegor.yaml"
describe ruleset.title do
forM_ ruleset.rules $ \rule -> do
describe rule.name do
forM_ rule.tests $ \ruleTest -> do
it ruleTest.name $
convertRule rule (Context []) ruleTest.input `shouldBe` [ruleTest.output | ruleTest.matches]
20 changes: 20 additions & 0 deletions eo-phi-normalizer/test/Test/EO/Yaml.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Test.EO.Yaml where

import Control.Monad (forM)
import Data.List (sort)
import Language.EO.Phi.Rules.Yaml (RuleSet, parseRuleSetFromFile)
import System.Directory (listDirectory)
import System.FilePath ((</>))

fileTests :: FilePath -> IO RuleSet
fileTests = parseRuleSetFromFile

directoryTests :: FilePath -> IO [RuleSet]
directoryTests dir = do
paths <- listDirectory dir
forM (sort paths) $ \path ->
fileTests (dir </> path)