Skip to content

[5.1] Update with changes from master #51

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

Merged
merged 60 commits into from
Aug 17, 2019

Conversation

benlangmuir
Copy link
Contributor

Sync up with master to get install support and recent bug fixes.

akyrtzi and others added 30 commits May 1, 2019 12:45
…sure to filter the units properly

Previously it was returning the unit with the most recent modification time, and if that unit was filtered-out by SymbolIndexImpl::createProviderForCode()
then the whole provider would be ignored, which is incorrect because there could be other units for the same provider that are eligible.

This change moves the filtering into the `ReadTransaction`'s call.
[Database] For ReadTransaction::getProviderFileCodeReferences() make sure to filter the units properly
- Set up config and llvm-config.h to not be unix specific
- Import WindowsSupport.h and VerisonTuple.h
[Index] For `isKnownFile()` take into account visibility of unit files
This allows the client to be much more efficient for handling unit test symbol changes.
Keep track and report the unit files that contain test symbols
This allows IndexStoreDB to build on Windows.
Workaround corelibs-libdispatch crash SR-10319
This can be used in lsp projects to find
all symbols in a workspace  that match a string.

https://bugs.swift.org/browse/SR-10806
Add discardableResult to new functions.
Return Bool in new functions.
Make all new variables lowercase.
Rename functions to match existing patterns.
Add IndexSymbolKind enum

Add kind property in Symbol

Add forEachRelation of occurrence function
Add SymbolRelation class with roles and symbols
…ipt-helper

For now, just thread ninja_bin through as an environment variable.
Future commits will make use of this during testing. Also pass the
toolchain path and remove unnecessary differences with the sourcekit-lsp
build-script-helper script.
…script

[build-script] Accept --ninja-bin and sync with sourcekit's build-script-helper
The goal of this change is to make it convenient to add tests for the
index that test the whole process of producing the raw index data using
the compilers in the toolchain, importing that data, and
producing/updating an IndexStoreDB. The core infrastructure is also
designed to be shared by the SourceKitLSP project.  All of this is built
for tests written in Swift.

This change can be broken down into some inter-dependent high-level
components:

1. Tibs (Test Index Build System)
2. ISDBTestSupport
3. Improvements to IndexStoreDB to make it testable
4. Tests

---

Tibs
----

Tibs, or the "Test Index Build System" provides a simple and flexible
build system for test projects. A test case can use a fixture from the
`Tests/INPUTS` directory containing a `project.json` describing any
targets of the test. Targets may be Swift modules containing any number
of source files, C translations units, or a mix of both, including mixed
language targets (subject to the capabilities of the platform - Linux
cannot use Objective-C interop, for example). The test can then
programatically build index raw data, make modifications to source
files, and incrementally rebuild.

Tibs is implemented using `ninja`, which introduces a new dependency in
IndexStoreDB *only when running tests*.

ISDBTestSupport
---------------

This module contains a number of useful types and functions for working
with test fixtures. In particular,

* `TestSources` provides a one-stop shop for working with the source files
inside a test project, including modifying them and scanning them for
named `TestLocation`s, which can then be used to locate positions within
source code during a test.

* `TibsTestWorkspace` provides a convenient way to work with a tibs test
project, its `TestSources`, and the resulting `IndexStoreDB.. Mutable
projects are created with sources and build products copied into a
temporary location (and cleared on deinit), and can be edited and
rebuilt during the test. An immutable (static) test workspace can use
the sources directly from the INPUTS directory, and its build products
are stored in the build directory for IndexStoreDB itself, allowing
faster incremental builds (or null builds) during development.

Improvements to IndexStoreDB
----------------------------

The biggest change here is that the `Symbol` and `SymbolOccurrence`
types are now simple struct types rather than wrapping the underlying C
API types. This makes it much more convenient to work with them during
testing, used along with the new `checkOccurrences` function.

There is also a new API to `pollForUnitChangesAndWait`, intended only
for testing. This replaces watching for file system changes during
testing by polling and comparing to the last known state of the unit
directory. Watching for file system changes is unnecessarily
asynchronous during testing, and this lets us side step any performance
issues with that, as well as determining when an index update is "done".

Tests
-----

To prove the usefulness of the new testing APIs, several new tests for
indexing functionality, were added. These are the first real tests for
the indexing code. There is lots of room to improve testing coverage
further.
[SR-11164] Use the toolchain's Block.h
…rebased

Add infrastructure for testing IndexStoreDB
[docs] Add documentation about writing tests for IndexStoreDB
Using a leading '<', we can now specify a location ending at the comment
instead of after it.  For example,

```swift
/*a:start*/abc/*<a:end*/
//         ^  ^
//   a:start  a:end

```

This is useful for forming source ranges.
benlangmuir and others added 23 commits August 9, 2019 21:23
Fix warnings by using the non-deprecated APIs, and while we're at it
consolidate all the uses into a single place that checks the result and
collects stdout. Inspired by SwiftPM's checkNonZeroExit.
The `INDEXSTORE_PUBLIC` macro was guarding based on `_MSC_VER` which is
a check for MSVC's compiler which is incorrect.  This annotation has
nothing to do with the MSVC compiler but rather the PE/COFF file format.
Adjust that to `_WIN32` as an alias for Windows.

Furthermore, correct the annotation - the functions should be given
dllexport storage when building IndexStoreDB, and dllimport storage when
building code which uses IndexStoreDB (unless it is statically built).
The dllstorage appertains to function and variable (declaration,
applied to definitions).  The usage here was to members of a type
definition which does not make sense.  This has no change as the
annotation is ignored with a warning.
CIndexStoreDB: correct dllstorage annotation
IndexStore: correct dllstorage attributes (NFC)
… relation

These objects are now valid only during the callbacks that provide them
from the index. Since we already converted them immediately, this didn't
impact the Swift code except to remove the indexstoredb_release calls
for these. I updated the documentation to indicate the new lifetime.

Incidentally, relation was using the make_object machinery even though
it was documented to only live for the callback, so this fixes a leak of
relations.
[tibs] Consolidate uses of Process and fix warnings
Remove unnecessary refcounting and allocation for symbol, occurrence, relation
Windows is able to create the directory `/nope` since a leading `/`
indications a drive relative path. Instead, use `/nope:` which is
invalid both on POSIX and Windows.
Windows doesn't support `#import` and using `#include` instead doesn't
affect this test case.
- Shared libs have a .dll extension
- dlls are typically store in bin along side the executables on Windows
On Windows, Ninja outputs CRLF instead of just an LF.
Use a Path that is Also Invalid on Windows in testErrors
Add Support for CRLF when Parsing Ninja Output
Search for Shared Libraries Properly on Windows
In a Makefile, spaces can be escaped by a preceeding backslash. Rather
than using string.split, iterate through the string keeping track of the
previous character.

Additionally added a test for the new functionality
- Ninja requires that `:`s in filenames be escaped as `$:`
- Explicitly call cmd.exe /C on Windows
- In addition, escape spaces for the command that we pass to cmd.exe
Windows (without msys) doesn't have where, instead, use the native which
to locate tools.
@benlangmuir benlangmuir requested a review from akyrtzi as a code owner August 16, 2019 22:50
@benlangmuir
Copy link
Contributor Author

@benlangmuir benlangmuir merged commit 03fe356 into swiftlang:swift-5.1-branch Aug 17, 2019
@benlangmuir benlangmuir deleted the merge-51 branch August 17, 2019 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants