@@ -153,4 +153,44 @@ packages:
153
153
process.stdout, emits ('An unexpected exception has occurred.' ));
154
154
await process.shouldExit (70 );
155
155
});
156
+
157
+ test ('should succeed with valid configuration' , () async {
158
+ var exampleDirectory = p.absolute (p.join (p.current, '..' , 'example' ));
159
+ var process = await TestProcess .start ('pub' , ['get' ],
160
+ workingDirectory: exampleDirectory, environment: _getPubEnvironment ());
161
+
162
+ await process.shouldExit (0 );
163
+
164
+ await d.file ('.packages' , isNotEmpty).validate (exampleDirectory);
165
+ await d.file ('pubspec.lock' , isNotEmpty).validate (exampleDirectory);
166
+
167
+ process = await TestProcess .start (
168
+ 'dart' , [_webdevBin, 'build' , '-o' , d.sandbox],
169
+ workingDirectory: exampleDirectory);
170
+
171
+ var output = await process.stdoutStream ().join ('\n ' );
172
+
173
+ expect (output, contains (d.sandbox));
174
+ expect (output, contains ('[INFO] Succeeded' ));
175
+ await process.shouldExit (0 );
176
+
177
+ await d.file ('web/main.dart.js' , isNotEmpty).validate ();
178
+ }, timeout: const Timeout .factor (4 ));
179
+ }
180
+
181
+ /// Returns an environment map that includes `PUB_ENVIRONMENT` .
182
+ ///
183
+ /// Maintains any existing values for this environment var.
184
+ /// Adds a new value that flags this is a bot/test and not human usage.
185
+ Map <String , String > _getPubEnvironment () {
186
+ var pubEnvironmentKey = 'PUB_ENVIRONMENT' ;
187
+ var pubEnvironment = Platform .environment[pubEnvironmentKey] ?? '' ;
188
+ if (pubEnvironment.isNotEmpty) {
189
+ pubEnvironment = '$pubEnvironment ;' ;
190
+ }
191
+ pubEnvironment = '${pubEnvironment }bot.pkg.webdev.test' ;
192
+
193
+ var environment = {'PUB_ENVIRONMENT' : pubEnvironment};
194
+
195
+ return environment;
156
196
}
0 commit comments