@@ -15,14 +15,14 @@ const String _kInitialVersion = '3.0.0';
1515const String _kBranch = 'beta' ;
1616
1717final Stdio stdio = Stdio ();
18- final ProcessUtils processUtils = ProcessUtils (processManager : processManager, logger : StdoutLogger (
18+ final BufferLogger logger = BufferLogger . test (
1919 terminal: AnsiTerminal (
2020 platform: platform,
2121 stdio: stdio,
2222 ),
23- stdio: stdio,
2423 outputPreferences: OutputPreferences .test (wrapText: true ),
25- ));
24+ );
25+ final ProcessUtils processUtils = ProcessUtils (processManager: processManager, logger: logger);
2626final String flutterBin = fileSystem.path.join (getFlutterRoot (), 'bin' , platform.isWindows ? 'flutter.bat' : 'flutter' );
2727
2828/// A test for flutter upgrade & downgrade that checks out a parallel flutter repo.
@@ -48,13 +48,29 @@ void main() {
4848 'git' , 'config' , '--system' , 'core.longpaths' , 'true' ,
4949 ]);
5050
51+ void checkExitCode (int code) {
52+ expect (
53+ exitCode,
54+ 0 ,
55+ reason: '''
56+ trace:
57+ ${logger .traceText }
58+
59+ status:
60+ ${logger .statusText }
61+
62+ error:
63+ ${logger .errorText }''' ,
64+ );
65+ }
66+
5167 printOnFailure ('Step 1 - clone the $_kBranch of flutter into the test directory' );
5268 exitCode = await processUtils.stream (< String > [
5369 'git' ,
5470 'clone' ,
5571 'https://github.com/flutter/flutter.git' ,
5672 ], workingDirectory: parentDirectory.path, trace: true );
57- expect (exitCode, 0 );
73+ checkExitCode (exitCode);
5874
5975 printOnFailure ('Step 2 - switch to the $_kBranch ' );
6076 exitCode = await processUtils.stream (< String > [
@@ -65,7 +81,7 @@ void main() {
6581 _kBranch,
6682 'origin/$_kBranch ' ,
6783 ], workingDirectory: testDirectory.path, trace: true );
68- expect (exitCode, 0 );
84+ checkExitCode (exitCode);
6985
7086 printOnFailure ('Step 3 - revert back to $_kInitialVersion ' );
7187 exitCode = await processUtils.stream (< String > [
@@ -74,7 +90,7 @@ void main() {
7490 '--hard' ,
7591 _kInitialVersion,
7692 ], workingDirectory: testDirectory.path, trace: true );
77- expect (exitCode, 0 );
93+ checkExitCode (exitCode);
7894
7995 printOnFailure ('Step 4 - upgrade to the newest $_kBranch ' );
8096 // This should update the persistent tool state with the sha for HEAD
@@ -84,8 +100,10 @@ void main() {
84100 'upgrade' ,
85101 '--verbose' ,
86102 '--working-directory=${testDirectory .path }' ,
87- ], workingDirectory: testDirectory.path, trace: true );
88- expect (exitCode, 0 );
103+ // we intentionally run this in a directory outside the test repo to
104+ // verify the tool overrides the working directory when invoking git
105+ ], workingDirectory: parentDirectory.path, trace: true );
106+ checkExitCode (exitCode);
89107
90108 printOnFailure ('Step 5 - verify that the version is different' );
91109 final RunResult versionResult = await processUtils.run (< String > [
@@ -105,8 +123,8 @@ void main() {
105123 'downgrade' ,
106124 '--no-prompt' ,
107125 '--working-directory=${testDirectory .path }' ,
108- ], workingDirectory: testDirectory .path, trace: true );
109- expect (exitCode, 0 );
126+ ], workingDirectory: parentDirectory .path, trace: true );
127+ checkExitCode (exitCode);
110128
111129 printOnFailure ('Step 7 - verify downgraded version matches original version' );
112130 final RunResult oldVersionResult = await processUtils.run (< String > [
0 commit comments