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
71bfe3be
Unverified
Commit
71bfe3be
authored
Jun 10, 2019
by
Jonah Williams
Committed by
GitHub
Jun 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "More verification on flutter build web, add tests and cleanup (#34090)" (#34166)
parent
354ce1aa
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
51 additions
and
234 deletions
+51
-234
application_package.dart
packages/flutter_tools/lib/src/application_package.dart
+0
-3
project.dart
packages/flutter_tools/lib/src/project.dart
+2
-5
resident_web_runner.dart
packages/flutter_tools/lib/src/resident_web_runner.dart
+2
-10
compile.dart
packages/flutter_tools/lib/src/web/compile.dart
+0
-3
build_linux_test.dart
packages/flutter_tools/test/commands/build_linux_test.dart
+14
-23
build_macos_test.dart
packages/flutter_tools/test/commands/build_macos_test.dart
+15
-25
build_web_test.dart
packages/flutter_tools/test/commands/build_web_test.dart
+0
-96
build_windows_test.dart
packages/flutter_tools/test/commands/build_windows_test.dart
+17
-28
testbed.dart
packages/flutter_tools/test/src/testbed.dart
+1
-41
No files found.
packages/flutter_tools/lib/src/application_package.dart
View file @
71bfe3be
...
@@ -57,9 +57,6 @@ class ApplicationPackageFactory {
...
@@ -57,9 +57,6 @@ class ApplicationPackageFactory {
?
MacOSApp
.
fromMacOSProject
(
FlutterProject
.
current
().
macos
)
?
MacOSApp
.
fromMacOSProject
(
FlutterProject
.
current
().
macos
)
:
MacOSApp
.
fromPrebuiltApp
(
applicationBinary
);
:
MacOSApp
.
fromPrebuiltApp
(
applicationBinary
);
case
TargetPlatform
.
web_javascript
:
case
TargetPlatform
.
web_javascript
:
if
(!
FlutterProject
.
current
().
web
.
existsSync
())
{
return
null
;
}
return
WebApplicationPackage
(
FlutterProject
.
current
());
return
WebApplicationPackage
(
FlutterProject
.
current
());
case
TargetPlatform
.
linux_x64
:
case
TargetPlatform
.
linux_x64
:
return
applicationBinary
==
null
return
applicationBinary
==
null
...
...
packages/flutter_tools/lib/src/project.dart
View file @
71bfe3be
...
@@ -580,14 +580,11 @@ class WebProject {
...
@@ -580,14 +580,11 @@ class WebProject {
/// Whether this flutter project has a web sub-project.
/// Whether this flutter project has a web sub-project.
bool
existsSync
()
{
bool
existsSync
()
{
return
parent
.
directory
.
childDirectory
(
'web'
).
existsSync
()
return
parent
.
directory
.
childDirectory
(
'web'
).
existsSync
();
&&
indexFile
.
existsSync
();
}
}
/// The html file used to host the flutter web application.
/// The html file used to host the flutter web application.
File
get
indexFile
=>
parent
.
directory
File
get
indexFile
=>
parent
.
directory
.
childDirectory
(
'web'
).
childFile
(
'index.html'
);
.
childDirectory
(
'web'
)
.
childFile
(
'index.html'
);
Future
<
void
>
ensureReadyForPlatformSpecificTooling
()
async
{}
Future
<
void
>
ensureReadyForPlatformSpecificTooling
()
async
{}
}
}
...
...
packages/flutter_tools/lib/src/resident_web_runner.dart
View file @
71bfe3be
...
@@ -7,7 +7,6 @@ import 'dart:async';
...
@@ -7,7 +7,6 @@ import 'dart:async';
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
import
'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'
;
import
'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'
;
import
'application_package.dart'
;
import
'asset.dart'
;
import
'asset.dart'
;
import
'base/common.dart'
;
import
'base/common.dart'
;
import
'base/file_system.dart'
;
import
'base/file_system.dart'
;
...
@@ -113,14 +112,7 @@ class ResidentWebRunner extends ResidentRunner {
...
@@ -113,14 +112,7 @@ class ResidentWebRunner extends ResidentRunner {
String
route
,
String
route
,
bool
shouldBuild
=
true
,
bool
shouldBuild
=
true
,
})
async
{
})
async
{
final
ApplicationPackage
package
=
await
ApplicationPackageFactory
.
instance
.
getPackageForPlatform
(
final
FlutterProject
currentProject
=
FlutterProject
.
current
();
TargetPlatform
.
web_javascript
,
applicationBinary:
null
,
);
if
(
package
==
null
)
{
printError
(
'No application found for TargetPlatform.web_javascript'
);
return
1
;
}
if
(!
fs
.
isFileSync
(
mainPath
))
{
if
(!
fs
.
isFileSync
(
mainPath
))
{
String
message
=
'Tried to run
$mainPath
, but that file does not exist.'
;
String
message
=
'Tried to run
$mainPath
, but that file does not exist.'
;
if
(
target
==
null
)
{
if
(
target
==
null
)
{
...
@@ -132,7 +124,7 @@ class ResidentWebRunner extends ResidentRunner {
...
@@ -132,7 +124,7 @@ class ResidentWebRunner extends ResidentRunner {
}
}
// Start the web compiler and build the assets.
// Start the web compiler and build the assets.
await
webCompilationProxy
.
initialize
(
await
webCompilationProxy
.
initialize
(
projectDirectory:
FlutterProject
.
current
()
.
directory
,
projectDirectory:
currentProject
.
directory
,
targets:
<
String
>[
target
],
targets:
<
String
>[
target
],
);
);
_lastCompiled
=
DateTime
.
now
();
_lastCompiled
=
DateTime
.
now
();
...
...
packages/flutter_tools/lib/src/web/compile.dart
View file @
71bfe3be
...
@@ -19,9 +19,6 @@ import '../usage.dart';
...
@@ -19,9 +19,6 @@ import '../usage.dart';
WebCompilationProxy
get
webCompilationProxy
=>
context
.
get
<
WebCompilationProxy
>();
WebCompilationProxy
get
webCompilationProxy
=>
context
.
get
<
WebCompilationProxy
>();
Future
<
void
>
buildWeb
(
FlutterProject
flutterProject
,
String
target
,
BuildInfo
buildInfo
)
async
{
Future
<
void
>
buildWeb
(
FlutterProject
flutterProject
,
String
target
,
BuildInfo
buildInfo
)
async
{
if
(!
flutterProject
.
web
.
existsSync
())
{
throwToolExit
(
'Missing index.html.'
);
}
final
Status
status
=
logger
.
startProgress
(
'Compiling
$target
for the Web...'
,
timeout:
null
);
final
Status
status
=
logger
.
startProgress
(
'Compiling
$target
for the Web...'
,
timeout:
null
);
final
Stopwatch
sw
=
Stopwatch
()..
start
();
final
Stopwatch
sw
=
Stopwatch
()..
start
();
final
Directory
outputDir
=
fs
.
directory
(
getWebBuildDirectory
())
final
Directory
outputDir
=
fs
.
directory
(
getWebBuildDirectory
())
...
...
packages/flutter_tools/test/commands/build_linux_test.dart
View file @
71bfe3be
...
@@ -19,20 +19,12 @@ import '../src/context.dart';
...
@@ -19,20 +19,12 @@ import '../src/context.dart';
import
'../src/mocks.dart'
;
import
'../src/mocks.dart'
;
void
main
(
)
{
void
main
(
)
{
MockProcessManager
mockProcessManager
;
MockProcess
mockProcess
;
MockPlatform
linuxPlatform
;
MockPlatform
notLinuxPlatform
;
setUpAll
(()
{
Cache
.
disableLocking
();
Cache
.
disableLocking
();
});
final
MockProcessManager
mockProcessManager
=
MockProcessManager
();
final
MockProcess
mockProcess
=
MockProcess
();
final
MockPlatform
linuxPlatform
=
MockPlatform
();
final
MockPlatform
notLinuxPlatform
=
MockPlatform
();
setUp
(()
{
mockProcessManager
=
MockProcessManager
();
mockProcess
=
MockProcess
();
linuxPlatform
=
MockPlatform
();
notLinuxPlatform
=
MockPlatform
();
when
(
mockProcess
.
exitCode
).
thenAnswer
((
Invocation
invocation
)
async
{
when
(
mockProcess
.
exitCode
).
thenAnswer
((
Invocation
invocation
)
async
{
return
0
;
return
0
;
});
});
...
@@ -44,7 +36,6 @@ void main() {
...
@@ -44,7 +36,6 @@ void main() {
});
});
when
(
linuxPlatform
.
isLinux
).
thenReturn
(
true
);
when
(
linuxPlatform
.
isLinux
).
thenReturn
(
true
);
when
(
notLinuxPlatform
.
isLinux
).
thenReturn
(
false
);
when
(
notLinuxPlatform
.
isLinux
).
thenReturn
(
false
);
});
testUsingContext
(
'Linux build fails when there is no linux project'
,
()
async
{
testUsingContext
(
'Linux build fails when there is no linux project'
,
()
async
{
final
BuildCommand
command
=
BuildCommand
();
final
BuildCommand
command
=
BuildCommand
();
...
...
packages/flutter_tools/test/commands/build_macos_test.dart
View file @
71bfe3be
...
@@ -19,22 +19,13 @@ import '../src/context.dart';
...
@@ -19,22 +19,13 @@ import '../src/context.dart';
import
'../src/mocks.dart'
;
import
'../src/mocks.dart'
;
void
main
(
)
{
void
main
(
)
{
MockProcessManager
mockProcessManager
;
MemoryFileSystem
memoryFilesystem
;
MockProcess
mockProcess
;
MockPlatform
macosPlatform
;
MockPlatform
notMacosPlatform
;
setUpAll
(()
{
Cache
.
disableLocking
();
Cache
.
disableLocking
();
});
final
MockProcessManager
mockProcessManager
=
MockProcessManager
();
final
MemoryFileSystem
memoryFilesystem
=
MemoryFileSystem
();
final
MockProcess
mockProcess
=
MockProcess
();
final
MockPlatform
macosPlatform
=
MockPlatform
();
final
MockPlatform
notMacosPlatform
=
MockPlatform
();
setUp
(()
{
mockProcessManager
=
MockProcessManager
();
memoryFilesystem
=
MemoryFileSystem
();
mockProcess
=
MockProcess
();
macosPlatform
=
MockPlatform
();
notMacosPlatform
=
MockPlatform
();
when
(
mockProcess
.
exitCode
).
thenAnswer
((
Invocation
invocation
)
async
{
when
(
mockProcess
.
exitCode
).
thenAnswer
((
Invocation
invocation
)
async
{
return
0
;
return
0
;
});
});
...
@@ -46,7 +37,6 @@ void main() {
...
@@ -46,7 +37,6 @@ void main() {
});
});
when
(
macosPlatform
.
isMacOS
).
thenReturn
(
true
);
when
(
macosPlatform
.
isMacOS
).
thenReturn
(
true
);
when
(
notMacosPlatform
.
isMacOS
).
thenReturn
(
false
);
when
(
notMacosPlatform
.
isMacOS
).
thenReturn
(
false
);
});
testUsingContext
(
'macOS build fails when there is no macos project'
,
()
async
{
testUsingContext
(
'macOS build fails when there is no macos project'
,
()
async
{
final
BuildCommand
command
=
BuildCommand
();
final
BuildCommand
command
=
BuildCommand
();
...
...
packages/flutter_tools/test/commands/build_web_test.dart
deleted
100644 → 0
View file @
354ce1aa
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/resident_runner.dart'
;
import
'package:flutter_tools/src/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
'../src/common.dart'
;
import
'../src/testbed.dart'
;
void
main
(
)
{
MockWebCompilationProxy
mockWebCompilationProxy
;
Testbed
testbed
;
MockPlatform
mockPlatform
;
setUpAll
(()
{
Cache
.
disableLocking
();
});
setUp
(()
{
mockWebCompilationProxy
=
MockWebCompilationProxy
();
testbed
=
Testbed
(
setup:
()
{
fs
.
file
(
'pubspec.yaml'
)
..
createSync
()
..
writeAsStringSync
(
'name: foo
\n
'
);
fs
.
file
(
'.packages'
).
createSync
();
fs
.
file
(
fs
.
path
.
join
(
'web'
,
'index.html'
)).
createSync
(
recursive:
true
);
fs
.
file
(
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
when
(
mockWebCompilationProxy
.
initialize
(
projectDirectory:
anyNamed
(
'projectDirectory'
),
targets:
anyNamed
(
'targets'
),
release:
anyNamed
(
'release'
)
)).
thenAnswer
((
Invocation
invocation
)
{
final
String
path
=
fs
.
path
.
join
(
'.dart_tool'
,
'build'
,
'flutter_web'
,
'foo'
,
'lib'
,
'main_web_entrypoint.dart.js'
);
fs
.
file
(
path
).
createSync
(
recursive:
true
);
fs
.
file
(
'
$path
.map'
).
createSync
();
return
Future
<
bool
>.
value
(
true
);
});
},
overrides:
<
Type
,
Generator
>{
WebCompilationProxy:
()
=>
mockWebCompilationProxy
,
Platform:
()
=>
mockPlatform
,
FlutterVersion:
()
=>
MockFlutterVersion
(),
});
});
test
(
'Refuses to build for web when missing index.html'
,
()
=>
testbed
.
run
(()
async
{
fs
.
file
(
fs
.
path
.
join
(
'web'
,
'index.html'
)).
deleteSync
();
expect
(
buildWeb
(
FlutterProject
.
current
(),
fs
.
path
.
join
(
'lib'
,
'main.dart'
),
BuildInfo
.
debug
,
),
throwsA
(
isInstanceOf
<
ToolExit
>()));
}));
test
(
'Refuses to build using runner when missing index.html'
,
()
=>
testbed
.
run
(()
async
{
fs
.
file
(
fs
.
path
.
join
(
'web'
,
'index.html'
)).
deleteSync
();
final
ResidentWebRunner
runner
=
ResidentWebRunner
(
<
FlutterDevice
>[],
flutterProject:
FlutterProject
.
current
(),
ipv6:
false
,
);
expect
(
await
runner
.
run
(),
1
);
}));
test
(
'Can build for web'
,
()
=>
testbed
.
run
(()
async
{
await
buildWeb
(
FlutterProject
.
current
(),
fs
.
path
.
join
(
'lib'
,
'main.dart'
),
BuildInfo
.
debug
,
);
}));
}
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
isStable
=>
false
;
}
packages/flutter_tools/test/commands/build_windows_test.dart
View file @
71bfe3be
...
@@ -19,28 +19,18 @@ import '../src/context.dart';
...
@@ -19,28 +19,18 @@ import '../src/context.dart';
import
'../src/mocks.dart'
;
import
'../src/mocks.dart'
;
void
main
(
)
{
void
main
(
)
{
MockProcessManager
mockProcessManager
;
Cache
.
disableLocking
();
MemoryFileSystem
memoryFilesystem
;
final
MockProcessManager
mockProcessManager
=
MockProcessManager
();
MockProcess
mockProcess
;
final
MemoryFileSystem
memoryFilesystem
=
MemoryFileSystem
(
style:
FileSystemStyle
.
windows
);
MockPlatform
windowsPlatform
;
final
MockProcess
mockProcess
=
MockProcess
();
MockPlatform
notWindowsPlatform
;
final
MockPlatform
windowsPlatform
=
MockPlatform
()
MockVisualStudio
mockVisualStudio
;
..
environment
[
'PROGRAMFILES(X86)'
]
=
r'C:\Program Files (x86)\'
;
final
MockPlatform
notWindowsPlatform
=
MockPlatform
();
final
MockVisualStudio
mockVisualStudio
=
MockVisualStudio
();
const
String
solutionPath
=
r'C:\windows\Runner.sln'
;
const
String
solutionPath
=
r'C:\windows\Runner.sln'
;
const
String
visualStudioPath
=
r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community'
;
const
String
visualStudioPath
=
r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community'
;
const
String
vcvarsPath
=
visualStudioPath
+
r'\VC\Auxiliary\Build\vcvars64.bat'
;
const
String
vcvarsPath
=
visualStudioPath
+
r'\VC\Auxiliary\Build\vcvars64.bat'
;
setUpAll
(()
{
Cache
.
disableLocking
();
});
setUp
(()
{
mockProcessManager
=
MockProcessManager
();
memoryFilesystem
=
MemoryFileSystem
(
style:
FileSystemStyle
.
windows
);
mockProcess
=
MockProcess
();
windowsPlatform
=
MockPlatform
()
..
environment
[
'PROGRAMFILES(X86)'
]
=
r'C:\Program Files (x86)\'
;
notWindowsPlatform
=
MockPlatform
();
mockVisualStudio
=
MockVisualStudio
();
when
(
mockProcess
.
exitCode
).
thenAnswer
((
Invocation
invocation
)
async
{
when
(
mockProcess
.
exitCode
).
thenAnswer
((
Invocation
invocation
)
async
{
return
0
;
return
0
;
});
});
...
@@ -52,7 +42,6 @@ void main() {
...
@@ -52,7 +42,6 @@ void main() {
});
});
when
(
windowsPlatform
.
isWindows
).
thenReturn
(
true
);
when
(
windowsPlatform
.
isWindows
).
thenReturn
(
true
);
when
(
notWindowsPlatform
.
isWindows
).
thenReturn
(
false
);
when
(
notWindowsPlatform
.
isWindows
).
thenReturn
(
false
);
});
testUsingContext
(
'Windows build fails when there is no vcvars64.bat'
,
()
async
{
testUsingContext
(
'Windows build fails when there is no vcvars64.bat'
,
()
async
{
final
BuildCommand
command
=
BuildCommand
();
final
BuildCommand
command
=
BuildCommand
();
...
...
packages/flutter_tools/test/src/testbed.dart
View file @
71bfe3be
...
@@ -11,7 +11,6 @@ import 'package:flutter_tools/src/base/logger.dart';
...
@@ -11,7 +11,6 @@ import 'package:flutter_tools/src/base/logger.dart';
import
'package:flutter_tools/src/base/terminal.dart'
;
import
'package:flutter_tools/src/base/terminal.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/context_runner.dart'
;
import
'package:flutter_tools/src/context_runner.dart'
;
import
'package:flutter_tools/src/usage.dart'
;
import
'context.dart'
;
import
'context.dart'
;
...
@@ -25,7 +24,6 @@ final Map<Type, Generator> _testbedDefaults = <Type, Generator>{
...
@@ -25,7 +24,6 @@ final Map<Type, Generator> _testbedDefaults = <Type, Generator>{
FileSystem:
()
=>
MemoryFileSystem
(),
// Keeps tests fast by avoid actual file system.
FileSystem:
()
=>
MemoryFileSystem
(),
// Keeps tests fast by avoid actual file system.
Logger:
()
=>
BufferLogger
(),
// Allows reading logs and prevents stdout.
Logger:
()
=>
BufferLogger
(),
// Allows reading logs and prevents stdout.
OutputPreferences:
()
=>
OutputPreferences
(
showColor:
false
),
// configures BufferLogger to avoid color codes.
OutputPreferences:
()
=>
OutputPreferences
(
showColor:
false
),
// configures BufferLogger to avoid color codes.
Usage:
()
=>
NoOpUsage
(),
// prevent addition of analytics from burdening test mocks
};
};
/// Manages interaction with the tool injection and runner system.
/// Manages interaction with the tool injection and runner system.
...
@@ -62,7 +60,7 @@ class Testbed {
...
@@ -62,7 +60,7 @@ class Testbed {
/// `overrides` provides more overrides in addition to the test defaults.
/// `overrides` provides more overrides in addition to the test defaults.
/// `setup` may be provided to apply mocks within the tool managed zone,
/// `setup` may be provided to apply mocks within the tool managed zone,
/// including any specified overrides.
/// including any specified overrides.
Testbed
({
Future
Or
<
void
>
Function
()
setup
,
Map
<
Type
,
Generator
>
overrides
})
Testbed
({
Future
<
void
>
Function
()
setup
,
Map
<
Type
,
Generator
>
overrides
})
:
_setup
=
setup
,
:
_setup
=
setup
,
_overrides
=
overrides
;
_overrides
=
overrides
;
...
@@ -103,41 +101,3 @@ class Testbed {
...
@@ -103,41 +101,3 @@ class Testbed {
});
});
}
}
}
}
/// A no-op implementation of [Usage] for testing.
class
NoOpUsage
implements
Usage
{
@override
bool
enabled
=
false
;
@override
bool
suppressAnalytics
=
true
;
@override
String
get
clientId
=>
'test'
;
@override
Future
<
void
>
ensureAnalyticsSent
()
{
return
null
;
}
@override
bool
get
isFirstRun
=>
false
;
@override
Stream
<
Map
<
String
,
Object
>>
get
onSend
=>
const
Stream
<
Object
>.
empty
();
@override
void
printWelcome
()
{}
@override
void
sendCommand
(
String
command
,
{
Map
<
String
,
String
>
parameters
})
{}
@override
void
sendEvent
(
String
category
,
String
parameter
,
{
Map
<
String
,
String
>
parameters
})
{}
@override
void
sendException
(
dynamic
exception
,
StackTrace
trace
)
{}
@override
void
sendTiming
(
String
category
,
String
variableName
,
Duration
duration
,
{
String
label
})
{}
}
\ No newline at end of file
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