ISandbox

public interface ISandbox

com.android.tradefed.sandbox.ISandbox


用于定义可用于运行调用的沙盒的接口。

摘要

公共方法

abstract String createClasspath(File workingDir)

根据 getTradefedSandboxEnvironment(IInvocationContext,IConfiguration,String[]) 返回的环境和工作目录创建类路径。

abstract IConfiguration createThinLauncherConfig(String[] args, IKeyStoreClient keyStoreClient, IRunUtil runUtil, File globalConfig)

与主运行断开连接的特殊模式:如果父级中似乎不存在配置,我们会回退到精简启动器,尝试使用当前已知信息设置沙盒,并填充工作目录以在版本化目录中完全创建配置。

default Map<String, List<String>> discoverTests(IInvocationContext context, IConfiguration configuration)

prepareEnvironment(IInvocationContext,IConfiguration,ITestInvocationListener) 的一个子步骤,用于在启用 SandboxOptions.shouldUseTestDiscovery() 时发现测试。

default Map<String, List<String>> discoverTests(IInvocationContext context, IConfiguration configuration, ITestLogger logger)
default IFolderBuildInfo fetchSandboxExtraArtifacts(IInvocationContext context, IConfiguration configuration, String[] args)

prepareEnvironment(IInvocationContext,IConfiguration,ITestInvocationListener) 的子步骤,用于获取沙盒所需的其他文件。

default File getTradefedSandboxEnvironment(IInvocationContext context, IConfiguration nonVersionedConfig, String[] args)

根据命令行实参返回要使用的沙盒环境 TF。

default File getTradefedSandboxEnvironment(IInvocationContext context, IConfiguration nonVersionedConfig, ITestLogger logger, String[] args)
abstract Exception prepareEnvironment(IInvocationContext context, IConfiguration configuration, ITestInvocationListener listener)

准备沙盒正常运行所需的环境。

abstract CommandResult run(TestInformation info, IConfiguration configuration, ITestLogger logger)

使用已设置的环境运行沙盒。

abstract void tearDown()

清理可能已更改的任何状态、文件或环境。

公共方法

createClasspath

public abstract String createClasspath (File workingDir)

根据 getTradefedSandboxEnvironment(IInvocationContext,IConfiguration,String[]) 返回的环境和工作目录创建类路径。

参数
workingDir File:沙盒的当前工作目录。

返回
String 要使用的类路径。

抛出
ConfigurationException

createThinLauncherConfig

public abstract IConfiguration createThinLauncherConfig (String[] args, 
                IKeyStoreClient keyStoreClient, 
                IRunUtil runUtil, 
                File globalConfig)

与主运行断开连接的特殊模式:如果父级中似乎不存在配置,我们会回退到精简启动器,尝试使用当前已知信息设置沙盒,并填充工作目录以在版本化目录中完全创建配置。

参数
args String:原始命令行实参。

keyStoreClient IKeyStoreClient:用于创建配置的当前密钥库客户端。

runUtil IRunUtil:用于运行主机命令的当前 IRunUtil

globalConfig File:用于运行 TF 子进程的全局配置。

返回
IConfiguration 指向非版本化对象的 TF 配置 XML 的文件。如果无法创建精简启动器配置,则返回 null。

discoverTests

public Map<String, List<String>> discoverTests (IInvocationContext context, 
                IConfiguration configuration)

prepareEnvironment(IInvocationContext,IConfiguration,ITestInvocationListener) 的一个子步骤,用于在启用 SandboxOptions.shouldUseTestDiscovery() 时发现测试。

参数
context IInvocationContext:当前调用 IInvocationContext

configuration IConfiguration:要运行的命令的 IConfiguration

返回
Map<String, List<String>> 发现的测试的映射,如果不支持或失败,则为 null。

discoverTests

public Map<String, List<String>> discoverTests (IInvocationContext context, 
                IConfiguration configuration, 
                ITestLogger logger)

参数
context IInvocationContext

configuration IConfiguration

logger ITestLogger

返回
Map<String, List<String>>

fetchSandboxExtraArtifacts

public IFolderBuildInfo fetchSandboxExtraArtifacts (IInvocationContext context, 
                IConfiguration configuration, 
                String[] args)

prepareEnvironment(IInvocationContext,IConfiguration,ITestInvocationListener) 的子步骤,用于提取沙盒所需的其他文件。

参数
context IInvocationContext:当前调用 IInvocationContext

configuration IConfiguration:要运行的命令的 IConfiguration

args String:命令行实参。

返回
IFolderBuildInfo 为其他沙盒文件提取的 build。

抛出
com.android.tradefed.build.BuildRetrievalError
com.android.tradefed.config.ConfigurationException
java.io.IOException
BuildRetrievalError
ConfigurationException
IOException

getTradefedSandboxEnvironment

public File getTradefedSandboxEnvironment (IInvocationContext context, 
                IConfiguration nonVersionedConfig, 
                String[] args)

根据命令行实参返回要使用的沙盒环境 TF。

参数
context IInvocationContext:父级的 IInvocationContext

nonVersionedConfig IConfiguration:表示无版本控制对象的 IConfiguration

args String:命令行实参。

返回
File 一个 File 目录,其中包含 TF 沙盒环境 jar。

抛出
Exception

getTradefedSandboxEnvironment

public File getTradefedSandboxEnvironment (IInvocationContext context, 
                IConfiguration nonVersionedConfig, 
                ITestLogger logger, 
                String[] args)

参数
context IInvocationContext

nonVersionedConfig IConfiguration

logger ITestLogger

args String

返回
File

抛出
Exception

prepareEnvironment

public abstract Exception prepareEnvironment (IInvocationContext context, 
                IConfiguration configuration, 
                ITestInvocationListener listener)

准备环境,以便沙盒正常运行。

参数
context IInvocationContext:当前调用 IInvocationContext

configuration IConfiguration:要运行的命令的 IConfiguration

listener ITestInvocationListener:当前调用 ITestInvocationListener,最终结果应通过管道传输到该调用。

返回
Exception 包含失败信息的 Exception;如果成功,则为 Null。

run

public abstract CommandResult run (TestInformation info, 
                IConfiguration configuration, 
                ITestLogger logger)

运行已设置环境的沙盒。

参数
info TestInformation:描述调用的 TestInformation

configuration IConfiguration:要运行的命令的 IConfiguration

logger ITestLogger:一个可以记录文件的 ITestLogger

返回
CommandResult 一个 CommandResult,其中包含沙盒运行的状态和日志。

抛出
Throwable

tearDown

public abstract void tearDown ()

清理可能已更改的任何状态、文件或环境。