-
Notifications
You must be signed in to change notification settings - Fork 26.7k
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
Clearer text about what happens with --disable-telemetry
+ enable-telemetry command
#125995
Merged
auto-submit
merged 8 commits into
flutter:master
from
eliasyishak:124411-disable-telemetry-refinements
May 8, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
24631af
Clearer text about what happens with `--disable-telemetry`
eliasyishak d561ed2
Adding `flutter --enable-telemetry` functionality + tests
eliasyishak a3d4d89
Merge branch 'master' into 124411-disable-telemetry-refinements
eliasyishak d00778f
Lowercase for dart and flutter in help messages
eliasyishak dfb379b
Removing bool value
eliasyishak 0fdbf9d
Fix bug
eliasyishak 89555ae
Remove conditional on disabling telemetry
eliasyishak 80ec41b
Throw if both enable and disable commands supplied + test
eliasyishak File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
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 |
---|---|---|
|
@@ -317,11 +317,6 @@ void main() { | |
}); | ||
|
||
group('unified_analytics', () { | ||
final Usage legacyAnalytics = TestUsage(); | ||
setUp(() { | ||
legacyAnalytics.enabled = false; | ||
}); | ||
|
||
Comment on lines
-320
to
-324
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wasn't being used anywhere in the tests, removing |
||
testUsingContext( | ||
'runner disable telemetry with flag', | ||
() async { | ||
|
@@ -346,6 +341,62 @@ void main() { | |
ProcessManager: () => FakeProcessManager.any(), | ||
}, | ||
); | ||
|
||
testUsingContext( | ||
'runner enabling telemetry with flag', | ||
() async { | ||
io.setExitFunctionForTests((int exitCode) {}); | ||
|
||
expect(globals.analytics.telemetryEnabled, false); | ||
expect(globals.analytics.shouldShowMessage, false); | ||
|
||
await runner.run( | ||
<String>['--enable-telemetry'], | ||
() => <FlutterCommand>[], | ||
// This flutterVersion disables crash reporting. | ||
flutterVersion: '[user-branch]/', | ||
shutdownHooks: ShutdownHooks(), | ||
); | ||
|
||
expect(globals.analytics.telemetryEnabled, true); | ||
}, | ||
overrides: <Type, Generator>{ | ||
Analytics: () => FakeAnalytics(fakeTelemetryStatusOverride: false), | ||
FileSystem: () => MemoryFileSystem.test(), | ||
ProcessManager: () => FakeProcessManager.any(), | ||
}, | ||
); | ||
|
||
testUsingContext( | ||
'throw error when both flags passed', | ||
() async { | ||
io.setExitFunctionForTests((int exitCode) {}); | ||
|
||
expect(globals.analytics.telemetryEnabled, true); | ||
expect(globals.analytics.shouldShowMessage, true); | ||
|
||
final int exitCode = await runner.run( | ||
<String>[ | ||
'--disable-telemetry', | ||
'--enable-telemetry', | ||
], | ||
() => <FlutterCommand>[], | ||
// This flutterVersion disables crash reporting. | ||
flutterVersion: '[user-branch]/', | ||
shutdownHooks: ShutdownHooks(), | ||
); | ||
|
||
expect(exitCode, 1, | ||
reason: 'Should return 1 due to conflicting options for telemetry'); | ||
expect(globals.analytics.telemetryEnabled, true, | ||
reason: 'Should not have changed from initialization'); | ||
}, | ||
overrides: <Type, Generator>{ | ||
Analytics: () => FakeAnalytics(), | ||
FileSystem: () => MemoryFileSystem.test(), | ||
ProcessManager: () => FakeProcessManager.any(), | ||
}, | ||
); | ||
}); | ||
} | ||
|
||
|
@@ -489,8 +540,16 @@ class WaitingCrashReporter implements CrashReporter { | |
/// A fake [Analytics] that will be used to test | ||
/// the --disable-telemetry flag | ||
class FakeAnalytics extends Fake implements Analytics { | ||
bool _fakeTelemetryStatus = true; | ||
bool _fakeShowMessage = true; | ||
|
||
FakeAnalytics({bool fakeTelemetryStatusOverride = true}) | ||
: _fakeTelemetryStatus = fakeTelemetryStatusOverride, | ||
_fakeShowMessage = fakeTelemetryStatusOverride; | ||
|
||
// Both of the members below can be initialized with [fakeTelemetryStatusOverride] | ||
// because if we pass in false for the status, that means we can also | ||
// assume the message has been shown before | ||
bool _fakeTelemetryStatus; | ||
bool _fakeShowMessage; | ||
|
||
@override | ||
String get getConsentMessage => 'message'; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is an exit code of
1
appropriate for this exit code? @gspencergoogThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think so. Anything non-zero would work.