mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Tools] Add a tool to detect source-breaking API changes introduced from libraries. swift-api-digester is a test utility to detect source-breaking API changes during the evolution of a swift library. The tool works on two phases: (1) dumping library contents as a json file, and (2) comparing two json files textually to report interesting changes. During phase (1), the api-digester looks up every declarations inside a module and outputs a singly-rooted tree that encloses interesting details of the API level. During phase (2), api-digester applies structure-information comparision algorithms on two given singly root trees, trying to figure out, as precise as possible, the branches/leaves in the trees that differ from each other. Further analysis decides whether the changed leaves/branches can be reflected as source-breaking changes for API users. If they are, the output of api-digester will include such changes. Also, this commit includes a regression test that make sure API changes from the Swift stdlib are expected.
9 lines
721 B
Swift
9 lines
721 B
Swift
// REQUIRES: OS=macosx
|
|
// RUN: rm -rf %S/tmp && mkdir %S/tmp && mkdir %S/tmp/module-cache && mkdir %S/tmp/dummy.sdk
|
|
// RUN: %api-digester -dump-sdk -module Swift -o %S/tmp/current-stdlib.json -module-cache-path %S/tmp/module-cache -sdk %S/tmp/dummy.sdk -swift-version 3.0
|
|
// RUN: %api-digester -diagnose-sdk -input-paths %S/stdlib-stable.json -input-paths %S/tmp/current-stdlib.json >> %S/tmp/changes.txt
|
|
// RUN: %clang -E -P -x c %S/source-stability.swift.expected -o - | sed '/^\s*$/d' > %S/tmp/source-stability.swift.expected
|
|
// RUN: %clang -E -P -x c %S/tmp/changes.txt -o - | sed '/^\s*$/d' > %S/tmp/changes.txt.tmp
|
|
// RUN: diff -u %S/tmp/source-stability.swift.expected %S/tmp/changes.txt.tmp
|
|
// RUN: rm -rf %S/tmp
|