From dafdd642a688b3609985c2a3d38c4030a81824a4 Mon Sep 17 00:00:00 2001 From: wengchangcheng Date: Thu, 21 Oct 2021 16:56:38 +0800 Subject: [PATCH] copy all testcase resources and fix codestyle Signed-off-by: wengchangcheng --- BUILD.gn | 13 ++++++++----- ecmascript/builtins/builtins_promise.cpp | 11 +++++------ ecmascript/ecma_module.cpp | 2 +- ecmascript/interpreter/fast_runtime_stub-inl.h | 16 ++++++++-------- test/copy_resource.py | 13 ++++++------- 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 61a21036be..042bdd5acf 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -436,7 +436,7 @@ source_set("libark_jsruntime_test_static") { sources += intl_sources deps = [ - ":copy_resource_xml", + ":copy_ark_resource", "$ark_root/libpandabase:libarkbase", "$ark_root/libpandafile:libarkfile", "$ark_root/runtime:arkruntime_header_deps", @@ -478,25 +478,28 @@ ohos_shared_library("libark_jsruntime_test") { subsystem_name = "test" } -action("copy_resource_xml") { +action("copy_ark_resource") { deps = [] script = "//ark/js_runtime/test/copy_resource.py" - src_path = "//ark/js_runtime/test/resource/js_runtime/" + src_path = "//ark/js_runtime/test/resource/js_runtime" src_xml = "ohos_test.xml" dst_path = "//ark/test/resource/js_runtime/" args = [ "--src-path", - rebase_path(src_path), + rebase_path("${src_path}/"), "--src-xml", src_xml, "--dst-path", rebase_path(dst_path), ] - inputs = [ src_path + src_xml ] + inputs = [ + src_path, + "${src_path}/${src_xml}", + ] outputs = [ "$target_out_dir" ] } diff --git a/ecmascript/builtins/builtins_promise.cpp b/ecmascript/builtins/builtins_promise.cpp index 663bd1df9a..5cdd765d68 100644 --- a/ecmascript/builtins/builtins_promise.cpp +++ b/ecmascript/builtins/builtins_promise.cpp @@ -399,14 +399,13 @@ JSTaggedValue BuiltinsPromise::PerformPromiseThen(JSThread *thread, const JSHand if (JSTaggedValue::SameValue(promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::PENDING)))) { JSHandle fulfillReactions(thread, promise->GetPromiseFulfillReactions()); - auto result = - JSTaggedValue(TaggedQueue::Push(thread, fulfillReactions, JSHandle::Cast(fulfillReaction))); - promise->SetPromiseFulfillReactions(thread, result); + TaggedQueue *newQueue = + TaggedQueue::Push(thread, fulfillReactions, JSHandle::Cast(fulfillReaction)); + promise->SetPromiseFulfillReactions(thread, JSTaggedValue(newQueue)); JSHandle rejectReactions(thread, promise->GetPromiseRejectReactions()); - result = - JSTaggedValue(TaggedQueue::Push(thread, rejectReactions, JSHandle::Cast(rejectReaction))); - promise->SetPromiseRejectReactions(thread, result); + newQueue = TaggedQueue::Push(thread, rejectReactions, JSHandle::Cast(rejectReaction)); + promise->SetPromiseRejectReactions(thread, JSTaggedValue(newQueue)); } else if (JSTaggedValue::SameValue(promise->GetPromiseState(), JSTaggedValue(static_cast(PromiseStatus::FULFILLED)))) { JSHandle argv = factory->NewTaggedArray(2); // 2: 2 means two args stored in array diff --git a/ecmascript/ecma_module.cpp b/ecmascript/ecma_module.cpp index cebd2c0aea..edeaadc50e 100644 --- a/ecmascript/ecma_module.cpp +++ b/ecmascript/ecma_module.cpp @@ -61,7 +61,7 @@ void EcmaModule::RemoveItem(const JSThread *thread, JSHandle module, JSHandle moduleItems(data); int entry = moduleItems->FindEntry(itemName.GetTaggedValue()); if (entry != -1) { - NameDictionary *newDict = NameDictionary::Remove(thread, moduleItems, entry); // discard return + NameDictionary *newDict = NameDictionary::Remove(thread, moduleItems, entry); module->SetNameDictionary(thread, JSTaggedValue(newDict)); } } diff --git a/ecmascript/interpreter/fast_runtime_stub-inl.h b/ecmascript/interpreter/fast_runtime_stub-inl.h index 7d2faab112..055ba3b912 100644 --- a/ecmascript/interpreter/fast_runtime_stub-inl.h +++ b/ecmascript/interpreter/fast_runtime_stub-inl.h @@ -880,9 +880,9 @@ bool FastRuntimeStub::SetPropertyByName(JSThread *thread, JSTaggedValue receiver if (receiver.IsJSGlobalObject()) { [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle dict_handle(thread, properties); + JSHandle dictHandle(thread, properties); // globalobj have no internal accessor - GlobalDictionary::InvalidatePropertyBox(thread, dict_handle, indexOrEntry, attr); + GlobalDictionary::InvalidatePropertyBox(thread, dictHandle, indexOrEntry, attr); return true; } @@ -961,7 +961,7 @@ bool FastRuntimeStub::SetGlobalOwnProperty(JSThread *thread, JSTaggedValue recei JSHandle keyHandle(thread, key); JSHandle valHandle(thread, value); JSHandle objHandle(thread, obj); - JSHandle dict_handle(thread, GlobalDictionary::Create(thread)); + JSHandle dictHandle(thread, GlobalDictionary::Create(thread)); // Add PropertyBox to global dictionary ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); @@ -971,7 +971,7 @@ bool FastRuntimeStub::SetGlobalOwnProperty(JSThread *thread, JSTaggedValue recei attr.SetBoxType(boxType); GlobalDictionary *properties = - GlobalDictionary::PutIfAbsent(thread, dict_handle, keyHandle, JSHandle(boxHandle), attr); + GlobalDictionary::PutIfAbsent(thread, dictHandle, keyHandle, JSHandle(boxHandle), attr); objHandle->SetProperties(thread, JSTaggedValue(properties)); return true; } @@ -983,8 +983,8 @@ bool FastRuntimeStub::SetGlobalOwnProperty(JSThread *thread, JSTaggedValue recei if (!attr.IsAccessor()) { if (attr.IsWritable()) { // globalobj have no internal accessor - JSHandle dict_handle(thread, dict); - GlobalDictionary::InvalidatePropertyBox(thread, dict_handle, entry, attr); + JSHandle dictHandle(thread, dict); + GlobalDictionary::InvalidatePropertyBox(thread, dictHandle, entry, attr); return true; } } @@ -1011,7 +1011,7 @@ bool FastRuntimeStub::SetGlobalOwnProperty(JSThread *thread, JSTaggedValue recei JSHandle keyHandle(thread, key); JSHandle valHandle(thread, value); JSHandle objHandle(thread, obj); - JSHandle dict_handle(thread, dict); + JSHandle dictHandle(thread, dict); // Add PropertyBox to global dictionary ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); @@ -1021,7 +1021,7 @@ bool FastRuntimeStub::SetGlobalOwnProperty(JSThread *thread, JSTaggedValue recei attr.SetBoxType(boxType); GlobalDictionary *properties = - GlobalDictionary::PutIfAbsent(thread, dict_handle, keyHandle, JSHandle(boxHandle), attr); + GlobalDictionary::PutIfAbsent(thread, dictHandle, keyHandle, JSHandle(boxHandle), attr); objHandle->SetProperties(thread, JSTaggedValue(properties)); return true; } diff --git a/test/copy_resource.py b/test/copy_resource.py index b6b3a10cd1..dfaa369555 100755 --- a/test/copy_resource.py +++ b/test/copy_resource.py @@ -35,21 +35,20 @@ def parse_args(): return args -def copy_xml(args): - """copy resource xml to test direction.""" +def copy_res(args): + """copy resources to test direction.""" src_xml_file = os.path.join(args.src_path, args.src_xml) - dst_xml_file = os.path.join(args.dst_path, args.src_xml) if not os.path.isfile(src_xml_file): print(args.src_xml + " not exist.") return - if not os.path.exists(args.dst_path): - os.makedirs(args.dst_path) + if os.path.exists(args.dst_path): + shutil.rmtree(args.dst_path) - shutil.copyfile(src_xml_file, dst_xml_file) + shutil.copytree(args.src_path, args.dst_path) if __name__ == '__main__': input_args = parse_args() - copy_xml(input_args) + copy_res(input_args) -- Gitee