-
Notifications
You must be signed in to change notification settings - Fork 56
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
Gather data about private API usage in test suite #1800
Gather data about private API usage in test suite #1800
Commits on Jul 24, 2024
-
Remove shortcuts to shared_helper properties
This refactor is preparation for an upcoming change which will give each test function a unique helper object.
Configuration menu - View commit details
-
Copy full SHA for 9e28603 - Browse repository at this point
Copy the full SHA 9e28603View commit details -
Declare variables consistently in shared_helper
Preparation for an upcoming change which will turn this helper into a class.
Configuration menu - View commit details
-
Copy full SHA for 3ddc825 - Browse repository at this point
Copy the full SHA 3ddc825View commit details -
Stop using helper.AblyRealtime as a constructor
It isn’t intended be called as a constructor.
Configuration menu - View commit details
-
Copy full SHA for 2b7c2f5 - Browse repository at this point
Copy the full SHA 2b7c2f5View commit details -
Convert shared helper to a class
Motivation as in 9e28603. To expand a little, in order to implement ECO-4821 (gathering detailed information about private API usage in the test suite), we will give each test function access to a unique helper object which is aware of the identity of the test case in which it is executing. This helper object will offer a method for recording the fact that a test function is calling a private API. By using the existing shared_helper object, we can also record the usage of private APIs by the various helper methods, access to which is currently funnelled through the shared_helper. The couple of methods that I’ve made static (randomString, whenPromiseSettles) are ones that are very frequently called _and_ which definitely don’t use any private APIs, so I’ve made them static so that, when we make the aforementioned change giving each test case its own helper object, we don’t need to pass a helper around just to enable these methods to be called. The choice of making just these two methods static was pretty arbitrary; once we’ve catalogued all of the private API usage it might turn out there some other ones that can be made static.
Configuration menu - View commit details
-
Copy full SHA for 1fa5e13 - Browse repository at this point
Copy the full SHA 1fa5e13View commit details -
Update tests so that each has its own helper instance
This removes the per-file SharedHelper instance and instead makes sure that each context which will call SharedHelper instance methods (e.g. test cases, test hooks) has a unique SharedHelper instance that is aware of the context from which it is being called. (Motivation for this change already explained in 1fa5e13.)
Configuration menu - View commit details
-
Copy full SHA for 4f0dbbe - Browse repository at this point
Copy the full SHA 4f0dbbeView commit details -
Move availableTransports and bestTransport inside helper
Preparation for recording private API usage by tests (ECO-4821).
Configuration menu - View commit details
-
Copy full SHA for 0bf4291 - Browse repository at this point
Copy the full SHA 0bf4291View commit details -
Record usages of private APIs in the test suite
This adds annotations to each place in the test suite where a private API is called. When the tests are run, these annotations are used to emit a JSON file containing private API usage information. (In ECO-4834, we’ll process this JSON file to generate some useful reports.) This JSON file also contains a list of all of the tests which get run, which will be used as part of the aforementioned reporting to allow us to generate a report of the tests that do not use any private APIs. The motivation for this gathering this data is that we intend to try and reuse the ably-js test suite as a unified test suite for all of our client libraries. In order to do this, we’ll need to address the usage of ably-js private APIs in the test suite, and to do that we need to first gather data about the current usage. I originally intended to put the changes into the current commit into a separate unified test suite branch, instead of merging them into `main`. But I don’t really want to maintain a long-running feature branch, and also I want to make sure that we add private API annotations to any new tests that we add to ably-js, hence I decided to put this commit into `main`. But maybe, once we’re done with the unified test suite, we’ll decide to remove these annotations. Given the context in which we’re gathering this data, in the interests of saving time I skipped adding some annotations to some files that I’m pretty sure will not form part of the unified test suite: - test/realtime/transports.test.js - test/browser/simple.test.js - test/browser/http.test.js - test/browser/connection.test.js - test/browser/modular.test.js - test/browser/push.test.js - test/rest/bufferutils.test.js If we decide at some point that we’d like to for whatever reason gather data on these tests, we can do that later. (Note I haven't been very consistent with how many times per test I record the usage of a given private API; it’s not a stat I’m particularly interested in here. But for the most part I’m doing it at the point of each invocation of the private API.) Resolves ECO-4821.
Configuration menu - View commit details
-
Copy full SHA for 2dcf4ed - Browse repository at this point
Copy the full SHA 2dcf4edView commit details -
Generate reports on private API usage
This uses the data gathered in 2dcf4ed to generate some CSV reports about private API usage in the test suite. We’ll use these reports as a starting point for deciding how to remove this private API usage when reusing the test suite as a unified test suite for all our client libraries. Resolves ECO-4834.
Configuration menu - View commit details
-
Copy full SHA for f770124 - Browse repository at this point
Copy the full SHA f770124View commit details