mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
#152 fix
This commit is contained in:
@@ -115,7 +115,7 @@ class PsResult {
|
|||||||
});
|
});
|
||||||
|
|
||||||
factory PsResult.parse(String raw, {ProcSortMode sort = ProcSortMode.cpu}) {
|
factory PsResult.parse(String raw, {ProcSortMode sort = ProcSortMode.cpu}) {
|
||||||
final lines = raw.split('\n');
|
final lines = raw.split('\n').map((e) => e.trim()).toList();
|
||||||
if (lines.isEmpty) return PsResult(procs: [], error: null);
|
if (lines.isEmpty) return PsResult(procs: [], error: null);
|
||||||
|
|
||||||
final header = lines[0];
|
final header = lines[0];
|
||||||
@@ -145,6 +145,7 @@ class PsResult {
|
|||||||
} catch (e, trace) {
|
} catch (e, trace) {
|
||||||
err += '$line: $e\n';
|
err += '$line: $e\n';
|
||||||
_logger.warning(trace);
|
_logger.warning(trace);
|
||||||
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
13
test/proc_test.dart
Normal file
13
test/proc_test.dart
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:toolbox/data/model/server/proc.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test('parse process', () {
|
||||||
|
const raw = '''
|
||||||
|
PID USER VSZ STAT COMMAND
|
||||||
|
1 root 1276 S /sbin/procd
|
||||||
|
''';
|
||||||
|
final psResult = PsResult.parse(raw);
|
||||||
|
expect(psResult.procs.length, 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user