MemoryExecutionEnv class final
In-memory ExecutionEnv: MemoryFileSystem plus a Shell.
The default shell is UnavailableShell; pass a custom shell to test
shell-consuming code without spawning real processes. When the shell
implements BackgroundShell (the app's sandbox shells do), the env
forwards detached-job calls to it.
- Inheritance
-
- Object
- MemoryFileSystem
- MemoryExecutionEnv
- Implemented types
Constructors
- MemoryExecutionEnv({String cwd = '/', Shell shell = const UnavailableShell()})
-
Creates a MemoryExecutionEnv rooted at
cwd.
Properties
- backgroundJobsSupported → bool
-
Whether startShellJob actually works here. Decorators forward their
delegate's answer, so wrapping an env never fakes the capability.
no setteroverride
- cwd → String
-
Current working directory for relative paths.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
absolutePath(
String path) → Future< Result< String, FileError> > -
Returns an absolute addressed path without requiring it to exist and
without resolving symlinks.
inherited
-
appendFile(
String path, String content) → Future< Result< void, FileError> > -
Creates or appends to a file, creating parent directories.
inherited
-
createDir(
String path, {bool recursive = true}) → Future< Result< void, FileError> > -
Creates a directory. When
recursiveis true (the default), missing parents are created too.inherited -
exec(
String command, {ShellExecOptions? options}) → Future< Result< ShellExecResult, ExecutionError> > -
Executes a shell command. Must never throw: all failures are encoded in
the returned Result.
override
-
exists(
String path) → Future< Result< bool, FileError> > -
Returns
falsefor missing paths; other errors surface as Err.inherited -
fileInfo(
String path) → Future< Result< FileInfo, FileError> > -
Returns metadata for the addressed path without following symlinks.
inherited
-
joinPath(
List< String> parts) → Future<Result< String, FileError> > -
Joins path segments in the filesystem namespace without requiring the
result to exist.
inherited
-
listDir(
String path) → Future< Result< List< >FileInfo> , FileError> -
Lists the direct children of a directory.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
readBinaryFile(
String path) → Future< Result< Uint8List, FileError> > -
Reads the file as raw bytes.
inherited
-
readTextFile(
String path) → Future< Result< String, FileError> > -
Reads a UTF-8 text file.
inherited
-
readTextLines(
String path, {int? maxLines}) → Future< Result< List< >String> , FileError> -
Reads UTF-8 text lines. Implementations should stop once
maxLineslines have been read.inherited -
remove(
String path, {bool recursive = false, bool force = false}) → Future< Result< void, FileError> > -
Removes a file or directory. With
force, a missing path is not an error.inherited -
setMtime(
String path, int mtimeMs) → void -
Test-only: updates the modification time of
pathtomtimeMs. No-op when the file does not exist.inherited -
startShellJob(
String command, {required String id, required String logPath, ShellExecOptions? options}) → Future< Result< ShellJob, ExecutionError> > -
Starts
commanddetached: stdout/stderr append tologPathand the returned ShellJob keeps running until it exits or is stopped. ShellExecOptions.timeout and ShellExecOptions.cancelToken still apply (both stop the job).override -
toString(
) → String -
A string representation of this object.
inherited
-
writeBinaryFile(
String path, Uint8List content) → Future< Result< void, FileError> > -
Writes raw bytes to a file, creating parent directories.
inherited
-
writeFile(
String path, String content) → Future< Result< void, FileError> > -
Creates or overwrites a file, creating parent directories.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited