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
238dac14
Unverified
Commit
238dac14
authored
Feb 15, 2020
by
Jonah Williams
Committed by
GitHub
Feb 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "[flutter_tools] More Linux version detail (#50739)" (#50840)
This reverts commit
c725f107
.
parent
1602be6a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
178 deletions
+83
-178
os.dart
packages/flutter_tools/lib/src/base/os.dart
+14
-41
os_test.dart
packages/flutter_tools/test/general.shard/base/os_test.dart
+25
-137
os_utils_test.dart
.../flutter_tools/test/general.shard/base/os_utils_test.dart
+44
-0
No files found.
packages/flutter_tools/lib/src/base/os.dart
View file @
238dac14
...
@@ -251,48 +251,21 @@ class _PosixUtils extends OperatingSystemUtils {
...
@@ -251,48 +251,21 @@ class _PosixUtils extends OperatingSystemUtils {
@override
@override
String
get
name
{
String
get
name
{
if
(
_name
!=
null
)
{
if
(
_name
==
null
)
{
return
_name
;
}
if
(
_platform
.
isMacOS
)
{
if
(
_platform
.
isMacOS
)
{
return
_name
=
_macName
;
}
else
if
(
_platform
.
isLinux
)
{
return
_name
=
_linuxName
;
}
return
_name
=
super
.
name
;
}
String
get
_macName
{
final
List
<
RunResult
>
results
=
<
RunResult
>[
final
List
<
RunResult
>
results
=
<
RunResult
>[
_processUtils
.
runSync
(<
String
>[
'sw_vers'
,
'-productName'
]),
_processUtils
.
runSync
(<
String
>[
'sw_vers'
,
'-productName'
]),
_processUtils
.
runSync
(<
String
>[
'sw_vers'
,
'-productVersion'
]),
_processUtils
.
runSync
(<
String
>[
'sw_vers'
,
'-productVersion'
]),
_processUtils
.
runSync
(<
String
>[
'sw_vers'
,
'-buildVersion'
]),
_processUtils
.
runSync
(<
String
>[
'sw_vers'
,
'-buildVersion'
]),
];
];
if
(
results
.
every
((
RunResult
result
)
=>
result
.
exitCode
==
0
))
{
if
(
results
.
every
((
RunResult
result
)
=>
result
.
exitCode
==
0
))
{
return
'
${results[0].stdout.trim()}
'
_name
=
'
${results[0].stdout.trim()}
${results[1].stdout
'
${results[1].stdout.trim()}
'
.trim()}
${results[2].stdout.trim()}
'
;
'
${results[2].stdout.trim()}
'
;
}
}
}
return
super
.
name
;
_name
??=
super
.
name
;
}
}
return
_name
;
String
get
_linuxName
{
final
String
fullVersion
=
_platform
.
operatingSystemVersion
;
// This is formatted as 'Linux version build'. The 'build' part can be
// somewhat long and is not very informative, so omit it.
final
List
<
String
>
versionParts
=
fullVersion
.
split
(
' '
);
if
(
versionParts
.
length
<
2
)
{
// The version string didn't have the expected format. Just return the
// full string.
return
fullVersion
;
}
final
String
system
=
versionParts
[
0
];
final
String
version
=
versionParts
[
1
];
if
(
system
!=
'Linux'
)
{
// If the system name isn't 'Linux', then just return the full string.
return
fullVersion
;
}
return
'
$system
$version
'
;
}
}
@override
@override
...
...
packages/flutter_tools/test/general.shard/base/os_test.dart
View file @
238dac14
...
@@ -4,17 +4,16 @@
...
@@ -4,17 +4,16 @@
import
'package:file/file.dart'
;
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:mockito/mockito.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
import
'package:process/process.dart'
;
import
'package:platform/platform.dart'
;
import
'package:platform/platform.dart'
;
import
'../../src/common.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/context.dart'
;
import
'../../src/fake_process_manager.dart'
;
const
String
kExecutable
=
'foo'
;
const
String
kExecutable
=
'foo'
;
const
String
kPath1
=
'/bar/bin/
$kExecutable
'
;
const
String
kPath1
=
'/bar/bin/
$kExecutable
'
;
...
@@ -23,51 +22,40 @@ const String kPath2 = '/another/bin/$kExecutable';
...
@@ -23,51 +22,40 @@ const String kPath2 = '/another/bin/$kExecutable';
class
MockLogger
extends
Mock
implements
Logger
{}
class
MockLogger
extends
Mock
implements
Logger
{}
void
main
(
)
{
void
main
(
)
{
FakeProcessManager
fakeProcessManager
;
MockProcessManager
mockProcessManager
;
setUp
(()
{
mockProcessManager
=
MockProcessManager
();
});
OperatingSystemUtils
createOSUtils
(
Platform
platform
)
{
OperatingSystemUtils
createOSUtils
(
Platform
platform
)
{
return
OperatingSystemUtils
(
return
OperatingSystemUtils
(
fileSystem:
MemoryFileSystem
(),
fileSystem:
MemoryFileSystem
(),
logger:
MockLogger
(),
logger:
MockLogger
(),
platform:
platform
,
platform:
platform
,
processManager:
fake
ProcessManager
,
processManager:
mock
ProcessManager
,
);
);
}
}
group
(
'which on POSIX'
,
()
{
group
(
'which on POSIX'
,
()
{
testWithoutContext
(
'returns null when executable does not exist'
,
()
async
{
testWithoutContext
(
'returns null when executable does not exist'
,
()
async
{
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
when
(
mockProcessManager
.
runSync
(<
String
>[
'which'
,
kExecutable
]))
const
FakeCommand
(
command:
<
String
>[
'which'
,
kExecutable
],
exitCode:
1
),
.
thenReturn
(
ProcessResult
(
0
,
1
,
null
,
null
));
]);
final
OperatingSystemUtils
utils
=
createOSUtils
(
FakePlatform
(
operatingSystem:
'linux'
));
final
OperatingSystemUtils
utils
=
createOSUtils
(
FakePlatform
(
operatingSystem:
'linux'
),
);
expect
(
utils
.
which
(
kExecutable
),
isNull
);
expect
(
utils
.
which
(
kExecutable
),
isNull
);
});
});
testWithoutContext
(
'returns exactly one result'
,
()
async
{
testWithoutContext
(
'returns exactly one result'
,
()
async
{
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
when
(
mockProcessManager
.
runSync
(<
String
>[
'which'
,
'foo'
]))
const
FakeCommand
(
.
thenReturn
(
ProcessResult
(
0
,
0
,
kPath1
,
null
));
command:
<
String
>[
'which'
,
kExecutable
],
final
OperatingSystemUtils
utils
=
createOSUtils
(
FakePlatform
(
operatingSystem:
'linux'
));
stdout:
kPath1
,
),
]);
final
OperatingSystemUtils
utils
=
createOSUtils
(
FakePlatform
(
operatingSystem:
'linux'
),
);
expect
(
utils
.
which
(
kExecutable
).
path
,
kPath1
);
expect
(
utils
.
which
(
kExecutable
).
path
,
kPath1
);
});
});
testWithoutContext
(
'returns all results for whichAll'
,
()
async
{
testWithoutContext
(
'returns all results for whichAll'
,
()
async
{
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
when
(
mockProcessManager
.
runSync
(<
String
>[
'which'
,
'-a'
,
kExecutable
]))
const
FakeCommand
(
.
thenReturn
(
ProcessResult
(
0
,
0
,
'
$kPath1
\n
$kPath2
'
,
null
));
command:
<
String
>[
'which'
,
'-a'
,
kExecutable
],
final
OperatingSystemUtils
utils
=
createOSUtils
(
FakePlatform
(
operatingSystem:
'linux'
));
stdout:
'
$kPath1
\n
$kPath2
\n
'
,
),
]);
final
OperatingSystemUtils
utils
=
createOSUtils
(
FakePlatform
(
operatingSystem:
'linux'
),
);
final
List
<
File
>
result
=
utils
.
whichAll
(
kExecutable
);
final
List
<
File
>
result
=
utils
.
whichAll
(
kExecutable
);
expect
(
result
,
hasLength
(
2
));
expect
(
result
,
hasLength
(
2
));
expect
(
result
[
0
].
path
,
kPath1
);
expect
(
result
[
0
].
path
,
kPath1
);
...
@@ -77,129 +65,29 @@ void main() {
...
@@ -77,129 +65,29 @@ void main() {
group
(
'which on Windows'
,
()
{
group
(
'which on Windows'
,
()
{
testWithoutContext
(
'returns null when executable does not exist'
,
()
async
{
testWithoutContext
(
'returns null when executable does not exist'
,
()
async
{
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
when
(
mockProcessManager
.
runSync
(<
String
>[
'where'
,
kExecutable
]))
const
FakeCommand
(
.
thenReturn
(
ProcessResult
(
0
,
1
,
null
,
null
));
command:
<
String
>[
'where'
,
kExecutable
],
final
OperatingSystemUtils
utils
=
createOSUtils
(
FakePlatform
(
operatingSystem:
'windows'
));
exitCode:
1
,
),
]);
final
OperatingSystemUtils
utils
=
createOSUtils
(
FakePlatform
(
operatingSystem:
'windows'
),
);
expect
(
utils
.
which
(
kExecutable
),
isNull
);
expect
(
utils
.
which
(
kExecutable
),
isNull
);
});
});
testWithoutContext
(
'returns exactly one result'
,
()
async
{
testWithoutContext
(
'returns exactly one result'
,
()
async
{
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
when
(
mockProcessManager
.
runSync
(<
String
>[
'where'
,
'foo'
]))
const
FakeCommand
(
.
thenReturn
(
ProcessResult
(
0
,
0
,
'
$kPath1
\n
$kPath2
'
,
null
));
command:
<
String
>[
'where'
,
kExecutable
],
final
OperatingSystemUtils
utils
=
createOSUtils
(
FakePlatform
(
operatingSystem:
'windows'
));
stdout:
'
$kPath1
\n
$kPath2
\n
'
,
),
]);
final
OperatingSystemUtils
utils
=
createOSUtils
(
FakePlatform
(
operatingSystem:
'windows'
),
);
expect
(
utils
.
which
(
kExecutable
).
path
,
kPath1
);
expect
(
utils
.
which
(
kExecutable
).
path
,
kPath1
);
});
});
testWithoutContext
(
'returns all results for whichAll'
,
()
async
{
testWithoutContext
(
'returns all results for whichAll'
,
()
async
{
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
when
(
mockProcessManager
.
runSync
(<
String
>[
'where'
,
kExecutable
]))
const
FakeCommand
(
.
thenReturn
(
ProcessResult
(
0
,
0
,
'
$kPath1
\n
$kPath2
'
,
null
));
command:
<
String
>[
'where'
,
kExecutable
],
final
OperatingSystemUtils
utils
=
createOSUtils
(
FakePlatform
(
operatingSystem:
'windows'
));
stdout:
'
$kPath1
\n
$kPath2
\n
'
,
),
]);
final
OperatingSystemUtils
utils
=
createOSUtils
(
FakePlatform
(
operatingSystem:
'windows'
),
);
final
List
<
File
>
result
=
utils
.
whichAll
(
kExecutable
);
final
List
<
File
>
result
=
utils
.
whichAll
(
kExecutable
);
expect
(
result
,
hasLength
(
2
));
expect
(
result
,
hasLength
(
2
));
expect
(
result
[
0
].
path
,
kPath1
);
expect
(
result
[
0
].
path
,
kPath1
);
expect
(
result
[
1
].
path
,
kPath2
);
expect
(
result
[
1
].
path
,
kPath2
);
});
});
});
});
group
(
'name'
,
()
{
testWithoutContext
(
'on Linux'
,
()
{
final
FakePlatform
platform
=
FakePlatform
(
operatingSystem:
'linux'
,
operatingSystemVersion:
'Linux 5.2.17-amd64 '
'#1 SMP Debian 5.2.17 (2019-10-21 > 2018)'
,
);
final
OperatingSystemUtils
utils
=
createOSUtils
(
platform
);
expect
(
utils
.
name
,
'Linux 5.2.17-amd64'
);
});
testWithoutContext
(
'on Mac'
,
()
{
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'sw_vers'
,
'-productName'
],
stdout:
'Mac OS X
\n
'
,
),
const
FakeCommand
(
command:
<
String
>[
'sw_vers'
,
'-productVersion'
],
stdout:
'10.14.6
\n
'
,
),
const
FakeCommand
(
command:
<
String
>[
'sw_vers'
,
'-buildVersion'
],
stdout:
'16G2128
\n
'
,
),
]);
final
FakePlatform
platform
=
FakePlatform
(
operatingSystem:
'macos'
,
);
final
OperatingSystemUtils
utils
=
createOSUtils
(
platform
);
expect
(
utils
.
name
,
'Mac OS X 10.14.6 16G2128'
);
});
testWithoutContext
(
'on Windows'
,
()
{
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'ver'
],
stdout:
'Microsoft Windows [Version 10.0.17763.740]'
,
),
]);
final
FakePlatform
platform
=
FakePlatform
(
operatingSystem:
'windows'
,
);
final
OperatingSystemUtils
utils
=
createOSUtils
(
platform
);
expect
(
utils
.
name
,
'Microsoft Windows [Version 10.0.17763.740]'
);
});
});
group
(
'makeExecutable'
,
()
{
Directory
tempDir
;
setUp
(()
{
tempDir
=
globals
.
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_tools_os_utils_test.'
,
);
});
tearDown
(()
{
tryToDelete
(
tempDir
);
});
testUsingContext
(
'makeExecutable'
,
()
async
{
final
File
file
=
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
tempDir
.
path
,
'foo.script'
,
));
file
.
writeAsStringSync
(
'hello world'
);
globals
.
os
.
makeExecutable
(
file
);
final
String
mode
=
file
.
statSync
().
modeString
();
// rwxr--r--
expect
(
mode
.
substring
(
0
,
3
),
endsWith
(
'x'
));
},
overrides:
<
Type
,
Generator
>{
OperatingSystemUtils:
()
=>
OperatingSystemUtils
(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
platform:
globals
.
platform
,
processManager:
globals
.
processManager
,
),
},
skip:
const
LocalPlatform
().
isWindows
);
});
}
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
packages/flutter_tools/test/general.shard/base/os_utils_test.dart
0 → 100644
View file @
238dac14
// Copyright 2014 The Flutter 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/file_system.dart'
;
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
void
main
(
)
{
group
(
'OperatingSystemUtils'
,
()
{
Directory
tempDir
;
setUp
(()
{
tempDir
=
globals
.
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_tools_os_utils_test.'
);
});
tearDown
(()
{
tryToDelete
(
tempDir
);
});
testUsingContext
(
'makeExecutable'
,
()
async
{
final
File
file
=
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
tempDir
.
path
,
'foo.script'
));
file
.
writeAsStringSync
(
'hello world'
);
globals
.
os
.
makeExecutable
(
file
);
// Skip this test on windows.
if
(!
globals
.
platform
.
isWindows
)
{
final
String
mode
=
file
.
statSync
().
modeString
();
// rwxr--r--
expect
(
mode
.
substring
(
0
,
3
),
endsWith
(
'x'
));
}
},
overrides:
<
Type
,
Generator
>{
OperatingSystemUtils:
()
=>
OperatingSystemUtils
(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
platform:
globals
.
platform
,
processManager:
globals
.
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