Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
9295b348
Unverified
Commit
9295b348
authored
Feb 20, 2020
by
Jonah Williams
Committed by
GitHub
Feb 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup of tool build tests (#50904)
parent
1793108b
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
331 additions
and
331 deletions
+331
-331
build_fuchsia_test.dart
...ools/test/commands.shard/hermetic/build_fuchsia_test.dart
+79
-81
build_linux_test.dart
..._tools/test/commands.shard/hermetic/build_linux_test.dart
+100
-98
build_macos_test.dart
..._tools/test/commands.shard/hermetic/build_macos_test.dart
+69
-91
build_web_test.dart
...er_tools/test/commands.shard/hermetic/build_web_test.dart
+83
-60
fake_process_manager.dart
packages/flutter_tools/test/src/fake_process_manager.dart
+0
-1
No files found.
packages/flutter_tools/test/commands.shard/hermetic/build_fuchsia_test.dart
View file @
9295b348
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart
View file @
9295b348
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/commands.shard/hermetic/build_macos_test.dart
View file @
9295b348
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart
View file @
9295b348
...
...
@@ -3,6 +3,8 @@
// found in the LICENSE file.
import
'package:args/command_runner.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:platform/platform.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
...
...
@@ -15,18 +17,22 @@ import 'package:flutter_tools/src/device.dart';
import
'package:flutter_tools/src/features.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/build_runner/resident_web_runner.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:flutter_tools/src/web/compile.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/mocks.dart'
;
import
'../../src/testbed.dart'
;
void
main
(
)
{
Testbed
testbed
;
MockPlatform
mockPlatform
;
FileSystem
fileSystem
;
final
Platform
fakePlatform
=
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{
'FLUTTER_ROOT'
:
'/'
}
);
setUpAll
(()
{
Cache
.
flutterRoot
=
''
;
...
...
@@ -34,36 +40,36 @@ void main() {
});
setUp
(()
{
testbed
=
Testbed
(
setup:
()
{
globals
.
fs
.
file
(
'pubspec.yaml'
)
fileSystem
=
MemoryFileSystem
.
test
();
fileSystem
.
file
(
'pubspec.yaml'
)
..
createSync
()
..
writeAsStringSync
(
'name: foo
\n
'
);
globals
.
fs
.
file
(
'.packages'
).
createSync
();
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'web'
,
'index.html'
)).
createSync
(
recursive:
true
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
mockPlatform
,
FlutterVersion:
()
=>
MockFlutterVersion
(),
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
true
),
Pub:
()
=>
MockPub
(),
});
fileSystem
.
file
(
'.packages'
).
createSync
();
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'web'
,
'index.html'
)).
createSync
(
recursive:
true
);
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
});
test
(
'Refuses to build for web when missing index.html'
,
()
=>
testbed
.
run
(
()
async
{
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'web'
,
'index.html'
)).
deleteSync
();
test
UsingContext
(
'Refuses to build for web when missing index.html'
,
()
async
{
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'web'
,
'index.html'
)).
deleteSync
();
expect
(
buildWeb
(
FlutterProject
.
current
(),
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
),
fileSystem
.
path
.
join
(
'lib'
,
'main.dart'
),
BuildInfo
.
debug
,
false
,
const
<
String
>[],
false
,
),
throwsToolExit
());
}));
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
fakePlatform
,
FileSystem:
()
=>
fileSystem
,
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
true
),
Pub:
()
=>
MockPub
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
test
(
'Refuses to build using runner when missing index.html'
,
()
=>
testbed
.
run
(
()
async
{
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'web'
,
'index.html'
)).
deleteSync
();
test
UsingContext
(
'Refuses to build using runner when missing index.html'
,
()
async
{
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'web'
,
'index.html'
)).
deleteSync
();
final
ResidentWebRunner
runner
=
DwdsWebRunnerFactory
().
createWebRunner
(
null
,
...
...
@@ -75,48 +81,64 @@ void main() {
urlTunneller:
null
,
)
as
ResidentWebRunner
;
expect
(
await
runner
.
run
(),
1
);
}));
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
fakePlatform
,
FileSystem:
()
=>
fileSystem
,
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
true
),
Pub:
()
=>
MockPub
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
test
(
'Refuses to build a debug build for web'
,
()
=>
testbed
.
run
(
()
async
{
test
UsingContext
(
'Refuses to build a debug build for web'
,
()
async
{
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
BuildCommand
());
expect
(()
=>
runner
.
run
(<
String
>[
'build'
,
'web'
,
'--debug'
]),
throwsA
(
isA
<
UsageException
>()));
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
fakePlatform
,
FileSystem:
()
=>
fileSystem
,
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
true
),
}));
Pub:
()
=>
MockPub
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
test
(
'Refuses to build for web when feature is disabled'
,
()
=>
testbed
.
run
(
()
async
{
test
UsingContext
(
'Refuses to build for web when feature is disabled'
,
()
async
{
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
BuildCommand
());
expect
(()
=>
runner
.
run
(<
String
>[
'build'
,
'web'
]),
throwsToolExit
());
expect
(
()
=>
runner
.
run
(<
String
>[
'build'
,
'web'
]),
throwsToolExit
(),
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
fakePlatform
,
FileSystem:
()
=>
fileSystem
,
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
false
),
}));
Pub:
()
=>
MockPub
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
test
(
'Builds a web bundle - end to end'
,
()
=>
testbed
.
run
(
()
async
{
test
UsingContext
(
'Builds a web bundle - end to end'
,
()
async
{
final
BuildCommand
buildCommand
=
BuildCommand
();
applyMocksToCommand
(
buildCommand
);
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
buildCommand
);
final
List
<
String
>
dependencies
=
<
String
>[
globals
.
fs
.
path
.
join
(
'packages'
,
'flutter_tools'
,
'lib'
,
'src'
,
'build_system'
,
'targets'
,
'web.dart'
),
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'flutter_web_sdk'
),
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'snapshots'
,
'dart2js.dart.snapshot'
),
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'dart'
),
globals
.
fs
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk '
),
fileSystem
.
path
.
join
(
'packages'
,
'flutter_tools'
,
'lib'
,
'src'
,
'build_system'
,
'targets'
,
'web.dart'
),
fileSystem
.
path
.
join
(
'bin'
,
'cache'
,
'flutter_web_sdk'
),
fileSystem
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'snapshots'
,
'dart2js.dart.snapshot'
),
fileSystem
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'dart'
),
fileSystem
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk '
),
];
for
(
final
String
dependency
in
dependencies
)
{
globals
.
fs
.
file
(
dependency
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
dependency
).
createSync
(
recursive:
true
);
}
// Project files.
globals
.
fs
.
file
(
'.packages'
)
fileSystem
.
file
(
'.packages'
)
..
writeAsStringSync
(
'''
foo:lib/
fizz:bar/lib/
'''
);
globals
.
fs
.
file
(
'pubspec.yaml'
)
fileSystem
.
file
(
'pubspec.yaml'
)
..
writeAsStringSync
(
'''
name: foo
...
...
@@ -127,7 +149,7 @@ dependencies:
path:
bar/
'''
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'bar'
,
'pubspec.yaml'
))
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'bar'
,
'pubspec.yaml'
))
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'''
name: bar
...
...
@@ -139,12 +161,12 @@ flutter:
pluginClass: UrlLauncherPlugin
fileName: url_launcher_web.dart
'''
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'bar'
,
'lib'
,
'url_launcher_web.dart'
))
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'bar'
,
'lib'
,
'url_launcher_web.dart'
))
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'''
class UrlLauncherPlugin {}
'''
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
))
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'lib'
,
'main.dart'
))
..
writeAsStringSync
(
'void main() { }'
);
// Process calls. We're not testing that these invocations are correct because
...
...
@@ -154,35 +176,36 @@ class UrlLauncherPlugin {}
});
await
runner
.
run
(<
String
>[
'build'
,
'web'
]);
expect
(
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'generated_plugin_registrant.dart'
)).
existsSync
(),
true
);
expect
(
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'lib'
,
'generated_plugin_registrant.dart'
)).
existsSync
(),
true
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
fakePlatform
,
FileSystem:
()
=>
fileSystem
,
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
true
),
Pub:
()
=>
MockPub
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
BuildSystem:
()
=>
MockBuildSystem
(),
})
)
;
});
test
(
'hidden if feature flag is not enabled'
,
()
=>
testbed
.
run
(
()
async
{
test
UsingContext
(
'hidden if feature flag is not enabled'
,
()
async
{
expect
(
BuildWebCommand
().
hidden
,
true
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
fakePlatform
,
FileSystem:
()
=>
fileSystem
,
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
false
),
}));
Pub:
()
=>
MockPub
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
test
(
'not hidden if feature flag is enabled'
,
()
=>
testbed
.
run
(
()
async
{
test
UsingContext
(
'not hidden if feature flag is enabled'
,
()
async
{
expect
(
BuildWebCommand
().
hidden
,
false
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
fakePlatform
,
FileSystem:
()
=>
fileSystem
,
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
true
),
}));
Pub:
()
=>
MockPub
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
}
class
MockBuildSystem
extends
Mock
implements
BuildSystem
{}
class
MockWebCompilationProxy
extends
Mock
implements
WebCompilationProxy
{}
class
MockPlatform
extends
Mock
implements
Platform
{
@override
Map
<
String
,
String
>
environment
=
<
String
,
String
>{
'FLUTTER_ROOT'
:
'/'
,
};
}
class
MockFlutterVersion
extends
Mock
implements
FlutterVersion
{
@override
bool
get
isMaster
=>
true
;
}
class
MockPub
extends
Mock
implements
Pub
{}
packages/flutter_tools/test/src/fake_process_manager.dart
View file @
9295b348
...
...
@@ -8,7 +8,6 @@ import 'dart:io' as io show ProcessSignal;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:meta/meta.dart'
;
import
'package:process/process.dart'
;
import
'common.dart'
;
export
'package:process/process.dart'
show
ProcessManager
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment