mirror of
https://github.com/github/semantic.git
synced 2024-11-27 03:09:48 +03:00
Fix bad hacks associated with directory paths.
This commit is contained in:
parent
1800de07e8
commit
6d390195e3
@ -142,7 +142,6 @@ def semantic_language_parsing_test(language, semantic_package = "", ts_package =
|
||||
"//:base",
|
||||
"//:bytestring",
|
||||
"//:text",
|
||||
"//semantic:fixtureshim",
|
||||
"//semantic-ast",
|
||||
"@stackage//:bazel-runfiles",
|
||||
"@stackage//:hedgehog",
|
||||
|
@ -31,6 +31,7 @@ haskell_library(
|
||||
"@stackage//:aeson",
|
||||
"@stackage//:aeson-pretty",
|
||||
"@stackage//:attoparsec",
|
||||
"@stackage//:bazel-runfiles",
|
||||
"@stackage//:directory",
|
||||
"@stackage//:fused-effects",
|
||||
"@stackage//:hedgehog",
|
||||
|
@ -4,7 +4,7 @@
|
||||
module System.Path.Fixture
|
||||
( absFile,
|
||||
absRelFile,
|
||||
bazelDir,
|
||||
relDir,
|
||||
HasFixture,
|
||||
absRelDir,
|
||||
delay,
|
||||
@ -12,12 +12,11 @@ module System.Path.Fixture
|
||||
where
|
||||
|
||||
import qualified Bazel.Runfiles as Bazel
|
||||
import Data.Proxy
|
||||
import GHC.Stack
|
||||
import GHC.TypeLits
|
||||
import qualified System.Path as Path
|
||||
import Control.Concurrent
|
||||
import GHC.Stack
|
||||
import System.IO
|
||||
import System.Path ((</>))
|
||||
import qualified System.Path as Path
|
||||
|
||||
type HasFixture =
|
||||
( ?runfiles :: Bazel.Runfiles,
|
||||
@ -32,13 +31,17 @@ delay s = do
|
||||
threadDelay 100000000
|
||||
|
||||
absFile :: (HasFixture) => String -> Path.AbsFile
|
||||
absFile x = Path.absFile (Bazel.rlocation ?runfiles ("semantic/" <> Path.toString ?project <> x))
|
||||
absFile x = root </> Path.relDir "semantic" </> ?project </> Path.relFile x
|
||||
where
|
||||
root = Path.absDir (Bazel.rlocation ?runfiles ".")
|
||||
|
||||
absRelFile :: (HasFixture) => String -> Path.AbsRelFile
|
||||
absRelFile = Path.toAbsRel . absFile
|
||||
|
||||
bazelDir :: HasFixture => String -> Path.AbsDir
|
||||
bazelDir x = Path.absDir (Bazel.rlocation ?runfiles ("semantic/" <> Path.toString ?project <> x))
|
||||
relDir :: HasFixture => String -> Path.AbsDir
|
||||
relDir x = root </> Path.relDir "semantic" </> ?project </> Path.relDir x
|
||||
where
|
||||
root = Path.absDir (Bazel.rlocation ?runfiles ".")
|
||||
|
||||
absRelDir :: HasFixture => String -> Path.AbsRelDir
|
||||
absRelDir = Path.toAbsRel . bazelDir
|
||||
absRelDir = Path.toAbsRel . relDir
|
@ -17,7 +17,7 @@ main = do
|
||||
let ?project = Path.relDir "semantic-codeql"
|
||||
?runfiles = rf
|
||||
|
||||
let dirs = Fixture.bazelDir "/../external/tree-sitter-ql/test/corpus"
|
||||
let dirs = Fixture.relDir "../external/tree-sitter-ql/test/corpus"
|
||||
parse = parseByteString @CodeQL.Ql @() tree_sitter_ql
|
||||
|
||||
readCorpusFiles' dirs
|
||||
|
@ -17,7 +17,7 @@ main = do
|
||||
-- dirs <- Path.absDir <$> Go.getTestCorpusDir
|
||||
let ?project = Path.relDir "semantic-go"
|
||||
?runfiles = rf
|
||||
let dirs = Fixture.bazelDir "/../external/tree-sitter-go/corpus"
|
||||
let dirs = Fixture.relDir "../external/tree-sitter-go/corpus"
|
||||
|
||||
readCorpusFiles' dirs
|
||||
>>= traverse (testCorpus parse)
|
||||
|
@ -22,7 +22,7 @@ main = do
|
||||
-- dirs <- Path.absDir <$> Java.getTestCorpusDir
|
||||
let ?project = Path.relDir "semantic-java"
|
||||
?runfiles = rf
|
||||
let dirs = Fixture.bazelDir "/../external/tree-sitter-java/corpus"
|
||||
let dirs = Fixture.relDir "../external/tree-sitter-java/corpus"
|
||||
readCorpusFiles' dirs
|
||||
>>= traverse (testCorpus parse)
|
||||
>>= defaultMain . tests
|
||||
|
@ -17,7 +17,7 @@ main = do
|
||||
let ?project = Path.relDir "semantic-python"
|
||||
?runfiles = rf
|
||||
|
||||
let dirs = Fixture.bazelDir "/../external/tree-sitter-python/test/corpus"
|
||||
let dirs = Fixture.relDir "../external/tree-sitter-python/test/corpus"
|
||||
parse = parseByteString @Py.Module @() tree_sitter_python
|
||||
|
||||
readCorpusFiles' dirs
|
||||
|
@ -18,7 +18,7 @@ main = do
|
||||
-- dirs <- Path.absDir <$> Ruby.getTestCorpusDir
|
||||
let ?project = Path.relDir "semantic-ruby"
|
||||
?runfiles = rf
|
||||
let dirs = Fixture.bazelDir "/../external/tree-sitter-ruby/test/corpus"
|
||||
let dirs = Fixture.relDir "../external/tree-sitter-ruby/test/corpus"
|
||||
|
||||
readCorpusFiles' dirs
|
||||
>>= traverse (testCorpus parse)
|
||||
|
@ -17,7 +17,7 @@ main = do
|
||||
-- dirs <- Path.absDir <$> Typescript.getTestCorpusDir
|
||||
let ?project = Path.relDir "semantic-tsx"
|
||||
?runfiles = rf
|
||||
let dirs = Fixture.bazelDir "/../external/tree-sitter-typescript/tsx/corpus"
|
||||
let dirs = Fixture.relDir "../external/tree-sitter-typescript/tsx/corpus"
|
||||
|
||||
readCorpusFiles' dirs
|
||||
>>= traverse (testCorpus parse)
|
||||
|
@ -16,7 +16,7 @@ main = do
|
||||
-- dirs <- Path.absDir <$> Typescript.getTestCorpusDir
|
||||
let ?project = Path.relDir "semantic-typescript"
|
||||
?runfiles = rf
|
||||
let dirs = Fixture.bazelDir "/../external/tree-sitter-typescript/typescript/corpus"
|
||||
let dirs = Fixture.relDir "../external/tree-sitter-typescript/typescript/corpus"
|
||||
|
||||
readCorpusFiles' dirs
|
||||
>>= traverse (testCorpus parse)
|
||||
|
@ -133,17 +133,6 @@ haskell_binary(
|
||||
],
|
||||
)
|
||||
|
||||
# PT TODO: remove this
|
||||
haskell_library(
|
||||
name = "fixtureshim",
|
||||
srcs = ["test/System/Path/Fixture.hs"],
|
||||
deps = [
|
||||
"//:base",
|
||||
"@stackage//:bazel-runfiles",
|
||||
"@stackage//:pathtype",
|
||||
],
|
||||
)
|
||||
|
||||
haskell_test(
|
||||
name = "spec",
|
||||
srcs = glob(
|
||||
@ -167,7 +156,6 @@ haskell_test(
|
||||
"test/fixtures/cli/*.json",
|
||||
]),
|
||||
deps = semantic_common_dependencies + [
|
||||
":fixtureshim",
|
||||
"//:base",
|
||||
"//semantic",
|
||||
"//semantic-proto",
|
||||
@ -211,7 +199,6 @@ haskell_test(
|
||||
"test/fixtures/cli/*.json",
|
||||
]) + SEMANTIC_EXTERNAL_TEST_REPOSITORIES,
|
||||
deps = semantic_common_dependencies + [
|
||||
":fixtureshim",
|
||||
"//:base",
|
||||
"//semantic",
|
||||
"//semantic-proto",
|
||||
|
@ -179,7 +179,7 @@ main = withOptions testOptions $ \ config logger statter -> do
|
||||
let session = TaskSession config "-" False logger statter
|
||||
|
||||
allTests <- forConcurrently examples $ \lang@LanguageExample{..} -> do
|
||||
let tsDir = Fixture.absRelDir "/.."
|
||||
let tsDir = Fixture.absRelDir ".."
|
||||
buildExamples session lang tsDir
|
||||
|
||||
Tasty.defaultMain $ Tasty.testGroup "parse-examples" allTests
|
||||
|
Loading…
Reference in New Issue
Block a user