mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 15:20:34 +00:00
Modify aa test command parameters (-b -p -m)
Signed-off-by: njupthan <hanhaibin@huawei.com>
This commit is contained in:
parent
eea7c8fbec
commit
ea163d6401
@ -26,6 +26,8 @@ namespace AppExecFwk {
|
||||
class AbilityDelegatorArgs {
|
||||
public:
|
||||
static const std::string KEY_TEST_BUNDLE_NAME;
|
||||
static const std::string KEY_TEST_PACKAGE_NAME;
|
||||
static const std::string KEY_TEST_MODULE_NAME;
|
||||
static const std::string KEY_TEST_RUNNER_CLASS;
|
||||
static const std::string KEY_TEST_CASE;
|
||||
static const std::string KEY_TEST_WAIT_TIMEOUT;
|
||||
@ -39,12 +41,17 @@ public:
|
||||
void SetTestBundleName(const std::string &bundleName);
|
||||
std::string GetTestBundleName() const;
|
||||
|
||||
std::string GetTestPackageName() const;
|
||||
std::string GetTestModuleName() const;
|
||||
std::string GetTestRunnerClassName() const;
|
||||
std::string GetTestCaseName() const;
|
||||
|
||||
void SetTestParam(const std::map<std::string, std::string> ¶ms);
|
||||
std::map<std::string, std::string> GetTestParam() const;
|
||||
|
||||
private:
|
||||
std::string GetParamValue(const std::string &key) const;
|
||||
|
||||
private:
|
||||
std::string bundleName_;
|
||||
std::map<std::string, std::string> params_;
|
||||
|
@ -17,7 +17,9 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
const std::string AbilityDelegatorArgs::KEY_TEST_BUNDLE_NAME {"-p"};
|
||||
const std::string AbilityDelegatorArgs::KEY_TEST_BUNDLE_NAME {"-b"};
|
||||
const std::string AbilityDelegatorArgs::KEY_TEST_PACKAGE_NAME {"-p"};
|
||||
const std::string AbilityDelegatorArgs::KEY_TEST_MODULE_NAME {"-m"};
|
||||
const std::string AbilityDelegatorArgs::KEY_TEST_RUNNER_CLASS {"-s unittest"};
|
||||
const std::string AbilityDelegatorArgs::KEY_TEST_CASE {"-s class"};
|
||||
const std::string AbilityDelegatorArgs::KEY_TEST_WAIT_TIMEOUT {"-w"};
|
||||
@ -48,24 +50,24 @@ std::string AbilityDelegatorArgs::GetTestBundleName() const
|
||||
return bundleName_;
|
||||
}
|
||||
|
||||
std::string AbilityDelegatorArgs::GetTestPackageName() const
|
||||
{
|
||||
return GetParamValue(AbilityDelegatorArgs::KEY_TEST_PACKAGE_NAME);
|
||||
}
|
||||
|
||||
std::string AbilityDelegatorArgs::GetTestModuleName() const
|
||||
{
|
||||
return GetParamValue(AbilityDelegatorArgs::KEY_TEST_MODULE_NAME);
|
||||
}
|
||||
|
||||
std::string AbilityDelegatorArgs::GetTestRunnerClassName() const
|
||||
{
|
||||
auto target = params_.find(AbilityDelegatorArgs::KEY_TEST_RUNNER_CLASS);
|
||||
if (target != params_.end()) {
|
||||
return target->second;
|
||||
}
|
||||
|
||||
return {};
|
||||
return GetParamValue(AbilityDelegatorArgs::KEY_TEST_RUNNER_CLASS);
|
||||
}
|
||||
|
||||
std::string AbilityDelegatorArgs::GetTestCaseName() const
|
||||
{
|
||||
auto target = params_.find(AbilityDelegatorArgs::KEY_TEST_CASE);
|
||||
if (target != params_.end()) {
|
||||
return target->second;
|
||||
}
|
||||
|
||||
return {};
|
||||
return GetParamValue(AbilityDelegatorArgs::KEY_TEST_CASE);
|
||||
}
|
||||
|
||||
void AbilityDelegatorArgs::SetTestParam(const std::map<std::string, std::string> ¶ms)
|
||||
@ -77,5 +79,11 @@ std::map<std::string, std::string> AbilityDelegatorArgs::GetTestParam() const
|
||||
{
|
||||
return params_;
|
||||
}
|
||||
|
||||
std::string AbilityDelegatorArgs::GetParamValue(const std::string &key) const
|
||||
{
|
||||
auto target = params_.find(key);
|
||||
return (target != params_.end()) ? target->second : std::string();
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -41,14 +41,18 @@ JsTestRunner::JsTestRunner(
|
||||
JsRuntime &jsRuntime, const std::shared_ptr<AbilityDelegatorArgs> &args, const AppExecFwk::BundleInfo &bundleInfo)
|
||||
: jsRuntime_(jsRuntime)
|
||||
{
|
||||
std::string prefix;
|
||||
std::string tempTestRunnerName = args->GetTestRunnerClassName();
|
||||
auto testRunnerName = tempTestRunnerName;
|
||||
|
||||
auto pos = tempTestRunnerName.find(":");
|
||||
if (pos != std::string::npos) {
|
||||
prefix = tempTestRunnerName.substr(0, pos);
|
||||
testRunnerName = tempTestRunnerName.substr(pos + 1);
|
||||
if (args) {
|
||||
std::string srcPath;
|
||||
if (bundleInfo.hapModuleInfos.back().isModuleJson) {
|
||||
srcPath.append(args->GetTestModuleName());
|
||||
srcPath.append("/ets/TestRunner/");
|
||||
} else {
|
||||
srcPath.append(args->GetTestPackageName());
|
||||
srcPath.append("/assets/js/TestRunner/");
|
||||
}
|
||||
srcPath.append(args->GetTestRunnerClassName());
|
||||
srcPath.append(".abc");
|
||||
srcPath_ = srcPath;
|
||||
}
|
||||
|
||||
std::string srcPath;
|
||||
@ -65,7 +69,7 @@ JsTestRunner::JsTestRunner(
|
||||
HILOG_INFO("JsTestRunner srcPath is %{public}s", srcPath.c_str());
|
||||
|
||||
std::string moduleName;
|
||||
jsTestRunnerObj_ = jsRuntime_.LoadModule(moduleName, srcPath);
|
||||
jsTestRunnerObj_ = jsRuntime_.LoadModule(moduleName, srcPath_);
|
||||
}
|
||||
|
||||
JsTestRunner::~JsTestRunner() = default;
|
||||
|
@ -3899,7 +3899,7 @@ void AbilityManagerService::PauseOldConnectManager(int32_t userId)
|
||||
HILOG_INFO("%{public}s, u0 not stop, id:%{public}d-----nullptr", __func__, userId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
auto it = connectManagers_.find(userId);
|
||||
if (it == connectManagers_.end()) {
|
||||
@ -4185,7 +4185,7 @@ int AbilityManagerService::StartUserTest(const Want &want, const sptr<IRemoteObj
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
std::string bundleName = want.GetStringParam("-p");
|
||||
std::string bundleName = want.GetStringParam("-b");
|
||||
if (bundleName.empty()) {
|
||||
HILOG_ERROR("Invalid bundle name");
|
||||
return ERR_INVALID_VALUE;
|
||||
|
@ -1874,12 +1874,8 @@ int AppMgrServiceInner::GetHapModuleInfoForTestRunner(const AAFwk::Want &want, c
|
||||
moduelJson = bundleInfo.hapModuleInfos.back().isModuleJson;
|
||||
}
|
||||
if (moduelJson) {
|
||||
std::string moudleName;
|
||||
auto testRunnerName = want.GetStringParam("-s unittest");
|
||||
auto pos = testRunnerName.find(":");
|
||||
if (pos != std::string::npos) {
|
||||
moudleName = testRunnerName.substr(0, pos);
|
||||
} else {
|
||||
std::string moudleName = want.GetStringParam("-m");
|
||||
if (moudleName.empty()) {
|
||||
UserTestAbnormalFinish(observer, "No module name isn't unspecified.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
@ -89,7 +89,11 @@ const std::string HELP_MSG_TEST =
|
||||
"usage: aa test <options>\n"
|
||||
"options list:\n"
|
||||
" -h, --help list available commands\n"
|
||||
" -p <bundle-name> -s unittest <test-runner> start the test framework with options\n"
|
||||
" -b <bundle-name> -s unittest <test-runner> start the test framework with options\n"
|
||||
" [-p <package-name>] the name of package with test-runner, "
|
||||
"required for the FA model\n"
|
||||
" [-m <module-name>] the name of module with test-runner, "
|
||||
"required for the STAGE model\n"
|
||||
" [-s class <test-class>]\n"
|
||||
" [-s level <test-level>]\n"
|
||||
" [-s size <test-size>]\n"
|
||||
|
@ -1227,7 +1227,7 @@ ErrCode AbilityManagerShellCommand::RunAsTestCommand()
|
||||
if (opt == "-h" || opt == "--help") {
|
||||
resultReceiver_.append(HELP_MSG_TEST);
|
||||
return OHOS::ERR_OK;
|
||||
} else if (opt == "-p" || opt == "-w") {
|
||||
} else if (opt == "-b" || opt == "-w" || opt == "-p" || opt == "-m") {
|
||||
if (i >= argc_ - 1) {
|
||||
return TestCommandError("error: option [" + opt + "] requires a value.\n");
|
||||
}
|
||||
@ -1256,7 +1256,7 @@ bool AbilityManagerShellCommand::IsTestCommandIntegrity(const std::map<std::stri
|
||||
{
|
||||
HILOG_INFO("enter");
|
||||
|
||||
std::vector<std::string> opts = {"-p", "-s unittest"};
|
||||
std::vector<std::string> opts = {"-b", "-s unittest"};
|
||||
for (auto opt : opts) {
|
||||
auto it = params.find(opt);
|
||||
if (it == params.end()) {
|
||||
|
Loading…
Reference in New Issue
Block a user