Commit Graph

44 Commits

Author SHA1 Message Date
Paolo Tranquilli
20eaa34485 Swift: failing tests for linkage awareness 2023-01-18 10:07:46 +01:00
Paolo Tranquilli
874fe2b8f9 Swift: introduce an in-memory file hash cache
File hashing is now done internally in `SwiftFileInterception` (and
exported as a `getHashOfRealFile` function for future use in linkage
awareness), and using a per-process in-memory cache. The persistent
caching of paths is removed, so the solution is now robust against input
file changes during the build.

For the same reason, the hash to artifact mapping have the symlinks
reversed now. The artifacts themselves are stored using the hash as
filenames, and the original paths of the artifacts are reacreated in the
scratch dir with symlinks mostly for debugging purposes (to understand
what artifact each hash corresponds to, and to follow what was built by
the extractor).
2023-01-16 12:05:36 +01:00
Paolo Tranquilli
82d9edfabf Merge branch 'main' into redsun82/swift-open-redirection 2023-01-09 08:44:02 +01:00
Nora Dimitrijević
893ec33da0 Swift: update .expected for integration tests 2022-12-15 11:28:02 -05:00
Paolo Tranquilli
3084eda28a Swift: add swiftmodule hash map testing to frontend_invocations 2022-12-15 10:33:47 +01:00
Paolo Tranquilli
14fd89d482 Swift: generalize output redirection code 2022-12-14 18:26:48 +01:00
Paolo Tranquilli
4a41bb4061 Merge branch 'main' into redsun82/swift-open-redirection 2022-12-09 09:59:21 +01:00
Paolo Tranquilli
935e264f24 Swift: add empty directory marker 2022-12-08 17:04:56 +01:00
Paolo Tranquilli
bf1b32f210 Swift: rework file redirection
The hash map mechanism that was already in use for reading swiftmodule
files on macOS is now in use also on Linux. The output replacing
mechanism has been also reworked so that:
* frontend module emission modes have the remapping done directly in
  the internal frontend options instead of painstakingly modifying input
  flags (this requires a patch on the swift headers though)
* object emission mode is silenced to be just a type checking pass,
  thus producing no output files
* all other passes but some debugging and version related ones become
  noops

The open file read redirection uses a global weak pointer instance to
maximize robustness in the face of possibly multi-threaded calls to open
happening while `main` is exiting. Possibly overkill, but better safe
than sorry.
2022-12-08 16:10:44 +01:00
Paolo Tranquilli
1ba8b6d35a Swift: fix extraction of sources from .. 2022-12-08 15:57:57 +01:00
Alex Denisov
f5ddbd6abb Swift: add a test case showing case canonicalization 2022-12-02 14:06:21 +01:00
AlexDenisov
691188bc48 Merge pull request #11523 from github/alexdenisov/preserve-symlinks
Swift: resolve symlinks conditionally
2022-12-02 14:05:13 +01:00
Alex Denisov
7a3beac494 Swift: resolve symlinks conditionally 2022-12-02 10:07:10 +01:00
Alex Denisov
e7a48b4c98 Swift: add a test case for symlinks 2022-12-02 10:02:45 +01:00
Paolo Tranquilli
cd6d00e760 Swift: add xcode integration test 2022-12-01 17:25:34 +01:00
Paolo Tranquilli
4e29ff1d6e Swift: add -merge-modules to frontend-invocations test
Also, moved from Makefile to a bash source.
2022-11-30 17:46:47 +01:00
Paolo Tranquilli
28bf0c9e03 Merge pull request #11365 from github/redsun82/swift-integration-test-pack
Swift: fix extractor tests pack
2022-11-28 17:02:54 +01:00
Paolo Tranquilli
8df7d465cb Swift: cache more aggressively in CI
* the QL compilation cache action is used for ql and integration tests
* all caches (Bazel and QL) are populated on push
2022-11-25 08:52:46 +01:00
Paolo Tranquilli
414f18fc97 Swift: fix extractor tests pack
This allows `codeql query compile` to run on integration test queries.
2022-11-22 10:58:57 +01:00
Paolo Tranquilli
635391eae8 Swift: autopep8 integration tests 2022-11-15 15:43:05 +01:00
Chris Smowton
5ad5cdce47 Swift integration-test runner: use --additional-packs 2022-10-28 16:07:38 +01:00
Chris Smowton
ee63e60bb7 qlpacks: libraryPathDependencies -> dependencies 2022-10-28 16:07:36 +01:00
Paolo Tranquilli
6651c9447e Swift: failing test for extracting function bodies 2022-10-24 17:10:38 +02:00
dependabot[bot]
c3693f1a20 Swift: bump actions/setup-python from 3 to 4
Also fixes python version with a `.pythonversion` file.

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-19 18:10:42 +02:00
Paolo Tranquilli
57b8830972 Swift: fix integration tests 2022-08-30 11:46:27 +02:00
Paolo Tranquilli
7887f669c1 Merge pull request #10175 from github/redsun82/swift-missing-extractions
Swift: fix missing extractions
2022-08-26 14:09:09 +02:00
Paolo Tranquilli
ced36ffc61 Swift: run swift instead of swift-frontend on Linux 2022-08-26 12:12:21 +02:00
Paolo Tranquilli
c7c42acbf5 Swift: port frontend-invocations test to linux
`swift-frontend` will be in `$PATH` on Linux, and apparently it does
not require the `-sdk` option.
2022-08-26 12:03:18 +02:00
Paolo Tranquilli
df3dc9677f Swift: fix missing extractions from Builtin
There were missing extractions from the Builtin (and other) modules.

