fix rollup mock is not independent for each test scenario

Signed-off-by: s00912778 <shijiakai2@huawei.com>
Change-Id: Iac37e4496351b66f6ae20b1b2f759b459d764132
This commit is contained in:
s00912778 2024-10-22 10:26:23 +08:00
parent 085ad246de
commit fca4f28fff
9 changed files with 264 additions and 332 deletions

View File

@ -1,107 +1,53 @@
@Entry
@Component
struct V2ToV2ComponentValidate {
build() {}
}
class A {
name: string
constructor(name: string) {
this.name = name
}
}
enum MemberType {
first = 1
}
@Observed
class TestObserved {
@Entry
@Component
struct V1ToV2Component {
build() {}
}
type newType = Set<number> | Set<string>
@ComponentV2
struct TestV2Parent1 {
string_value: string = "hello"
@Param string_value1: string | Set<string> = "hello"
regular_value: Set<string> = new Set()
@Local enum_value1: MemberType = MemberType.first
@Provider() local_value: TestObserved
@Consumer() enum_value: Set<number> | MemberType = MemberType.first
@Event func_value1: Function = () => {}
@Event func_value2: () => void = () => {}
@Local set_value: Set<number> | Set<string> = new Set<number>()
@Local set_value_alias: newType = new Set<string>()
@Component
struct TestV1Parent {
@State state_string_value: string = "hello"
@Prop prop_number_value: number = 1
@Link link_boolean_value: boolean
@Provide provide_enum_value: MemberType = MemberType.first
@Consume consume_null_value: null
@StorageLink("a") storage_link_undefined_value: undefined = undefined
@StorageProp("b") storage_prop_string_value: string = "hello"
@LocalStorageLink("c") func_value1: Function = () => {}
@LocalStorageProp("d") func_value2: () => void = () => {}
build() {
Column() {
TestV1Child1({
string_value: this.string_value,
string_value1: this.string_value1,
regular_value: this.regular_value,
enum_value1: this.enum_value1,
objectLink_value: this.local_value,
enum_value: this.enum_value,
set_value: this.set_value,
set_value_alias: this.set_value_alias,
TestV2Child({
state_string_value: this.state_string_value,
prop_number_value: this.prop_number_value,
link_boolean_value: this.link_boolean_value,
provide_enum_value: this.provide_enum_value,
consume_null_value: this.consume_null_value,
storage_link_undefined_value: this.storage_link_undefined_value,
storage_prop_string_value: this.storage_prop_string_value,
func_value1: this.func_value1,
func_value2: this.func_value2
})
}
}
}
@Component
struct TestV1Child1 {
@State string_value: string = "hello"
@State string_value1: string | Set<string> = "hello"
@Prop regular_value: Set<string> = new Set()
@Link enum_value1: MemberType
@Link enum_value: Set<number> | MemberType
@Provide set_value: Set<number> | Set<string> = new Set<string>()
@State set_value_alias: newType = new Set<string>()
@ObjectLink objectLink_value: TestObserved
@Prop func_value1: Function
@BuilderParam func_value2: () => void
build() {
}
}
@ComponentV2
struct TestV2Parent {
@Local set_value: Set<string> = new Set()
@Param map_value: Map<string, string> = new Map();
@Param @Once date_value: Date = new Date()
@Require @Param arr_value: Array<string> = new Array()
@Param arr_value1: Array<A> = new Array()
@Provider() arr_value2: Array<string> = new Array()
@Consumer() arr_value3: Array<MemberType> = new Array()
build() {
Column() {
TestV1Child({
set_value: this.set_value,
map_value: this.map_value,
date_value: this.date_value,
arr_value: this.arr_value,
arr_value1: this.arr_value1,
arr_value2: this.arr_value2,
arr_value3: this.arr_value3
})
}
}
}
struct TestV2Child {
@Param state_string_value: string = "hello"
@Param prop_number_value: number = 1
@Param link_boolean_value: boolean = true
@Param provide_enum_value: MemberType = MemberType.first
@Param consume_null_value: null = null
@Param storage_link_undefined_value: undefined = undefined
@Param storage_prop_string_value: string = "hello"
@Event func_value1: Function = () => {}
@Event func_value2: () => void = () => {}
@Component
struct TestV1Child {
@State set_value: Set<string> = new Set()
@Prop map_value: Map<string, string> = new Map();
@Link date_value: Date
@Provide arr_value: Array<string> = new Array()
@State arr_value1: Array<A> = new Array()
@State arr_value2: Array<string> = new Array()
@State arr_value3: Array<MemberType> = new Array()
build() {
}

View File

@ -27,7 +27,6 @@ import {
} from './common';
import {
AN_BUILD_OUTPUT_PATH,
MAIN_PAGES,
MODULE_ID_ROLLUP_PLACEHOLDER,
NODE_MODULES_PATH
} from './pathConfig';
@ -56,7 +55,7 @@ class RollUpPluginMock {
this.share.projectConfig.setBuildMode(buildMode);
}
public build(projectRoot: string, testcase: string, buildMode: string = DEBUG) {
public build(projectRoot: string, testcase: string, pagePaths: string[] = [], buildMode: string = DEBUG) {
this.isPreview = false;
this.share = new Share();
this.share.projectConfig.setBuildMode(buildMode);
@ -64,27 +63,27 @@ class RollUpPluginMock {
this.share.projectConfig.setPreview(this.isPreview);
this.meta.watchMode = this.isPreview;
this.doBuild(projectRoot, testcase);
this.doBuild(projectRoot, testcase, pagePaths);
}
public chooseTestData(projectRoot: string, testcase: string) {
public chooseTestData(projectRoot: string, testcase: string, pagePaths: string[] = []) {
if (!this.share) {
throw new Error('Call build API first.');
}
this.doBuild(projectRoot, testcase);
this.doBuild(projectRoot, testcase, pagePaths);
}
public preview(projectRoot: string, testcase: string) {
public preview(projectRoot: string, testcase: string, pagePaths: string[] = []) {
this.isPreview = true;
this.share = new Share();
this.share.projectConfig.setPreview(this.isPreview);
this.meta.watchMode = this.isPreview;
this.doBuild(projectRoot, testcase);
this.doBuild(projectRoot, testcase, pagePaths);
}
public coldReload(projectRoot: string, testcase: string, buildMode: string = DEBUG) {
public coldReload(projectRoot: string, testcase: string, pagePaths: string[] = [], buildMode: string = DEBUG) {
this.isPreview = false;
this.share = new Share();
this.share.projectConfig.setBuildMode(buildMode)
@ -92,25 +91,25 @@ class RollUpPluginMock {
this.share.projectConfig.setPreview(this.isPreview);
this.meta.watchMode = false;
this.doBuild(projectRoot, testcase);
this.doBuild(projectRoot, testcase, pagePaths);
}
public hotReload(projectRoot: string, testcase: string) {
public hotReload(projectRoot: string, testcase: string, pagePaths: string[] = []) {
this.isPreview = false;
this.share = new Share();
this.share.projectConfig.setPreview(this.isPreview);
this.meta.watchMode = this.isPreview;
this.doBuild(projectRoot, testcase);
this.doBuild(projectRoot, testcase, pagePaths);
}
public useNormalizedOHMUrl() {
this.share.projectConfig.useNormalizedOHMUrl = true;
}
public mockCompileContextInfo(projectRoot: string, testcase: string) {
this.share.projectConfig.mockCompileContextInfo(`${projectRoot}/${testcase}`);
public mockCompileContextInfo(projectRoot: string, testcase: string, pagePaths: string[] = []) {
this.share.projectConfig.mockCompileContextInfo(`${projectRoot}/${testcase}`, pagePaths);
let entryObj: object = this.share.projectConfig.entryObj;
if (!!this.share.projectConfig.widgetCompile) {
entryObj = this.share.projectConfig.cardEntryObj
@ -123,9 +122,9 @@ class RollUpPluginMock {
}
}
private doBuild(projectRoot: string, testcase: string) {
this.share.scan(projectRoot, testcase);
this.load();
private doBuild(projectRoot: string, testcase: string, pagePaths: string[] = []) {
this.share.scan(projectRoot, testcase, pagePaths);
this.load(pagePaths);
// mock ets-loader build start
this.share.arkProjectConfig = RollUpPluginMock.mockArkProjectConfig(projectRoot, testcase, this.isPreview);
@ -203,7 +202,7 @@ class RollUpPluginMock {
public getWatchFiles() { }
public load() {
public load(pagePaths: string[] = []) {
// load project files list
this.share.allFiles = new Set<string>();
if (fs.existsSync(this.share.projectConfig.projectPath)) {
@ -215,7 +214,7 @@ class RollUpPluginMock {
this.share.allFiles.add(tsFilePath);
this.share.allFiles.add(jsFilePath);
MAIN_PAGES.forEach((mainPage: string) => {
pagePaths.forEach((mainPage: string) => {
const etsFilePath = path.join(this.share.projectConfig.projectPath, `/${mainPage}.ets`);
this.share.allFiles.add(etsFilePath);
})

View File

@ -47,215 +47,215 @@ export const UT_PAGES: string[] = [
];
export const UT_PARTIAL_UPFATE_PAGES: string[] = [
'import/import@CustomDialog',
'import/import@Observed',
'import/importAllEts',
'import/importEts',
'import/importExportEts',
'import/importExportNest',
'import/importTs',
// 'import/import@CustomDialog',
// 'import/import@Observed',
// 'import/importAllEts',
// 'import/importEts',
// 'import/importExportEts',
// 'import/importExportNest',
// 'import/importTs',
'inner_component_transform/$$_component/$$_component',
'inner_component_transform/$$_component/$$_componentCheck1',
'inner_component_transform/$$_component/$$_componentCheck2',
'inner_component_transform/$$_component/$$_componentCheck3',
'inner_component_transform/$$_component/$$_componentCheck4',
'inner_component_transform/$$_component/$$_componentCheck5',
'inner_component_transform/$$_component/$$_componentCheck6',
'inner_component_transform/$$_component/$$_componentCheck7',
'inner_component_transform/$$_component/$$_componentCheck8',
'inner_component_transform/$$_component/$$_componentCheck9',
'inner_component_transform/$$_component/$$_if_elseIf_else',
'inner_component_transform/custom_component/component_object',
'inner_component_transform/custom_component/custom_component',
'inner_component_transform/gesture_component/GestureModeParallel',
'inner_component_transform/gesture_component/longPressGesture',
'inner_component_transform/gesture_component/panGestrue',
'inner_component_transform/gesture_component/pinchGesture',
'inner_component_transform/gesture_component/rotationGesture',
'inner_component_transform/gesture_component/swipeGesture',
'inner_component_transform/gesture_component/tapGesture',
'inner_component_transform/render_component/foreach/foreach',
'inner_component_transform/render_component/foreach/forEachSecondFunction',
'inner_component_transform/render_component/foreach/forEachThreeParam',
'inner_component_transform/render_component/foreach/forEachTwo',
'inner_component_transform/render_component/if/id_if',
'inner_component_transform/render_component/if/if',
'inner_component_transform/render_component/item/GridItem',
'inner_component_transform/render_component/item/ListItem',
'inner_component_transform/render_component/lazyforeach/lazyforeach',
'inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam',
'inner_component_transform/render_component/repeat/repeat',
'inner_component_transform/render_component/repeat/repeatAttr',
'inner_component_transform/render_component/repeat/repeatVirtualScroll',
'inner_component_transform/render_component/tab/tab',
'inner_component_transform/simple_component/button/button',
'inner_component_transform/simple_component/xcomponent/XComponentContainer',
'inner_component_transform/transition_component/animateTo/animateTo',
'inner_component_transform/transition_component/navDestination_component/navDestination_component',
'inner_component_transform/transition_component/navigation/navigation_component',
'inner_component_transform/transition_component/pageTransition/pageTransition',
// 'inner_component_transform/$$_component/$$_component',
// 'inner_component_transform/$$_component/$$_componentCheck1',
// 'inner_component_transform/$$_component/$$_componentCheck2',
// 'inner_component_transform/$$_component/$$_componentCheck3',
// 'inner_component_transform/$$_component/$$_componentCheck4',
// 'inner_component_transform/$$_component/$$_componentCheck5',
// 'inner_component_transform/$$_component/$$_componentCheck6',
// 'inner_component_transform/$$_component/$$_componentCheck7',
// 'inner_component_transform/$$_component/$$_componentCheck8',
// 'inner_component_transform/$$_component/$$_componentCheck9',
// 'inner_component_transform/$$_component/$$_if_elseIf_else',
// 'inner_component_transform/custom_component/component_object',
// 'inner_component_transform/custom_component/custom_component',
// 'inner_component_transform/gesture_component/GestureModeParallel',
// 'inner_component_transform/gesture_component/longPressGesture',
// 'inner_component_transform/gesture_component/panGestrue',
// 'inner_component_transform/gesture_component/pinchGesture',
// 'inner_component_transform/gesture_component/rotationGesture',
// 'inner_component_transform/gesture_component/swipeGesture',
// 'inner_component_transform/gesture_component/tapGesture',
// 'inner_component_transform/render_component/foreach/foreach',
// 'inner_component_transform/render_component/foreach/forEachSecondFunction',
// 'inner_component_transform/render_component/foreach/forEachThreeParam',
// 'inner_component_transform/render_component/foreach/forEachTwo',
// 'inner_component_transform/render_component/if/id_if',
// 'inner_component_transform/render_component/if/if',
// 'inner_component_transform/render_component/item/GridItem',
// 'inner_component_transform/render_component/item/ListItem',
// 'inner_component_transform/render_component/lazyforeach/lazyforeach',
// 'inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam',
// 'inner_component_transform/render_component/repeat/repeat',
// 'inner_component_transform/render_component/repeat/repeatAttr',
// 'inner_component_transform/render_component/repeat/repeatVirtualScroll',
// 'inner_component_transform/render_component/tab/tab',
// 'inner_component_transform/simple_component/button/button',
// 'inner_component_transform/simple_component/xcomponent/XComponentContainer',
// 'inner_component_transform/transition_component/animateTo/animateTo',
// 'inner_component_transform/transition_component/navDestination_component/navDestination_component',
// 'inner_component_transform/transition_component/navigation/navigation_component',
// 'inner_component_transform/transition_component/pageTransition/pageTransition',
'render_decorator/@AnimatableExtend/animatableExtend',
'render_decorator/@builder/@builder',
'render_decorator/@builder/@builderDynamicUsage$$',
'render_decorator/@builder/@builderOrComponentAsName',
'render_decorator/@builder/@builderSimplifyAfferent',
'render_decorator/@builder/@builderTransFormFirst',
'render_decorator/@builder/@builderTransFormFourth',
'render_decorator/@builder/@builderTransFormSecond',
'render_decorator/@builder/@builderTransFormThird',
'render_decorator/@builder/@builderVisilibity$$',
'render_decorator/@builder/@builderWithComponent',
'render_decorator/@builder/@builderWithForEach',
'render_decorator/@builder/@builderWithLinkData',
'render_decorator/@builder/handleCustomBuilder',
'render_decorator/@builderParam/@builderParam',
'render_decorator/@builderParam/@builderParamQuestionMark',
'render_decorator/@builderParam/@BuilderParamReturnType',
'render_decorator/@componentParent/@componentParent',
'render_decorator/@customDialog/@customDialog',
'render_decorator/@extend/@extend',
'render_decorator/@localBuilder/@localBuilder',
'render_decorator/@preview/@preview',
'render_decorator/@recycle/recycle_$$component',
'render_decorator/@recycle/recycle_extend_styles',
'render_decorator/@recycle/recycle_function_array',
'render_decorator/@recycle/recycle_gesture',
'render_decorator/@recycle/recycle_reuseId',
'render_decorator/@recycle/recycle',
'render_decorator/@styles/@styles',
'render_decorator/@styles/@stylesExport',
'render_decorator/@styles/@stylesOrComponentAsName',
// 'render_decorator/@AnimatableExtend/animatableExtend',
// 'render_decorator/@builder/@builder',
// 'render_decorator/@builder/@builderDynamicUsage$$',
// 'render_decorator/@builder/@builderOrComponentAsName',
// 'render_decorator/@builder/@builderSimplifyAfferent',
// 'render_decorator/@builder/@builderTransFormFirst',
// 'render_decorator/@builder/@builderTransFormFourth',
// 'render_decorator/@builder/@builderTransFormSecond',
// 'render_decorator/@builder/@builderTransFormThird',
// 'render_decorator/@builder/@builderVisilibity$$',
// 'render_decorator/@builder/@builderWithComponent',
// 'render_decorator/@builder/@builderWithForEach',
// 'render_decorator/@builder/@builderWithLinkData',
// 'render_decorator/@builder/handleCustomBuilder',
// 'render_decorator/@builderParam/@builderParam',
// 'render_decorator/@builderParam/@builderParamQuestionMark',
// 'render_decorator/@builderParam/@BuilderParamReturnType',
// 'render_decorator/@componentParent/@componentParent',
// 'render_decorator/@customDialog/@customDialog',
// 'render_decorator/@extend/@extend',
// 'render_decorator/@localBuilder/@localBuilder',
// 'render_decorator/@preview/@preview',
// 'render_decorator/@recycle/recycle_$$component',
// 'render_decorator/@recycle/recycle_extend_styles',
// 'render_decorator/@recycle/recycle_function_array',
// 'render_decorator/@recycle/recycle_gesture',
// 'render_decorator/@recycle/recycle_reuseId',
// 'render_decorator/@recycle/recycle',
// 'render_decorator/@styles/@styles',
// 'render_decorator/@styles/@stylesExport',
// 'render_decorator/@styles/@stylesOrComponentAsName',
'ui_context/build_ui_in_correct_place',
// 'ui_context/build_ui_in_correct_place',
'ui_state_management/application_state_management/@storageLink/@storageLink',
'ui_state_management/application_state_management/@storageProp/@storageProp',
'ui_state_management/application_state_management/appStorage/appStorage',
'ui_state_management/application_state_management/localStorage/localStorage',
'ui_state_management/application_state_management/localStorage/localStorageForBoth',
'ui_state_management/application_state_management/localStorage/localStorageForChainCall',
'ui_state_management/application_state_management/localStorage/localStorageForRoute',
'ui_state_management/application_state_management/localStorage/localStorageForStorage',
'ui_state_management/application_state_management/localStorage/localStorageForThree',
'ui_state_management/application_state_management/localStorage/localStorageForThreeParam',
'ui_state_management/application_state_management/localStorage/localStorageParam',
'ui_state_management/inner_struct_state_management/@link/@link',
'ui_state_management/inner_struct_state_management/@objectLink/@objectLink',
'ui_state_management/inner_struct_state_management/@prop/@prop',
'ui_state_management/inner_struct_state_management/@prop/@propComplexType',
'ui_state_management/inner_struct_state_management/@state/@state',
'ui_state_management/others/@consume_@provide/@consume_@provide',
'ui_state_management/others/@observed_@objectLink/@observed_@objectLink',
'ui_state_management/others/@watch/@watch',
'ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck',
// 'ui_state_management/application_state_management/@storageLink/@storageLink',
// 'ui_state_management/application_state_management/@storageProp/@storageProp',
// 'ui_state_management/application_state_management/appStorage/appStorage',
// 'ui_state_management/application_state_management/localStorage/localStorage',
// 'ui_state_management/application_state_management/localStorage/localStorageForBoth',
// 'ui_state_management/application_state_management/localStorage/localStorageForChainCall',
// 'ui_state_management/application_state_management/localStorage/localStorageForRoute',
// 'ui_state_management/application_state_management/localStorage/localStorageForStorage',
// 'ui_state_management/application_state_management/localStorage/localStorageForThree',
// 'ui_state_management/application_state_management/localStorage/localStorageForThreeParam',
// 'ui_state_management/application_state_management/localStorage/localStorageParam',
// 'ui_state_management/inner_struct_state_management/@link/@link',
// 'ui_state_management/inner_struct_state_management/@objectLink/@objectLink',
// 'ui_state_management/inner_struct_state_management/@prop/@prop',
// 'ui_state_management/inner_struct_state_management/@prop/@propComplexType',
// 'ui_state_management/inner_struct_state_management/@state/@state',
// 'ui_state_management/others/@consume_@provide/@consume_@provide',
// 'ui_state_management/others/@observed_@objectLink/@observed_@objectLink',
// 'ui_state_management/others/@watch/@watch',
// 'ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck',
'v2_component_decorator/builderParamStyles',
'v2_component_decorator/param_event_twoway_binding',
'v2_component_decorator/staticComponentMember'
// 'v2_component_decorator/builderParamStyles',
// 'v2_component_decorator/param_event_twoway_binding',
// 'v2_component_decorator/staticComponentMember'
];
export const UT_VALIDATE_PAGES: string[] = [
// 'Decorators/process_component_build/@BuilderParam',
// 'Decorators/process_component_build/arkUIComponent',
// 'Decorators/process_component_build/arkUIStandard',
// 'Decorators/process_component_build/attributeCheck',
// 'Decorators/process_component_build/buttonCheck',
// 'Decorators/process_component_build/checkNonspecificParents',
// 'Decorators/process_component_build/foreachParamCheck',
// 'Decorators/process_component_build/idCheck', // Need to change error log
// 'Decorators/process_component_build/ifComponent', // Miss one error message
// 'Decorators/process_component_build/rootContainerCheck',
// 'Decorators/process_component_build/stateStyles',
'Decorators/process_component_build/@BuilderParam',
'Decorators/process_component_build/arkUIComponent',
'Decorators/process_component_build/arkUIStandard',
'Decorators/process_component_build/attributeCheck',
'Decorators/process_component_build/buttonCheck',
'Decorators/process_component_build/checkNonspecificParents',
'Decorators/process_component_build/foreachParamCheck',
'Decorators/process_component_build/idCheck', // Need to change error log
'Decorators/process_component_build/ifComponent', // Miss one error message
'Decorators/process_component_build/rootContainerCheck',
'Decorators/process_component_build/stateStyles',
// 'Decorators/process_component_class/@StylesParamChack',
// 'Decorators/process_component_class/processComponentMethod',
// 'Decorators/process_component_class/updateHeritageClauses',
// 'Decorators/process_component_class/validateBuildMethodCount',
// 'Decorators/process_component_class/validateDecorators',
// 'Decorators/process_component_class/validateHasController',
'Decorators/process_component_class/@StylesParamChack',
'Decorators/process_component_class/processComponentMethod',
'Decorators/process_component_class/updateHeritageClauses',
'Decorators/process_component_class/validateBuildMethodCount',
'Decorators/process_component_class/validateDecorators',
'Decorators/process_component_class/validateHasController',
// 'Decorators/process_component_member/@linkInitialize',
// 'Decorators/process_component_member/@objectLinkInitialize',
// 'Decorators/process_component_member/processWatch',
// 'Decorators/process_component_member/updateBuilderParamProperty',
// 'Decorators/process_component_member/validateCustomDecorator',
// 'Decorators/process_component_member/validateDuplicateDecorator', // Miss one error message
// 'Decorators/process_component_member/validateForbiddenUseStateType',
// 'Decorators/process_component_member/validateHasIllegalDecoratorInEntry',
// 'Decorators/process_component_member/validateHasIllegalQuestionToken', // Miss one error message
// 'Decorators/process_component_member/validateMultiDecorators',
// 'Decorators/process_component_member/validateNonObservedClassType',
// 'Decorators/process_component_member/validatePropertyDefaultValue',
// 'Decorators/process_component_member/validatePropertyNonDefaultValue',
// 'Decorators/process_component_member/validatePropertyNonType',
// 'Decorators/process_component_member/validateWatchDecorator',
// 'Decorators/process_component_member/validateWatchParam',
'Decorators/process_component_member/@linkInitialize',
'Decorators/process_component_member/@objectLinkInitialize',
'Decorators/process_component_member/processWatch',
'Decorators/process_component_member/updateBuilderParamProperty',
'Decorators/process_component_member/validateCustomDecorator',
'Decorators/process_component_member/validateDuplicateDecorator', // Miss one error message
'Decorators/process_component_member/validateForbiddenUseStateType',
'Decorators/process_component_member/validateHasIllegalDecoratorInEntry',
'Decorators/process_component_member/validateHasIllegalQuestionToken', // Miss one error message
'Decorators/process_component_member/validateMultiDecorators',
'Decorators/process_component_member/validateNonObservedClassType',
'Decorators/process_component_member/validatePropertyDefaultValue',
'Decorators/process_component_member/validatePropertyNonDefaultValue',
'Decorators/process_component_member/validatePropertyNonType',
'Decorators/process_component_member/validateWatchDecorator',
'Decorators/process_component_member/validateWatchParam',
// 'Decorators/process_custom_component/checkBuilder$$',
// 'Decorators/process_custom_component/v2DecoratorInitFromParent',
// 'Decorators/process_custom_component/validateForbiddenToInitViaParam',
// 'Decorators/process_custom_component/validateIllegalInitFromParent',
// 'Decorators/process_custom_component/validateInitDecorator',
// 'Decorators/process_custom_component/validateMandatoryToInitViaParam',
// 'Decorators/process_custom_component/validateNonLinkWithDollar',
// 'Decorators/process_custom_component/validateParamTwoWayBind',
'Decorators/process_custom_component/checkBuilder$$',
'Decorators/process_custom_component/v2DecoratorInitFromParent',
'Decorators/process_custom_component/validateForbiddenToInitViaParam',
'Decorators/process_custom_component/validateIllegalInitFromParent',
'Decorators/process_custom_component/validateInitDecorator',
'Decorators/process_custom_component/validateMandatoryToInitViaParam',
'Decorators/process_custom_component/validateNonLinkWithDollar',
'Decorators/process_custom_component/validateParamTwoWayBind',
// 'Decorators/process_import/index', // No such test case
// 'Decorators/process_import/validateModuleName',
'Decorators/process_import/index', // No such test case
'Decorators/process_import/validateModuleName',
// 'Decorators/process_struct_componentV2/param_require_once_check',
// 'Decorators/process_struct_componentV2/v2Component_member_type_check',
'Decorators/process_struct_componentV2/param_require_once_check',
'Decorators/process_struct_componentV2/v2Component_member_type_check',
// 'Decorators/process_ui_syntax/EntryDecoParam',
// 'Decorators/process_ui_syntax/ExtendOneChild',
// 'Decorators/process_ui_syntax/NoSrc',
// 'Decorators/process_ui_syntax/NotSupportResrcParam',
// 'Decorators/process_ui_syntax/NotSupportResrcType',
// 'Decorators/process_ui_syntax/StylesNoParam',
// 'Decorators/process_ui_syntax/UnknownSrc',
// 'Decorators/process_ui_syntax/UnknownSrcName',
// 'Decorators/process_ui_syntax/UnknownSrcType',
'Decorators/process_ui_syntax/EntryDecoParam',
'Decorators/process_ui_syntax/ExtendOneChild',
'Decorators/process_ui_syntax/NoSrc',
'Decorators/process_ui_syntax/NotSupportResrcParam',
'Decorators/process_ui_syntax/NotSupportResrcType',
'Decorators/process_ui_syntax/StylesNoParam',
'Decorators/process_ui_syntax/UnknownSrc',
'Decorators/process_ui_syntax/UnknownSrcName',
'Decorators/process_ui_syntax/UnknownSrcType',
// 'Decorators/v1AndV2ComponentDecorators/property_observe_validate',
// 'Decorators/v1AndV2ComponentDecorators/v1ToV2Component',
// 'Decorators/v1AndV2ComponentDecorators/v1ToV2ComponentValidate',
// 'Decorators/v1AndV2ComponentDecorators/v2ToV1ComponentValidate',
// 'Decorators/v1AndV2ComponentDecorators/v2ToV1Link',
'Decorators/v1AndV2ComponentDecorators/property_observe_validate',
'Decorators/v1AndV2ComponentDecorators/v1ToV2Component',
'Decorators/v1AndV2ComponentDecorators/v1ToV2ComponentValidate',
'Decorators/v1AndV2ComponentDecorators/v2ToV1ComponentValidate',
'Decorators/v1AndV2ComponentDecorators/v2ToV1Link',
// 'Decorators/vaildate_ui_syntax/@localBuilder',
// 'Decorators/vaildate_ui_syntax/@Monitor',
// 'Decorators/vaildate_ui_syntax/@Trace',
// 'Decorators/vaildate_ui_syntax/@Type',
// 'Decorators/vaildate_ui_syntax/componentV2BothWithComponent',
// 'Decorators/vaildate_ui_syntax/ExceededEntry',
// 'Decorators/vaildate_ui_syntax/ExceededPreview',
// 'Decorators/vaildate_ui_syntax/MethodNoExtend',
// 'Decorators/vaildate_ui_syntax/mutiDecoratorInComponentV2',
// 'Decorators/vaildate_ui_syntax/NoChild',
// 'Decorators/vaildate_ui_syntax/NoStructDeco',
// 'Decorators/vaildate_ui_syntax/notComponent',
// 'Decorators/vaildate_ui_syntax/notConcurrent',
// 'Decorators/vaildate_ui_syntax/notConcurrentFun',
// 'Decorators/vaildate_ui_syntax/notConcurrentFunAster',
// 'Decorators/vaildate_ui_syntax/notDecorator',
// 'Decorators/vaildate_ui_syntax/notMethodDeco',
// 'Decorators/vaildate_ui_syntax/OneChild',
// 'Decorators/vaildate_ui_syntax/OneEntry',
// 'Decorators/vaildate_ui_syntax/OnlyStructDeco',
// 'Decorators/vaildate_ui_syntax/state',
// 'Decorators/vaildate_ui_syntax/StructNameInvalid',
// 'Decorators/vaildate_ui_syntax/StylesDuplicate',
// 'Decorators/vaildate_ui_syntax/v1DecoratorInComponentV2',
// 'Decorators/vaildate_ui_syntax/v2DecoratorInClass',
// 'Decorators/vaildate_ui_syntax/v2DecoratorInComponent',
// 'Decorators/vaildate_ui_syntax/v2MemberDecorator',
// 'Decorators/vaildate_ui_syntax/vaildateDecorator',
// 'Decorators/vaildate_ui_syntax/validate_track_observed',
// 'Decorators/vaildate_ui_syntax/validateAccessQualifier',
// 'Decorators/vaildate_ui_syntax/validateDifferentMethod',
// 'Decorators/vaildate_ui_syntax/validateDuplicateMethod'
'Decorators/vaildate_ui_syntax/@localBuilder',
'Decorators/vaildate_ui_syntax/@Monitor',
'Decorators/vaildate_ui_syntax/@Trace',
'Decorators/vaildate_ui_syntax/@Type',
'Decorators/vaildate_ui_syntax/componentV2BothWithComponent',
'Decorators/vaildate_ui_syntax/ExceededEntry',
'Decorators/vaildate_ui_syntax/ExceededPreview',
'Decorators/vaildate_ui_syntax/MethodNoExtend',
'Decorators/vaildate_ui_syntax/mutiDecoratorInComponentV2',
'Decorators/vaildate_ui_syntax/NoChild',
'Decorators/vaildate_ui_syntax/NoStructDeco',
'Decorators/vaildate_ui_syntax/notComponent',
'Decorators/vaildate_ui_syntax/notConcurrent',
'Decorators/vaildate_ui_syntax/notConcurrentFun',
'Decorators/vaildate_ui_syntax/notConcurrentFunAster',
'Decorators/vaildate_ui_syntax/notDecorator',
'Decorators/vaildate_ui_syntax/notMethodDeco',
'Decorators/vaildate_ui_syntax/OneChild',
'Decorators/vaildate_ui_syntax/OneEntry',
'Decorators/vaildate_ui_syntax/OnlyStructDeco',
'Decorators/vaildate_ui_syntax/state',
'Decorators/vaildate_ui_syntax/StructNameInvalid',
'Decorators/vaildate_ui_syntax/StylesDuplicate',
'Decorators/vaildate_ui_syntax/v1DecoratorInComponentV2',
'Decorators/vaildate_ui_syntax/v2DecoratorInClass',
'Decorators/vaildate_ui_syntax/v2DecoratorInComponent',
'Decorators/vaildate_ui_syntax/v2MemberDecorator',
'Decorators/vaildate_ui_syntax/vaildateDecorator',
'Decorators/vaildate_ui_syntax/validate_track_observed',
'Decorators/vaildate_ui_syntax/validateAccessQualifier',
'Decorators/vaildate_ui_syntax/validateDifferentMethod',
'Decorators/vaildate_ui_syntax/validateDuplicateMethod'
]
export const MAIN_PAGES: string[] = [

View File

@ -34,7 +34,6 @@ import {
ACE_PROFILE_PATH,
CACHE_PATH,
LOADER_PATH,
MAIN_PAGES,
MAIN_PATH,
PREVIEW_CACHE_PATH,
PREVIEW_MAIN_PATH,
@ -249,8 +248,8 @@ class ProjectConfig {
this.compatibleSdkVersion = version;
}
public scan(projectRoot: string, testcase: string) {
this.initPath(`${projectRoot}/${testcase}`);
public scan(projectRoot: string, testcase: string, pagePaths: string[] = []) {
this.initPath(`${projectRoot}/${testcase}`, pagePaths);
}
public concat(other: typeof ProjectConfig | ArkProjectConfig) {
@ -270,7 +269,7 @@ class ProjectConfig {
// }
}
private initPath(projectPath: string) {
private initPath(projectPath: string, pagePaths: string[] = []) {
let mode = this.isPreview ? '.preview' : this.isLocalTest ? '.test' : 'build';
this.projectPath = `${projectPath}/${this.entryModuleName}/src/main/ets`;
@ -291,11 +290,11 @@ class ProjectConfig {
this.projectRootPath = `${projectPath}`;
if (this.isPreview) {
this.previewUniqueConfig();
this.previewUniqueConfig(pagePaths);
}
}
private previewUniqueConfig() {
private previewUniqueConfig(pagePaths: string[] = []) {
this.deviceType = DEVICE_TYPE;
this.checkEntry = 'true';
this.Path = NODE_JS_PATH;
@ -307,7 +306,7 @@ class ProjectConfig {
this.stageRouterConfig = {
'contents': [
"{\"module\":{\"pages\":\"$profile:main_pages\",\"name\":\"entry\"}}",
JSON.stringify({ 'src': MAIN_PAGES })
JSON.stringify({ 'src': pagePaths })
],
'paths': [
`${this.projectRootPath}/${this.entryModuleName}/.preview/${RES_PATH}/module.json`,
@ -318,7 +317,7 @@ class ProjectConfig {
this.aceSoPath = `${this.projectRootPath}/${this.entryModuleName}/.preview/cache/nativeDependencies.txt`;
}
public mockCompileContextInfo(projectRoot: string) {
public mockCompileContextInfo(projectRoot: string, pagePaths: string[] = []) {
this.entryObj = {
'entryAbility/EntryAbility': `${projectRoot}/entry/src/main/ets/entryability/EntryAbility.ets`,
'entryformability/EntryFormAbility': `${projectRoot}/entry/src/main/ets/entryformability/EntryFormAbility.ets`,
@ -331,7 +330,7 @@ class ProjectConfig {
// "pages/Index"
];
MAIN_PAGES.forEach((mainPage: string) => {
pagePaths.forEach((mainPage: string) => {
this.entryObj[mainPage] = `${projectRoot}/entry/src/main/ets/${mainPage}.ets`;
this.entryArrayForObf.push(mainPage);
})

View File

@ -72,11 +72,11 @@ class Share {
return Logger.removeLogger(prefix);
}
public scan(projectRoot: string, testcase: string) {
public scan(projectRoot: string, testcase: string, pagePaths: string[] = []) {
if (!testcase) {
return;
}
this.projectConfig.scan(projectRoot, testcase);
this.projectConfig.scan(projectRoot, testcase, pagePaths);
this.symlinkMap[`${this.projectConfig.projectTopDir}/${OH_MODULES_OHPM_HYPIUM}`] = [
`${this.projectConfig.projectTopDir}/${OH_MODULES_OHOS_HYPIUM}`
];

View File

@ -2,12 +2,11 @@ import path from 'path';
import mocha from 'mocha';
import { expect } from 'chai';
import { RollUpPluginMock } from './helpers/mockRollupContext';
import { ProjectConfig } from './helpers/projectConfig';
const PROJECT_ROOT = path.resolve(__dirname, '../../test/transform_ut');
const DEFAULT_PROJECT: string = 'application';
mocha.describe('test rollup', function () {
mocha.describe('test rollup mock', function () {
mocha.before(function () {
this.rollup = new RollUpPluginMock();
});
@ -17,19 +16,8 @@ mocha.describe('test rollup', function () {
});
mocha.it('1-1: test rollup projectConfig', function () {
// const projectConfig = new ProjectConfig();
// projectConfig.setPreview(true);
// projectConfig.scan(PROJECT_ROOT, DEFAULT_PROJECT);
// projectConfig.mockCompileContextInfo(`${PROJECT_ROOT}/${DEFAULT_PROJECT}`);
// projectConfig.concat(RollUpPluginMock.mockArkProjectConfig(PROJECT_ROOT, DEFAULT_PROJECT, true));
// console.error('1-1: ', projectConfig);
// expect(projectConfig !== null).to.be.true;
// this.rollup.build(PROJECT_ROOT, DEFAULT_PROJECT);
this.rollup.preview(PROJECT_ROOT, DEFAULT_PROJECT);
// console.error('1-1: ', this.rollup.share.projectConfig);
expect(this.rollup.share.projectConfig !== null).to.be.true;
});
});

View File

@ -55,13 +55,13 @@ mocha.describe('test UT testcases [non-preview mode]', function () {
mocha.before(function () {
this.rollup = new RollUpPluginMock();
this.rollup.build(PROJECT_ROOT, DEFAULT_PROJECT);
this.rollup.build(PROJECT_ROOT, DEFAULT_PROJECT, UT_PAGES);
this.globalProjectConfig = new ProjectConfig();
this.globalProjectConfig.setPreview(false);
this.globalProjectConfig.setIgnoreWarning(true);
this.globalProjectConfig.scan(PROJECT_ROOT, DEFAULT_PROJECT);
this.globalProjectConfig.mockCompileContextInfo(`${PROJECT_ROOT}/${DEFAULT_PROJECT}`);
this.globalProjectConfig.scan(PROJECT_ROOT, DEFAULT_PROJECT, UT_PAGES);
this.globalProjectConfig.mockCompileContextInfo(`${PROJECT_ROOT}/${DEFAULT_PROJECT}`, UT_PAGES);
this.globalProjectConfig.concat(RollUpPluginMock.mockArkProjectConfig(PROJECT_ROOT, DEFAULT_PROJECT, true));
this.rollup.share.projectConfig.concat(this.globalProjectConfig);

View File

@ -55,13 +55,13 @@ mocha.describe('test UT for partial update testcases [non-preview mode]', functi
mocha.before(function () {
this.rollup = new RollUpPluginMock();
this.rollup.build(PROJECT_ROOT, DEFAULT_PROJECT);
this.rollup.build(PROJECT_ROOT, DEFAULT_PROJECT, UT_PARTIAL_UPFATE_PAGES);
this.globalProjectConfig = new ProjectConfig();
this.globalProjectConfig.setPreview(false);
this.globalProjectConfig.setIgnoreWarning(true);
this.globalProjectConfig.scan(PROJECT_ROOT, DEFAULT_PROJECT);
this.globalProjectConfig.mockCompileContextInfo(`${PROJECT_ROOT}/${DEFAULT_PROJECT}`);
this.globalProjectConfig.scan(PROJECT_ROOT, DEFAULT_PROJECT, UT_PARTIAL_UPFATE_PAGES);
this.globalProjectConfig.mockCompileContextInfo(`${PROJECT_ROOT}/${DEFAULT_PROJECT}`, UT_PARTIAL_UPFATE_PAGES);
this.globalProjectConfig.concat(RollUpPluginMock.mockArkProjectConfig(PROJECT_ROOT, DEFAULT_PROJECT, true));
this.rollup.share.projectConfig.concat(this.globalProjectConfig);

View File

@ -56,7 +56,7 @@ mocha.describe('test UT for validate testcases [non-preview mode]', function ()
mocha.before(function () {
this.rollup = new RollUpPluginMock();
this.rollup.build(PROJECT_ROOT, DEFAULT_PROJECT);
this.rollup.build(PROJECT_ROOT, DEFAULT_PROJECT, UT_VALIDATE_PAGES);
// enable logger for etsTransform roll-up plugin
this.rollup.share.flushLogger();
@ -66,8 +66,8 @@ mocha.describe('test UT for validate testcases [non-preview mode]', function ()
this.globalProjectConfig = new ProjectConfig();
this.globalProjectConfig.setPreview(false);
this.globalProjectConfig.setIgnoreWarning(true);
this.globalProjectConfig.scan(PROJECT_ROOT, DEFAULT_PROJECT);
this.globalProjectConfig.mockCompileContextInfo(`${PROJECT_ROOT}/${DEFAULT_PROJECT}`);
this.globalProjectConfig.scan(PROJECT_ROOT, DEFAULT_PROJECT, UT_VALIDATE_PAGES);
this.globalProjectConfig.mockCompileContextInfo(`${PROJECT_ROOT}/${DEFAULT_PROJECT}`, UT_VALIDATE_PAGES);
this.globalProjectConfig.concat(RollUpPluginMock.mockArkProjectConfig(PROJECT_ROOT, DEFAULT_PROJECT, true));
this.rollup.share.projectConfig.concat(this.globalProjectConfig);