-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: This is a fully end-to-end test that indexes a base DB, an incremental DB with some changes, and then checks queries on the incremental DB against snapshot results. It also tests that most of the derived predicates are working, including the manual ones. For this to get the correct results: * ownership must be working for the base DB * we have to exclude the correct units * ownership has to be working for the derived predicates, including the manual ones (TargetUses and DeclFamilies) Reviewed By: phlalx Differential Revision: D51117377 fbshipit-source-id: e67e3cfe60c327702f45d32d44372099c72e04ac
- Loading branch information
1 parent
6b2f6c4
commit 8948452
Showing
16 changed files
with
1,808 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{- | ||
Copyright (c) Meta Platforms, Inc. and affiliates. | ||
All rights reserved. | ||
This source code is licensed under the BSD-style license found in the | ||
LICENSE file in the root directory of this source tree. | ||
-} | ||
|
||
{-# LANGUAGE ApplicativeDo #-} | ||
module IncrementalTest (main) where | ||
|
||
import qualified Data.ByteString.UTF8 as UTF8 | ||
import Data.Default | ||
import System.Directory | ||
import System.Exit | ||
import System.FilePath | ||
|
||
import Glean | ||
import Glean.Regression.Config | ||
import Glean.Regression.Indexer | ||
import Glean.Regression.Snapshot (testMain) | ||
import Glean.Regression.Snapshot.Driver | ||
import qualified Glean.Clang.Test as Clang | ||
import qualified Glean.Clang.Test.DerivePass as DerivePass | ||
import qualified Glean.Regression.Driver.DeriveForCodemarkup as Code | ||
|
||
main :: IO () | ||
main = testMain incrementalClangDriver | ||
|
||
incrementalClangDriver :: Driver Clang.Options | ||
incrementalClangDriver = clangDriver { driverCreateDatabase = createDB } | ||
where | ||
clangDriver = DerivePass.driver Code.codemarkupDerivePasses | ||
|
||
createDB _ backend indexer test = do | ||
let | ||
repo = testRepo test | ||
base = repo { repo_name = (repo_name repo) <> "_base" } | ||
baseTestConfig = test | ||
{ testRepo = base | ||
, testRoot = testRoot test </> "old" | ||
} | ||
|
||
fillDatabase backend base "" Nothing (die "repo already exists") $ | ||
runIndexerForTest backend indexer baseTestConfig | ||
|
||
-- discover which files are in the new version | ||
let isCppFile = (`elem` [".h", ".cpp"]) . takeExtension | ||
files <- filter isCppFile <$> listDirectory (testRoot test) | ||
|
||
let deps = | ||
Dependencies_pruned def { | ||
pruned_base = base, | ||
pruned_units = map UTF8.fromString files, | ||
pruned_exclude = True | ||
} | ||
fillDatabase backend repo "" (Just deps) (die "repo already exists") $ | ||
runIndexerForTest backend indexer test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
query: cxx1.DeclByName _ | ||
transform: | ||
- sort | ||
- - [key,name_lowercase] | ||
- [key,kind] | ||
- [key,ident,macro,key] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
query: cxx1.DeclFamily _ | ||
transform: [normord, []] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
query: cxx1.DeclToFamily _ | ||
transform: [normord, []] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
query: cxx1.TargetUses _ | ||
transform: [normord, []] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
namespace test { | ||
|
||
class C { | ||
public: | ||
int f(); | ||
|
||
private: | ||
int x; | ||
}; | ||
|
||
int a(); // defined in a.cpp | ||
|
||
int b(); // defined in b.cpp | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include "a.h" | ||
|
||
namespace test { | ||
|
||
int b() { | ||
return 4; // changed result | ||
} | ||
|
||
// Inserted comment | ||
|
||
int bb(int x, int y) { // added parameter | ||
C c; | ||
return c.f() + x + y; | ||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
glean/lang/clang/tests/incremental/src/cxx1.DeclByName.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
[ | ||
"@generated", | ||
{ | ||
"key": { | ||
"name_lowercase": "a", | ||
"kind": 6, | ||
"ident": { "name": { "key": "a" } } | ||
} | ||
}, | ||
{ | ||
"key": { | ||
"name_lowercase": "b", | ||
"kind": 6, | ||
"ident": { "name": { "key": "b" } } | ||
} | ||
}, | ||
{ | ||
"key": { | ||
"name_lowercase": "bb", | ||
"kind": 6, | ||
"ident": { "name": { "key": "bb" } } | ||
} | ||
}, | ||
{ | ||
"key": { | ||
"name_lowercase": "c", | ||
"kind": 3, | ||
"ident": { "name": { "key": "C" } } | ||
} | ||
}, | ||
{ | ||
"key": { | ||
"name_lowercase": "c", | ||
"kind": 7, | ||
"ident": { "name": { "key": "c" } } | ||
} | ||
}, | ||
{ | ||
"key": { | ||
"name_lowercase": "f", | ||
"kind": 6, | ||
"ident": { "name": { "key": "f" } } | ||
} | ||
}, | ||
{ | ||
"key": { | ||
"name_lowercase": "test", | ||
"kind": 0, | ||
"ident": { "name": { "key": "test" } } | ||
} | ||
}, | ||
{ | ||
"key": { | ||
"name_lowercase": "x", | ||
"kind": 7, | ||
"ident": { "name": { "key": "x" } } | ||
} | ||
}, | ||
{ | ||
"key": { | ||
"name_lowercase": "y", | ||
"kind": 7, | ||
"ident": { "name": { "key": "y" } } | ||
} | ||
} | ||
] |
191 changes: 191 additions & 0 deletions
191
glean/lang/clang/tests/incremental/src/cxx1.DeclFamily.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
[ | ||
"@generated", | ||
{ | ||
"key": [ | ||
{ | ||
"function_": { | ||
"key": { | ||
"method": { | ||
"isConst": false, | ||
"isVirtual": false, | ||
"isVolatile": false, | ||
"refQualifier": 0 | ||
}, | ||
"name": { | ||
"key": { | ||
"name": { "key": { "name": { "key": "f" } } }, | ||
"scope": { | ||
"recordWithAccess": { | ||
"access": 0, | ||
"record": { | ||
"key": { | ||
"name": { "key": "C" }, | ||
"scope": { | ||
"namespace_": { "key": { "name": { "key": "test" } } } | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"signature": { | ||
"key": { "parameters": [ ], "returns": { "key": "int" } } | ||
}, | ||
"source": { | ||
"columnBegin": 1, | ||
"columnEnd": 1, | ||
"file": { "key": "a.cpp" }, | ||
"lineBegin": 13, | ||
"lineEnd": 15 | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"function_": { | ||
"key": { | ||
"method": { | ||
"isConst": false, | ||
"isVirtual": false, | ||
"isVolatile": false, | ||
"refQualifier": 0 | ||
}, | ||
"name": { | ||
"key": { | ||
"name": { "key": { "name": { "key": "f" } } }, | ||
"scope": { | ||
"recordWithAccess": { | ||
"access": 0, | ||
"record": { | ||
"key": { | ||
"name": { "key": "C" }, | ||
"scope": { | ||
"namespace_": { "key": { "name": { "key": "test" } } } | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"signature": { | ||
"key": { "parameters": [ ], "returns": { "key": "int" } } | ||
}, | ||
"source": { | ||
"columnBegin": 3, | ||
"columnEnd": 9, | ||
"file": { "key": "a.h" }, | ||
"lineBegin": 15, | ||
"lineEnd": 15 | ||
} | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"key": [ | ||
{ | ||
"function_": { | ||
"key": { | ||
"name": { | ||
"key": { | ||
"name": { "key": { "name": { "key": "a" } } }, | ||
"scope": { | ||
"namespace_": { "key": { "name": { "key": "test" } } } | ||
} | ||
} | ||
}, | ||
"signature": { | ||
"key": { "parameters": [ ], "returns": { "key": "int" } } | ||
}, | ||
"source": { | ||
"columnBegin": 1, | ||
"columnEnd": 1, | ||
"file": { "key": "a.cpp" }, | ||
"lineBegin": 17, | ||
"lineEnd": 20 | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"function_": { | ||
"key": { | ||
"name": { | ||
"key": { | ||
"name": { "key": { "name": { "key": "a" } } }, | ||
"scope": { | ||
"namespace_": { "key": { "name": { "key": "test" } } } | ||
} | ||
} | ||
}, | ||
"signature": { | ||
"key": { "parameters": [ ], "returns": { "key": "int" } } | ||
}, | ||
"source": { | ||
"columnBegin": 1, | ||
"columnEnd": 7, | ||
"file": { "key": "a.h" }, | ||
"lineBegin": 21, | ||
"lineEnd": 21 | ||
} | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"key": [ | ||
{ | ||
"function_": { | ||
"key": { | ||
"name": { | ||
"key": { | ||
"name": { "key": { "name": { "key": "b" } } }, | ||
"scope": { | ||
"namespace_": { "key": { "name": { "key": "test" } } } | ||
} | ||
} | ||
}, | ||
"signature": { | ||
"key": { "parameters": [ ], "returns": { "key": "int" } } | ||
}, | ||
"source": { | ||
"columnBegin": 1, | ||
"columnEnd": 1, | ||
"file": { "key": "b.cpp" }, | ||
"lineBegin": 13, | ||
"lineEnd": 15 | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"function_": { | ||
"key": { | ||
"name": { | ||
"key": { | ||
"name": { "key": { "name": { "key": "b" } } }, | ||
"scope": { | ||
"namespace_": { "key": { "name": { "key": "test" } } } | ||
} | ||
} | ||
}, | ||
"signature": { | ||
"key": { "parameters": [ ], "returns": { "key": "int" } } | ||
}, | ||
"source": { | ||
"columnBegin": 1, | ||
"columnEnd": 7, | ||
"file": { "key": "a.h" }, | ||
"lineBegin": 23, | ||
"lineEnd": 23 | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] |
Oops, something went wrong.