This was actually caused by two issues:
* we did not visit all required modules, as for example the `Builtin`
  module does not appear as being imported by anybody (together with
  another mysterious `__Objc` module)
* moreover the `Builtin` module works internally by only creating
  declarations on demand, and does not provide a list of its top level
  declarations.

The first problem was solved by moving module collection to the actual
visiting. This may mean we extract less modules, as we only extract the
modules we actually use something from (recursively). This change can
be reverted if we feel we need it.

The second one was solved by explicitly listing the builtin symbols
encountered during a normal extraction. This does mean this list needs
to be kept up to date.
2022-08-25 15:18:24 +02:00
Mathias Vorreiter Pedersen
de03fbdc49 Swift: Accept test changes. 2022-08-24 10:03:21 +01:00
Paolo Tranquilli
065fecc57e Swift: extract precompiled swiftmodule files
Previously we were not extracting any `swiftmodule` file that was not
a system or a built-in one. This was done to avoid re-extracting
`swiftmodule` files that were built previously in the same build, but it
turned out to be too eager, as there are legitimate cases where a
non-system, non-built-in precompiled swift module can be used. An
example of that is the `PackageDescription` module used in Swift
Package Manager manifest files (`Package.swift`).

We now relax the test and trigger module extraction on all loaded
modules that do not have source files (we trigger source file extraction
for those). The catch, is that we also create empty trap files for
current output `swiftmodule` files (including possible alias locations
set up by XCode).

This means that if a following extractor run loads a previously built
`swiftmodule` file, although it will trigger module extraction, this
will however be skipped as it will find its target file already present
(this is done via the `TargetFile` semantics).
2022-07-29 11:10:03 +02:00
Paolo Tranquilli
d547a417c9 Swift: accept new test results 2022-07-28 12:57:12 +02:00
Paolo Tranquilli
ab1370cc8f Swift: add --no-cleanup to integration tests 2022-07-28 11:19:45 +02:00
Paolo Tranquilli
8addc06799 Swift: add integration test for multiple modules 2022-07-01 15:59:36 +02:00
Paolo Tranquilli
901e066355 Swift: locally run integration tests
Minimal recreations of internal `integration-tests-runner.py` and
`create_database_utils.py` are provided to be able to run the
integration tests on the codeql repository with a released codeql CLI.

For the moment we skip the database checks by default, as we are still
producing inconsistent results.
2022-07-01 15:00:05 +02:00
Alex Denisov
57811a4efc Swift: add a test case showing module loading problem
Extractor fails to load separate modules that were built by another
version of an actual compiler.
2022-06-29 07:38:18 +02:00
Paolo Tranquilli
80ffd81b2c Merge pull request #9614 from github/alexdenisov/swift-extract-all-inputs-with-outputs
Swift: extract all output-producing source files, not only primary files
2022-06-24 12:23:36 +02:00
Paolo Tranquilli
7334b4e03a Swift: autopep8 all python files
Additionally set up a pre-commit hook and a CI check for that.
2022-06-23 17:13:56 +02:00
Alex Denisov
42dc6814f0 Swift: extract all output-producing source files, not only primary files 2022-06-20 14:06:54 +02:00
Alex Denisov
1c9a684ac6 Swift: Introduce SwiftExtractionMode 2022-06-15 09:25:01 +02:00
Alex Denisov
6d67ea267c Swift: add cross-referencing test 2022-06-15 08:44:38 +02:00
Alex Denisov
fa09078976 Swift: do not keep trap files for tests 2022-05-24 11:48:45 +02:00
Alex Denisov
8e8da66325 Swift: share .gitignore across all tests 2022-05-24 11:48:06 +02:00
Alex Denisov
528f6f73c5 Swift: add integration tests 2022-05-24 11:12:35 +02:00