107ac75b1Sopenharmony_ci/*
207ac75b1Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
307ac75b1Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
407ac75b1Sopenharmony_ci * you may not use rollupObject file except in compliance with the License.
507ac75b1Sopenharmony_ci * You may obtain a copy of the License at
607ac75b1Sopenharmony_ci *
707ac75b1Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
807ac75b1Sopenharmony_ci *
907ac75b1Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1007ac75b1Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1107ac75b1Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1207ac75b1Sopenharmony_ci * See the License for the specific language governing permissions and
1307ac75b1Sopenharmony_ci * limitations under the License.
1407ac75b1Sopenharmony_ci */
1507ac75b1Sopenharmony_ci
1607ac75b1Sopenharmony_ciimport { expect } from 'chai';
1707ac75b1Sopenharmony_ciimport mocha from 'mocha';
1807ac75b1Sopenharmony_ciimport fs from "fs";
1907ac75b1Sopenharmony_ciimport path from "path";
2007ac75b1Sopenharmony_ciimport MagicString from 'magic-string';
2107ac75b1Sopenharmony_ciimport sinon from 'sinon';
2207ac75b1Sopenharmony_ci
2307ac75b1Sopenharmony_ciimport {
2407ac75b1Sopenharmony_ci  needAotCompiler,
2507ac75b1Sopenharmony_ci  shouldETSOrTSFileTransformToJS,
2607ac75b1Sopenharmony_ci  changeFileExtension,
2707ac75b1Sopenharmony_ci  isAotMode,
2807ac75b1Sopenharmony_ci  isDebug,
2907ac75b1Sopenharmony_ci  isCommonJsPluginVirtualFile,
3007ac75b1Sopenharmony_ci  isCurrentProjectFiles,
3107ac75b1Sopenharmony_ci  isSpecifiedExt,
3207ac75b1Sopenharmony_ci  isTsOrEtsSourceFile,
3307ac75b1Sopenharmony_ci  isJsSourceFile,
3407ac75b1Sopenharmony_ci  isJsonSourceFile,
3507ac75b1Sopenharmony_ci  utUtils,
3607ac75b1Sopenharmony_ci  updateSourceMap,
3707ac75b1Sopenharmony_ci  hasTsNoCheckOrTsIgnoreFiles,
3807ac75b1Sopenharmony_ci  compilingEtsOrTsFiles,
3907ac75b1Sopenharmony_ci  cleanUpFilesList
4007ac75b1Sopenharmony_ci} from '../../../lib/fast_build/ark_compiler/utils';
4107ac75b1Sopenharmony_ciimport RollUpPluginMock from '../mock/rollup_mock/rollup_plugin_mock';
4207ac75b1Sopenharmony_ciimport { ModuleInfo } from '../mock/rollup_mock/module_info';
4307ac75b1Sopenharmony_ciimport {
4407ac75b1Sopenharmony_ci  AOT_FULL,
4507ac75b1Sopenharmony_ci  AOT_PARTIAL,
4607ac75b1Sopenharmony_ci  AOT_TYPE
4707ac75b1Sopenharmony_ci} from '../../../lib/pre_define';
4807ac75b1Sopenharmony_ciimport {
4907ac75b1Sopenharmony_ci  ESMODULE,
5007ac75b1Sopenharmony_ci  JSBUNDLE,
5107ac75b1Sopenharmony_ci  EXTNAME_JS,
5207ac75b1Sopenharmony_ci  EXTNAME_TS,
5307ac75b1Sopenharmony_ci  EXTNAME_ETS,
5407ac75b1Sopenharmony_ci  EXTNAME_JSON,
5507ac75b1Sopenharmony_ci  RELEASE,
5607ac75b1Sopenharmony_ci  DEBUG,
5707ac75b1Sopenharmony_ci  GEN_ABC_PLUGIN_NAME
5807ac75b1Sopenharmony_ci} from '../../../lib/fast_build/ark_compiler/common/ark_define';
5907ac75b1Sopenharmony_ciimport ModuleSourceFileMock from '../mock/class_mock/module_source_files_mock';
6007ac75b1Sopenharmony_ciimport {
6107ac75b1Sopenharmony_ci  genTemporaryPath,
6207ac75b1Sopenharmony_ci  toUnixPath,
6307ac75b1Sopenharmony_ci  getProjectRootPath,
6407ac75b1Sopenharmony_ci  getBelongModuleInfo
6507ac75b1Sopenharmony_ci} from '../../../lib/utils';
6607ac75b1Sopenharmony_ciimport projectConfig from '../utils/processProjectConfig';
6707ac75b1Sopenharmony_ciimport {
6807ac75b1Sopenharmony_ci  TEST_TS,
6907ac75b1Sopenharmony_ci  TEST_JS,
7007ac75b1Sopenharmony_ci  TEST_ETS,
7107ac75b1Sopenharmony_ci  TEST_JSON,
7207ac75b1Sopenharmony_ci  PROJECT_ROOT,
7307ac75b1Sopenharmony_ci  DEFAULT_PROJECT
7407ac75b1Sopenharmony_ci} from '../mock/rollup_mock/path_config';
7507ac75b1Sopenharmony_ciimport { scanFiles } from "../utils/utils";
7607ac75b1Sopenharmony_ciimport { SourceMapGenerator } from '../../../lib/fast_build/ark_compiler/generate_sourcemap';
7707ac75b1Sopenharmony_ciimport { ModuleSourceFile } from '../../../lib/fast_build/ark_compiler/module/module_source_file';
7807ac75b1Sopenharmony_ciimport {
7907ac75b1Sopenharmony_ci  ENTRY_PACKAGE_INFO,
8007ac75b1Sopenharmony_ci  FILE,
8107ac75b1Sopenharmony_ci  SOURCE,
8207ac75b1Sopenharmony_ci  DYNAMICIMPORT_ETS,
8307ac75b1Sopenharmony_ci  UPDATESOURCEMAP
8407ac75b1Sopenharmony_ci} from '../mock/rollup_mock/common';
8507ac75b1Sopenharmony_ciimport {
8607ac75b1Sopenharmony_ci  moduleResolutionHostTest
8707ac75b1Sopenharmony_ci} from '../../../lib/ets_checker';
8807ac75b1Sopenharmony_ciimport {
8907ac75b1Sopenharmony_ci  getRollupCache,
9007ac75b1Sopenharmony_ci  setRollupCache
9107ac75b1Sopenharmony_ci} from '../../../lib/utils';
9207ac75b1Sopenharmony_ciimport {
9307ac75b1Sopenharmony_ci  ArkObfuscator
9407ac75b1Sopenharmony_ci} from 'arkguard';
9507ac75b1Sopenharmony_ci
9607ac75b1Sopenharmony_cimocha.describe('test utils file api', function () {
9707ac75b1Sopenharmony_ci  mocha.before(function () {
9807ac75b1Sopenharmony_ci    this.rollup = new RollUpPluginMock();
9907ac75b1Sopenharmony_ci  });
10007ac75b1Sopenharmony_ci
10107ac75b1Sopenharmony_ci  mocha.after(() => {
10207ac75b1Sopenharmony_ci    delete this.rollup;
10307ac75b1Sopenharmony_ci  });
10407ac75b1Sopenharmony_ci
10507ac75b1Sopenharmony_ci  mocha.it('1-1: test needAotCompiler under build debug', function () {
10607ac75b1Sopenharmony_ci    this.rollup.build();
10707ac75b1Sopenharmony_ci    const returnInfo = needAotCompiler(this.rollup.share.projectConfig);
10807ac75b1Sopenharmony_ci    expect(returnInfo).to.be.false;
10907ac75b1Sopenharmony_ci  });
11007ac75b1Sopenharmony_ci
11107ac75b1Sopenharmony_ci  mocha.it('1-2: test needAotCompiler under build debug and anBuildMode is AOT_PARTIAL', function () {
11207ac75b1Sopenharmony_ci    this.rollup.build();
11307ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.compileMode = ESMODULE;
11407ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.anBuildMode = AOT_PARTIAL;
11507ac75b1Sopenharmony_ci    const returnInfo = needAotCompiler(this.rollup.share.projectConfig);
11607ac75b1Sopenharmony_ci    expect(returnInfo).to.be.true;
11707ac75b1Sopenharmony_ci  });
11807ac75b1Sopenharmony_ci
11907ac75b1Sopenharmony_ci  mocha.it('1-3: test needAotCompiler under build release', function () {
12007ac75b1Sopenharmony_ci    this.rollup.build(RELEASE);
12107ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.compileMode = ESMODULE;
12207ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.anBuildMode = AOT_FULL;
12307ac75b1Sopenharmony_ci    const returnInfo = needAotCompiler(this.rollup.share.projectConfig);
12407ac75b1Sopenharmony_ci    expect(returnInfo).to.be.true;
12507ac75b1Sopenharmony_ci  });
12607ac75b1Sopenharmony_ci
12707ac75b1Sopenharmony_ci  mocha.it('1-4: test needAotCompiler under build release and compileMode is JSBUNDLE', function () {
12807ac75b1Sopenharmony_ci    this.rollup.build(RELEASE);
12907ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.compileMode = JSBUNDLE;
13007ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.anBuildMode = AOT_FULL;
13107ac75b1Sopenharmony_ci    const returnInfo = needAotCompiler(this.rollup.share.projectConfig);
13207ac75b1Sopenharmony_ci    expect(returnInfo).to.be.false;
13307ac75b1Sopenharmony_ci  });
13407ac75b1Sopenharmony_ci
13507ac75b1Sopenharmony_ci  mocha.it('1-5: test needAotCompiler under preview debug', function () {
13607ac75b1Sopenharmony_ci    this.rollup.preview();
13707ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.compileMode = JSBUNDLE;
13807ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.anBuildMode = AOT_PARTIAL;
13907ac75b1Sopenharmony_ci    const buildModeIsAotFull = needAotCompiler(this.rollup.share.projectConfig);
14007ac75b1Sopenharmony_ci    expect(buildModeIsAotFull === false).to.be.true;
14107ac75b1Sopenharmony_ci  });
14207ac75b1Sopenharmony_ci
14307ac75b1Sopenharmony_ci  mocha.it('1-6: test needAotCompiler under preview debug and anBuildMode is AOT_TYPE', function () {
14407ac75b1Sopenharmony_ci    this.rollup.preview();
14507ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.compileMode = JSBUNDLE;
14607ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.anBuildMode = AOT_TYPE;
14707ac75b1Sopenharmony_ci    const buildModeIsAotFull = needAotCompiler(this.rollup.share.projectConfig);
14807ac75b1Sopenharmony_ci    expect(buildModeIsAotFull === false).to.be.true;
14907ac75b1Sopenharmony_ci  });
15007ac75b1Sopenharmony_ci
15107ac75b1Sopenharmony_ci  mocha.it('1-7: test needAotCompiler under hot reload debug', function () {
15207ac75b1Sopenharmony_ci    this.rollup.hotReload();
15307ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.compileMode = ESMODULE;
15407ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.anBuildMode = AOT_TYPE;
15507ac75b1Sopenharmony_ci    const buildModeIsAotType = needAotCompiler(this.rollup.share.projectConfig);
15607ac75b1Sopenharmony_ci    expect(buildModeIsAotType === false).to.be.true;
15707ac75b1Sopenharmony_ci  });
15807ac75b1Sopenharmony_ci
15907ac75b1Sopenharmony_ci  mocha.it('2-1-1: test shouldETSOrTSFileTransformToJS under build debug: arkProjectConfig.processTs is false', function () {
16007ac75b1Sopenharmony_ci    this.rollup.build();
16107ac75b1Sopenharmony_ci    this.mockfileList = this.rollup.getModuleIds();
16207ac75b1Sopenharmony_ci    this.rollup.share.arkProjectConfig.cachePath = this.rollup.share.projectConfig.cachePath;
16307ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
16407ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
16507ac75b1Sopenharmony_ci        expect(shouldETSOrTSFileTransformToJS(filePath, this.rollup.share.arkProjectConfig) === true).to.be.true;
16607ac75b1Sopenharmony_ci      }
16707ac75b1Sopenharmony_ci    }
16807ac75b1Sopenharmony_ci  });
16907ac75b1Sopenharmony_ci
17007ac75b1Sopenharmony_ci  mocha.it('2-1-2: test shouldETSOrTSFileTransformToJS under build debug: arkProjectConfig.processTs is true', function () {
17107ac75b1Sopenharmony_ci    this.rollup.build();
17207ac75b1Sopenharmony_ci    this.mockfileList = this.rollup.getModuleIds();
17307ac75b1Sopenharmony_ci    this.rollup.share.arkProjectConfig.cachePath = this.rollup.share.projectConfig.cachePath;
17407ac75b1Sopenharmony_ci    this.rollup.share.arkProjectConfig.processTs = true;
17507ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
17607ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
17707ac75b1Sopenharmony_ci        compilingEtsOrTsFiles.push(filePath);
17807ac75b1Sopenharmony_ci        hasTsNoCheckOrTsIgnoreFiles.push(filePath);
17907ac75b1Sopenharmony_ci        expect(shouldETSOrTSFileTransformToJS(filePath, this.rollup.share.arkProjectConfig) === true).to.be.true;
18007ac75b1Sopenharmony_ci      }
18107ac75b1Sopenharmony_ci    }
18207ac75b1Sopenharmony_ci  });
18307ac75b1Sopenharmony_ci
18407ac75b1Sopenharmony_ci  mocha.it('2-2: test shouldETSOrTSFileTransformToJS under build release', function () {
18507ac75b1Sopenharmony_ci    this.rollup.build(RELEASE);
18607ac75b1Sopenharmony_ci    this.mockfileList = this.rollup.getModuleIds();
18707ac75b1Sopenharmony_ci    this.rollup.share.arkProjectConfig.cachePath = this.rollup.share.projectConfig.cachePath;
18807ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
18907ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
19007ac75b1Sopenharmony_ci        expect(shouldETSOrTSFileTransformToJS(filePath, this.rollup.share.arkProjectConfig) === true).to.be.true;
19107ac75b1Sopenharmony_ci      }
19207ac75b1Sopenharmony_ci    }
19307ac75b1Sopenharmony_ci  });
19407ac75b1Sopenharmony_ci
19507ac75b1Sopenharmony_ci  mocha.it('2-3: test shouldETSOrTSFileTransformToJS under preview debug', function () {
19607ac75b1Sopenharmony_ci    this.rollup.preview();
19707ac75b1Sopenharmony_ci    this.mockfileList = this.rollup.getModuleIds();
19807ac75b1Sopenharmony_ci    this.rollup.share.arkProjectConfig.cachePath = this.rollup.share.projectConfig.cachePath;
19907ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
20007ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
20107ac75b1Sopenharmony_ci        expect(shouldETSOrTSFileTransformToJS(filePath, this.rollup.share.arkProjectConfig) === true).to.be.true;
20207ac75b1Sopenharmony_ci      }
20307ac75b1Sopenharmony_ci    }
20407ac75b1Sopenharmony_ci  });
20507ac75b1Sopenharmony_ci
20607ac75b1Sopenharmony_ci  mocha.it('2-4: test shouldETSOrTSFileTransformToJS under hot reload debug', function () {
20707ac75b1Sopenharmony_ci    this.rollup.hotReload();
20807ac75b1Sopenharmony_ci    this.mockfileList = this.rollup.getModuleIds();
20907ac75b1Sopenharmony_ci    this.rollup.share.arkProjectConfig.cachePath = this.rollup.share.projectConfig.cachePath;
21007ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
21107ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
21207ac75b1Sopenharmony_ci        expect(shouldETSOrTSFileTransformToJS(filePath, this.rollup.share.arkProjectConfig) === true).to.be.true;
21307ac75b1Sopenharmony_ci      }
21407ac75b1Sopenharmony_ci    }
21507ac75b1Sopenharmony_ci  });
21607ac75b1Sopenharmony_ci
21707ac75b1Sopenharmony_ci  mocha.it('2-5: test shouldETSOrTSFileTransformToJS under build release and enable obuscate file name', function () {
21807ac75b1Sopenharmony_ci    this.rollup.build(RELEASE);
21907ac75b1Sopenharmony_ci    this.mockfileList = this.rollup.getModuleIds();
22007ac75b1Sopenharmony_ci    this.rollup.share.arkProjectConfig.cachePath = this.rollup.share.projectConfig.cachePath;
22107ac75b1Sopenharmony_ci
22207ac75b1Sopenharmony_ci    this.rollup.share.projectConfig = {
22307ac75b1Sopenharmony_ci      buildMode: 'Release'
22407ac75b1Sopenharmony_ci    }
22507ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.obfuscationMergedObConfig = {
22607ac75b1Sopenharmony_ci      options: {
22707ac75b1Sopenharmony_ci        enableFileNameObfuscation: true
22807ac75b1Sopenharmony_ci      }
22907ac75b1Sopenharmony_ci    };
23007ac75b1Sopenharmony_ci    this.rollup.share.arkProjectConfig.processTs = true;
23107ac75b1Sopenharmony_ci    const projectConfig: Object = Object.assign(this.rollup.share.arkProjectConfig, this.rollup.share.projectConfig);
23207ac75b1Sopenharmony_ci
23307ac75b1Sopenharmony_ci    const currentDir = path.dirname(__dirname);
23407ac75b1Sopenharmony_ci    const testMainDir = path.join(currentDir, "../../test/ark_compiler_ut/testdata/testcase_def/entry/build/entry/src/main");
23507ac75b1Sopenharmony_ci    let reservedFileNamesDirectories = testMainDir.split("/").filter(directory => directory !== "");
23607ac75b1Sopenharmony_ci    reservedFileNamesDirectories = reservedFileNamesDirectories.concat(["pages", "entryability"]);
23707ac75b1Sopenharmony_ci
23807ac75b1Sopenharmony_ci    const arkguardConfig = {
23907ac75b1Sopenharmony_ci      mRenameFileName: {
24007ac75b1Sopenharmony_ci        mEnable: true,
24107ac75b1Sopenharmony_ci        mNameGeneratorType: 1,
24207ac75b1Sopenharmony_ci        mReservedFileNames: reservedFileNamesDirectories
24307ac75b1Sopenharmony_ci      },
24407ac75b1Sopenharmony_ci      mPerformancePrinter: []
24507ac75b1Sopenharmony_ci    }
24607ac75b1Sopenharmony_ci
24707ac75b1Sopenharmony_ci    let arkObfuscator: ArkObfuscator = new ArkObfuscator();
24807ac75b1Sopenharmony_ci    arkObfuscator.init(arkguardConfig);
24907ac75b1Sopenharmony_ci
25007ac75b1Sopenharmony_ci    let index = 0
25107ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
25207ac75b1Sopenharmony_ci      cleanUpFilesList();
25307ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
25407ac75b1Sopenharmony_ci        if (index == 0) {
25507ac75b1Sopenharmony_ci          const directory = path.dirname(filePath);
25607ac75b1Sopenharmony_ci          const tempPath = path.join(directory, "../../../build/entry/src/main/entryability")
25707ac75b1Sopenharmony_ci          const bFilePath = path.join(tempPath, 'b.js');
25807ac75b1Sopenharmony_ci          fs.writeFileSync(bFilePath, 'console.log("b.js created");');
25907ac75b1Sopenharmony_ci          expect(bFilePath !== filePath).to.be.true;
26007ac75b1Sopenharmony_ci          expect(shouldETSOrTSFileTransformToJS(filePath, projectConfig) === true).to.be.true;
26107ac75b1Sopenharmony_ci          fs.unlinkSync(bFilePath);
26207ac75b1Sopenharmony_ci        }
26307ac75b1Sopenharmony_ci      }
26407ac75b1Sopenharmony_ci      index++;
26507ac75b1Sopenharmony_ci    }
26607ac75b1Sopenharmony_ci  });
26707ac75b1Sopenharmony_ci
26807ac75b1Sopenharmony_ci  mocha.it('3-1: test writeFileContent under build debug', function () {
26907ac75b1Sopenharmony_ci    this.rollup.build();
27007ac75b1Sopenharmony_ci    const mockFileList: object = this.rollup.getModuleIds();
27107ac75b1Sopenharmony_ci    for (const moduleId of mockFileList) {
27207ac75b1Sopenharmony_ci      if (moduleId.endsWith(EXTNAME_TS) || moduleId.endsWith(EXTNAME_ETS) || moduleId.endsWith(EXTNAME_JS)) {
27307ac75b1Sopenharmony_ci        const code: string = fs.readFileSync(moduleId, 'utf-8');
27407ac75b1Sopenharmony_ci        const metaInfo: Object = this.rollup.getModuleInfo(moduleId).meta;
27507ac75b1Sopenharmony_ci        const moduleSource = new ModuleSourceFileMock(moduleId, code, metaInfo);
27607ac75b1Sopenharmony_ci        moduleSource.initPluginEnvMock(this.rollup);
27707ac75b1Sopenharmony_ci        const filePath = genTemporaryPath(moduleSource.moduleId, moduleSource.projectConfig.projectPath,
27807ac75b1Sopenharmony_ci          moduleSource.projectConfig.cachePath, moduleSource.projectConfig, moduleSource.metaInfo);
27907ac75b1Sopenharmony_ci        utUtils.writeFileContent(moduleSource.moduleId, filePath, moduleSource.source,
28007ac75b1Sopenharmony_ci          moduleSource.projectConfig, moduleSource.logger);
28107ac75b1Sopenharmony_ci        const newFilePath = changeFileExtension(filePath, EXTNAME_JS);
28207ac75b1Sopenharmony_ci        const readFilecontent = fs.readFileSync(newFilePath, 'utf-8');
28307ac75b1Sopenharmony_ci        expect(readFilecontent === moduleSource.source).to.be.true;
28407ac75b1Sopenharmony_ci      }
28507ac75b1Sopenharmony_ci    }
28607ac75b1Sopenharmony_ci  });
28707ac75b1Sopenharmony_ci
28807ac75b1Sopenharmony_ci  mocha.it('3-2: test writeFileContent under build release', function () {
28907ac75b1Sopenharmony_ci    this.rollup.build(RELEASE);
29007ac75b1Sopenharmony_ci    SourceMapGenerator.initInstance(this.rollup);
29107ac75b1Sopenharmony_ci    const mockFileList: object = this.rollup.getModuleIds();
29207ac75b1Sopenharmony_ci    for (const moduleId of mockFileList) {
29307ac75b1Sopenharmony_ci      if (moduleId.endsWith(EXTNAME_TS) || moduleId.endsWith(EXTNAME_ETS) || moduleId.endsWith(EXTNAME_JS)) {
29407ac75b1Sopenharmony_ci        const code: string = fs.readFileSync(moduleId, 'utf-8');
29507ac75b1Sopenharmony_ci        const metaInfo: Object = this.rollup.getModuleInfo(moduleId).meta;
29607ac75b1Sopenharmony_ci        const moduleSource = new ModuleSourceFileMock(moduleId, code, metaInfo);
29707ac75b1Sopenharmony_ci        moduleSource.initPluginEnvMock(this.rollup);
29807ac75b1Sopenharmony_ci        const filePath = genTemporaryPath(moduleSource.moduleId, moduleSource.projectConfig.projectPath,
29907ac75b1Sopenharmony_ci          moduleSource.projectConfig.cachePath, moduleSource.projectConfig, moduleSource.metaInfo);
30007ac75b1Sopenharmony_ci        utUtils.writeFileContent(moduleSource.moduleId, filePath, moduleSource.source,
30107ac75b1Sopenharmony_ci          moduleSource.projectConfig, moduleSource.logger);
30207ac75b1Sopenharmony_ci        const newFilePath = changeFileExtension(filePath, EXTNAME_JS);
30307ac75b1Sopenharmony_ci        const readFilecontent = fs.readFileSync(newFilePath, 'utf-8');
30407ac75b1Sopenharmony_ci        expect(readFilecontent === moduleSource.source).to.be.true;
30507ac75b1Sopenharmony_ci      }
30607ac75b1Sopenharmony_ci    }
30707ac75b1Sopenharmony_ci    SourceMapGenerator.cleanSourceMapObject();
30807ac75b1Sopenharmony_ci  });
30907ac75b1Sopenharmony_ci
31007ac75b1Sopenharmony_ci  mocha.it('3-3: test writeFileContent under preview debug', function () {
31107ac75b1Sopenharmony_ci    this.rollup.preview();
31207ac75b1Sopenharmony_ci    const mockFileList: object = this.rollup.getModuleIds();
31307ac75b1Sopenharmony_ci    for (const moduleId of mockFileList) {
31407ac75b1Sopenharmony_ci      if (moduleId.endsWith(EXTNAME_TS) || moduleId.endsWith(EXTNAME_ETS) || moduleId.endsWith(EXTNAME_JS)) {
31507ac75b1Sopenharmony_ci        const code: string = fs.readFileSync(moduleId, 'utf-8');
31607ac75b1Sopenharmony_ci        const metaInfo: Object = this.rollup.getModuleInfo(moduleId).meta;
31707ac75b1Sopenharmony_ci        const moduleSource = new ModuleSourceFileMock(moduleId, code, metaInfo);
31807ac75b1Sopenharmony_ci        moduleSource.initPluginEnvMock(this.rollup);
31907ac75b1Sopenharmony_ci        const filePath = genTemporaryPath(moduleSource.moduleId, moduleSource.projectConfig.projectPath,
32007ac75b1Sopenharmony_ci          moduleSource.projectConfig.cachePath, moduleSource.projectConfig, moduleSource.metaInfo);
32107ac75b1Sopenharmony_ci        utUtils.writeFileContent(moduleSource.moduleId, filePath, moduleSource.source,
32207ac75b1Sopenharmony_ci          moduleSource.projectConfig, moduleSource.logger);
32307ac75b1Sopenharmony_ci        const newFilePath = changeFileExtension(filePath, EXTNAME_JS);
32407ac75b1Sopenharmony_ci        const readFilecontent = fs.readFileSync(newFilePath, 'utf-8');
32507ac75b1Sopenharmony_ci        expect(readFilecontent === moduleSource.source).to.be.true;
32607ac75b1Sopenharmony_ci      }
32707ac75b1Sopenharmony_ci    }
32807ac75b1Sopenharmony_ci  });
32907ac75b1Sopenharmony_ci
33007ac75b1Sopenharmony_ci  mocha.it('3-4: test writeFileContent under hot reload debug', function () {
33107ac75b1Sopenharmony_ci    this.rollup.hotReload();
33207ac75b1Sopenharmony_ci    const mockFileList: object = this.rollup.getModuleIds();
33307ac75b1Sopenharmony_ci    for (const moduleId of mockFileList) {
33407ac75b1Sopenharmony_ci      if (moduleId.endsWith(EXTNAME_TS) || moduleId.endsWith(EXTNAME_ETS) || moduleId.endsWith(EXTNAME_JS)) {
33507ac75b1Sopenharmony_ci        const code: string = fs.readFileSync(moduleId, 'utf-8');
33607ac75b1Sopenharmony_ci        const metaInfo: Object = this.rollup.getModuleInfo(moduleId).meta;
33707ac75b1Sopenharmony_ci        const moduleSource = new ModuleSourceFileMock(moduleId, code, metaInfo);
33807ac75b1Sopenharmony_ci        moduleSource.initPluginEnvMock(this.rollup);
33907ac75b1Sopenharmony_ci        const filePath = genTemporaryPath(moduleSource.moduleId, moduleSource.projectConfig.projectPath,
34007ac75b1Sopenharmony_ci          moduleSource.projectConfig.cachePath, moduleSource.projectConfig, moduleSource.metaInfo);
34107ac75b1Sopenharmony_ci        utUtils.writeFileContent(moduleSource.moduleId, filePath, moduleSource.source,
34207ac75b1Sopenharmony_ci          moduleSource.projectConfig, moduleSource.logger);
34307ac75b1Sopenharmony_ci        const newFilePath = changeFileExtension(filePath, EXTNAME_JS);
34407ac75b1Sopenharmony_ci        const readFilecontent = fs.readFileSync(newFilePath, 'utf-8');
34507ac75b1Sopenharmony_ci        expect(readFilecontent === moduleSource.source).to.be.true;
34607ac75b1Sopenharmony_ci      }
34707ac75b1Sopenharmony_ci    }
34807ac75b1Sopenharmony_ci  });
34907ac75b1Sopenharmony_ci
35007ac75b1Sopenharmony_ci  mocha.it('4-1-1: test updateSourceMap under build debug: originMap is null', async function () {
35107ac75b1Sopenharmony_ci    this.rollup.build();
35207ac75b1Sopenharmony_ci    const dynamicImportpath = this.rollup.share.projectConfig.DynamicImportpath;
35307ac75b1Sopenharmony_ci    this.rollup.moduleInfos.push(new ModuleInfo(dynamicImportpath,
35407ac75b1Sopenharmony_ci      this.rollup.share.projectConfig.entryModuleName,
35507ac75b1Sopenharmony_ci      this.rollup.share.projectConfig.modulePath)
35607ac75b1Sopenharmony_ci    );
35707ac75b1Sopenharmony_ci    const sourceMapGenerator = SourceMapGenerator.initInstance(this.rollup);
35807ac75b1Sopenharmony_ci
35907ac75b1Sopenharmony_ci    const relativeSourceFilePath =
36007ac75b1Sopenharmony_ci      toUnixPath(dynamicImportpath.replace(this.rollup.share.projectConfig.projectTopDir + path.sep, ''));
36107ac75b1Sopenharmony_ci    const code: string = fs.readFileSync(dynamicImportpath, 'utf-8');
36207ac75b1Sopenharmony_ci    const moduleSource = new ModuleSourceFile(dynamicImportpath, code);
36307ac75b1Sopenharmony_ci    const sourceCode: MagicString = new MagicString(<string>moduleSource.source);
36407ac75b1Sopenharmony_ci    const updatedMap: object = sourceCode.generateMap({
36507ac75b1Sopenharmony_ci      source: relativeSourceFilePath,
36607ac75b1Sopenharmony_ci      file: `${path.basename(moduleSource.moduleId)}`,
36707ac75b1Sopenharmony_ci      includeContent: false,
36807ac75b1Sopenharmony_ci      hires: true
36907ac75b1Sopenharmony_ci    });
37007ac75b1Sopenharmony_ci
37107ac75b1Sopenharmony_ci    updatedMap[SOURCE] = [relativeSourceFilePath];
37207ac75b1Sopenharmony_ci    updatedMap[FILE] = path.basename(relativeSourceFilePath);
37307ac75b1Sopenharmony_ci    updatedMap[ENTRY_PACKAGE_INFO] = 'entry|1.0.0';
37407ac75b1Sopenharmony_ci
37507ac75b1Sopenharmony_ci    sourceMapGenerator.updateSourceMap(dynamicImportpath, await updateSourceMap(undefined, updatedMap));
37607ac75b1Sopenharmony_ci    expect(sourceMapGenerator.getSourceMap(dynamicImportpath) === updatedMap).to.be.true;
37707ac75b1Sopenharmony_ci    // pop dynamicImportpath moduleInfo
37807ac75b1Sopenharmony_ci    this.rollup.moduleInfos.pop();
37907ac75b1Sopenharmony_ci    SourceMapGenerator.cleanSourceMapObject();
38007ac75b1Sopenharmony_ci  });
38107ac75b1Sopenharmony_ci
38207ac75b1Sopenharmony_ci  mocha.it('4-1-2: test updateSourceMap under build debug: newMap is null', async function () {
38307ac75b1Sopenharmony_ci    this.rollup.build();
38407ac75b1Sopenharmony_ci    const dynamicImportpath = this.rollup.share.projectConfig.DynamicImportpath;
38507ac75b1Sopenharmony_ci    this.rollup.moduleInfos.push(new ModuleInfo(dynamicImportpath,
38607ac75b1Sopenharmony_ci      this.rollup.share.projectConfig.entryModuleName,
38707ac75b1Sopenharmony_ci      this.rollup.share.projectConfig.modulePath)
38807ac75b1Sopenharmony_ci    );
38907ac75b1Sopenharmony_ci    const sourceMapGenerator = SourceMapGenerator.initInstance(this.rollup);
39007ac75b1Sopenharmony_ci
39107ac75b1Sopenharmony_ci    const relativeSourceFilePath =
39207ac75b1Sopenharmony_ci      toUnixPath(dynamicImportpath.replace(this.rollup.share.projectConfig.projectTopDir + path.sep, ''));
39307ac75b1Sopenharmony_ci    const code: string = fs.readFileSync(dynamicImportpath, 'utf-8');
39407ac75b1Sopenharmony_ci    const moduleSource = new ModuleSourceFile(dynamicImportpath, code);
39507ac75b1Sopenharmony_ci    const sourceCode: MagicString = new MagicString(<string>moduleSource.source);
39607ac75b1Sopenharmony_ci    const updatedMap: object = sourceCode.generateMap({
39707ac75b1Sopenharmony_ci      source: relativeSourceFilePath,
39807ac75b1Sopenharmony_ci      file: `${path.basename(moduleSource.moduleId)}`,
39907ac75b1Sopenharmony_ci      includeContent: false,
40007ac75b1Sopenharmony_ci      hires: true
40107ac75b1Sopenharmony_ci    });
40207ac75b1Sopenharmony_ci
40307ac75b1Sopenharmony_ci    updatedMap[SOURCE] = [relativeSourceFilePath];
40407ac75b1Sopenharmony_ci    updatedMap[FILE] = path.basename(relativeSourceFilePath);
40507ac75b1Sopenharmony_ci    updatedMap[ENTRY_PACKAGE_INFO] = 'entry|1.0.0';
40607ac75b1Sopenharmony_ci
40707ac75b1Sopenharmony_ci    sourceMapGenerator.updateSourceMap(dynamicImportpath, await updateSourceMap(updatedMap));
40807ac75b1Sopenharmony_ci    expect(sourceMapGenerator.getSourceMap(dynamicImportpath) === updatedMap).to.be.true;
40907ac75b1Sopenharmony_ci    // pop dynamicImportpath moduleInfo
41007ac75b1Sopenharmony_ci    this.rollup.moduleInfos.pop();
41107ac75b1Sopenharmony_ci    SourceMapGenerator.cleanSourceMapObject();
41207ac75b1Sopenharmony_ci  });
41307ac75b1Sopenharmony_ci
41407ac75b1Sopenharmony_ci  mocha.it('4-1-3: test updateSourceMap under build debug: originMap and newMap is not null', async function () {
41507ac75b1Sopenharmony_ci    this.rollup.build();
41607ac75b1Sopenharmony_ci    const dynamicImportpath = this.rollup.share.projectConfig.DynamicImportpath;
41707ac75b1Sopenharmony_ci    this.rollup.moduleInfos.push(new ModuleInfo(dynamicImportpath,
41807ac75b1Sopenharmony_ci      this.rollup.share.projectConfig.entryModuleName,
41907ac75b1Sopenharmony_ci      this.rollup.share.projectConfig.modulePath)
42007ac75b1Sopenharmony_ci    );
42107ac75b1Sopenharmony_ci    const sourceMapGenerator = SourceMapGenerator.initInstance(this.rollup);
42207ac75b1Sopenharmony_ci
42307ac75b1Sopenharmony_ci    const relativeSourceFilePath =
42407ac75b1Sopenharmony_ci      toUnixPath(dynamicImportpath.replace(this.rollup.share.projectConfig.projectTopDir + path.sep, ''));
42507ac75b1Sopenharmony_ci    const code: string = fs.readFileSync(dynamicImportpath, 'utf-8');
42607ac75b1Sopenharmony_ci    const moduleSource = new ModuleSourceFile(dynamicImportpath, code);
42707ac75b1Sopenharmony_ci    const sourceCode: MagicString = new MagicString(<string>moduleSource.source);
42807ac75b1Sopenharmony_ci    const updatedMap: object = sourceCode.generateMap({
42907ac75b1Sopenharmony_ci      source: relativeSourceFilePath,
43007ac75b1Sopenharmony_ci      file: `${path.basename(moduleSource.moduleId)}`,
43107ac75b1Sopenharmony_ci      includeContent: false,
43207ac75b1Sopenharmony_ci      hires: true
43307ac75b1Sopenharmony_ci    });
43407ac75b1Sopenharmony_ci    const arraylist = Array.from(this.rollup.share.allFiles);
43507ac75b1Sopenharmony_ci    const syncCode: string = fs.readFileSync(arraylist[2].toString(), 'utf-8');
43607ac75b1Sopenharmony_ci    const dynamicModuleSource = new ModuleSourceFile(dynamicImportpath, syncCode);
43707ac75b1Sopenharmony_ci    const codeString: MagicString = new MagicString(<string>dynamicModuleSource.source);
43807ac75b1Sopenharmony_ci    const sourceMap: object = codeString.generateMap({
43907ac75b1Sopenharmony_ci      source: relativeSourceFilePath,
44007ac75b1Sopenharmony_ci      file: `${path.basename(dynamicModuleSource.moduleId)}`,
44107ac75b1Sopenharmony_ci      includeContent: false,
44207ac75b1Sopenharmony_ci      hires: true
44307ac75b1Sopenharmony_ci    });
44407ac75b1Sopenharmony_ci
44507ac75b1Sopenharmony_ci    delete sourceMap.sourcesContent;
44607ac75b1Sopenharmony_ci    updatedMap[SOURCE] = [relativeSourceFilePath];
44707ac75b1Sopenharmony_ci    updatedMap[FILE] = path.basename(relativeSourceFilePath);
44807ac75b1Sopenharmony_ci
44907ac75b1Sopenharmony_ci    sourceMapGenerator.updateSourceMap(dynamicImportpath, await updateSourceMap(sourceMap, updatedMap));
45007ac75b1Sopenharmony_ci    const readSourceMap =
45107ac75b1Sopenharmony_ci      JSON.parse(fs.readFileSync(`${this.rollup.share.projectConfig.projectTopDir}/${UPDATESOURCEMAP}`, 'utf-8'));
45207ac75b1Sopenharmony_ci    expect(sourceMapGenerator.getSourceMap(dynamicImportpath).file === DYNAMICIMPORT_ETS).to.be.true;
45307ac75b1Sopenharmony_ci    expect(sourceMapGenerator.getSourceMap(dynamicImportpath).mappings === readSourceMap.mappings).to.be.true;
45407ac75b1Sopenharmony_ci    // pop dynamicImportpath moduleInfo
45507ac75b1Sopenharmony_ci    this.rollup.moduleInfos.pop();
45607ac75b1Sopenharmony_ci    SourceMapGenerator.cleanSourceMapObject();
45707ac75b1Sopenharmony_ci  });
45807ac75b1Sopenharmony_ci
45907ac75b1Sopenharmony_ci  mocha.it('4-2: test updateSourceMap under build release', async function () {
46007ac75b1Sopenharmony_ci    this.rollup.build(RELEASE);
46107ac75b1Sopenharmony_ci    const dynamicImportpath = this.rollup.share.projectConfig.DynamicImportpath;
46207ac75b1Sopenharmony_ci    this.rollup.moduleInfos.push(new ModuleInfo(dynamicImportpath,
46307ac75b1Sopenharmony_ci      this.rollup.share.projectConfig.entryModuleName,
46407ac75b1Sopenharmony_ci      this.rollup.share.projectConfig.modulePath)
46507ac75b1Sopenharmony_ci    );
46607ac75b1Sopenharmony_ci    const sourceMapGenerator = SourceMapGenerator.initInstance(this.rollup);
46707ac75b1Sopenharmony_ci
46807ac75b1Sopenharmony_ci    const relativeSourceFilePath =
46907ac75b1Sopenharmony_ci      toUnixPath(dynamicImportpath.replace(this.rollup.share.projectConfig.projectTopDir + path.sep, ''));
47007ac75b1Sopenharmony_ci    const code: string = fs.readFileSync(dynamicImportpath, 'utf-8');
47107ac75b1Sopenharmony_ci    const moduleSource = new ModuleSourceFile(dynamicImportpath, code);
47207ac75b1Sopenharmony_ci    const sourceCode: MagicString = new MagicString(<string>moduleSource.source);
47307ac75b1Sopenharmony_ci    const updatedMap: object = sourceCode.generateMap({
47407ac75b1Sopenharmony_ci      source: relativeSourceFilePath,
47507ac75b1Sopenharmony_ci      file: `${path.basename(moduleSource.moduleId)}`,
47607ac75b1Sopenharmony_ci      includeContent: false,
47707ac75b1Sopenharmony_ci      hires: true
47807ac75b1Sopenharmony_ci    });
47907ac75b1Sopenharmony_ci
48007ac75b1Sopenharmony_ci    updatedMap[SOURCE] = [relativeSourceFilePath];
48107ac75b1Sopenharmony_ci    updatedMap[FILE] = path.basename(relativeSourceFilePath);
48207ac75b1Sopenharmony_ci    updatedMap[ENTRY_PACKAGE_INFO] = 'entry|1.0.0';
48307ac75b1Sopenharmony_ci
48407ac75b1Sopenharmony_ci    sourceMapGenerator.updateSourceMap(dynamicImportpath, await updateSourceMap(undefined, updatedMap));
48507ac75b1Sopenharmony_ci    expect(sourceMapGenerator.getSourceMap(dynamicImportpath) === updatedMap).to.be.true;
48607ac75b1Sopenharmony_ci    // pop dynamicImportpath moduleInfo
48707ac75b1Sopenharmony_ci    this.rollup.moduleInfos.pop();
48807ac75b1Sopenharmony_ci    SourceMapGenerator.cleanSourceMapObject();
48907ac75b1Sopenharmony_ci  });
49007ac75b1Sopenharmony_ci
49107ac75b1Sopenharmony_ci  mocha.it('4-3: test updateSourceMap under preview debug', async function () {
49207ac75b1Sopenharmony_ci    this.rollup.preview();
49307ac75b1Sopenharmony_ci    const dynamicImportpath = this.rollup.share.projectConfig.DynamicImportpath;
49407ac75b1Sopenharmony_ci    this.rollup.moduleInfos.push(new ModuleInfo(dynamicImportpath,
49507ac75b1Sopenharmony_ci      this.rollup.share.projectConfig.entryModuleName,
49607ac75b1Sopenharmony_ci      this.rollup.share.projectConfig.modulePath)
49707ac75b1Sopenharmony_ci    );
49807ac75b1Sopenharmony_ci    const sourceMapGenerator = SourceMapGenerator.initInstance(this.rollup);
49907ac75b1Sopenharmony_ci
50007ac75b1Sopenharmony_ci    const relativeSourceFilePath =
50107ac75b1Sopenharmony_ci      toUnixPath(dynamicImportpath.replace(this.rollup.share.projectConfig.projectTopDir + path.sep, ''));
50207ac75b1Sopenharmony_ci    const code: string = fs.readFileSync(dynamicImportpath, 'utf-8');
50307ac75b1Sopenharmony_ci    const moduleSource = new ModuleSourceFile(dynamicImportpath, code);
50407ac75b1Sopenharmony_ci    const sourceCode: MagicString = new MagicString(<string>moduleSource.source);
50507ac75b1Sopenharmony_ci    const updatedMap: object = sourceCode.generateMap({
50607ac75b1Sopenharmony_ci      source: relativeSourceFilePath,
50707ac75b1Sopenharmony_ci      file: `${path.basename(moduleSource.moduleId)}`,
50807ac75b1Sopenharmony_ci      includeContent: false,
50907ac75b1Sopenharmony_ci      hires: true
51007ac75b1Sopenharmony_ci    });
51107ac75b1Sopenharmony_ci
51207ac75b1Sopenharmony_ci    updatedMap[SOURCE] = [relativeSourceFilePath];
51307ac75b1Sopenharmony_ci    updatedMap[FILE] = path.basename(relativeSourceFilePath);
51407ac75b1Sopenharmony_ci    updatedMap[ENTRY_PACKAGE_INFO] = 'entry|1.0.0';
51507ac75b1Sopenharmony_ci
51607ac75b1Sopenharmony_ci    sourceMapGenerator.updateSourceMap(dynamicImportpath, await updateSourceMap(undefined, updatedMap));
51707ac75b1Sopenharmony_ci    expect(sourceMapGenerator.getSourceMap(dynamicImportpath) === updatedMap).to.be.true;
51807ac75b1Sopenharmony_ci    // pop dynamicImportpath moduleInfo
51907ac75b1Sopenharmony_ci    this.rollup.moduleInfos.pop();
52007ac75b1Sopenharmony_ci    SourceMapGenerator.cleanSourceMapObject();
52107ac75b1Sopenharmony_ci  });
52207ac75b1Sopenharmony_ci
52307ac75b1Sopenharmony_ci  mocha.it('4-4: test updateSourceMap under hot reload debug', async function () {
52407ac75b1Sopenharmony_ci    this.rollup.hotReload();
52507ac75b1Sopenharmony_ci    const dynamicImportpath = this.rollup.share.projectConfig.DynamicImportpath;
52607ac75b1Sopenharmony_ci    this.rollup.moduleInfos.push(new ModuleInfo(dynamicImportpath,
52707ac75b1Sopenharmony_ci      this.rollup.share.projectConfig.entryModuleName,
52807ac75b1Sopenharmony_ci      this.rollup.share.projectConfig.modulePath)
52907ac75b1Sopenharmony_ci    );
53007ac75b1Sopenharmony_ci    const sourceMapGenerator = SourceMapGenerator.initInstance(this.rollup);
53107ac75b1Sopenharmony_ci
53207ac75b1Sopenharmony_ci    const relativeSourceFilePath =
53307ac75b1Sopenharmony_ci      toUnixPath(dynamicImportpath.replace(this.rollup.share.projectConfig.projectTopDir + path.sep, ''));
53407ac75b1Sopenharmony_ci    const code: string = fs.readFileSync(dynamicImportpath, 'utf-8');
53507ac75b1Sopenharmony_ci    const moduleSource = new ModuleSourceFile(dynamicImportpath, code);
53607ac75b1Sopenharmony_ci    const sourceCode: MagicString = new MagicString(<string>moduleSource.source);
53707ac75b1Sopenharmony_ci    const updatedMap: object = sourceCode.generateMap({
53807ac75b1Sopenharmony_ci      source: relativeSourceFilePath,
53907ac75b1Sopenharmony_ci      file: `${path.basename(moduleSource.moduleId)}`,
54007ac75b1Sopenharmony_ci      includeContent: false,
54107ac75b1Sopenharmony_ci      hires: true
54207ac75b1Sopenharmony_ci    });
54307ac75b1Sopenharmony_ci
54407ac75b1Sopenharmony_ci    updatedMap[SOURCE] = [relativeSourceFilePath];
54507ac75b1Sopenharmony_ci    updatedMap[FILE] = path.basename(relativeSourceFilePath);
54607ac75b1Sopenharmony_ci    updatedMap[ENTRY_PACKAGE_INFO] = 'entry|1.0.0';
54707ac75b1Sopenharmony_ci
54807ac75b1Sopenharmony_ci    sourceMapGenerator.updateSourceMap(dynamicImportpath, await updateSourceMap(undefined, updatedMap));
54907ac75b1Sopenharmony_ci    expect(sourceMapGenerator.getSourceMap(dynamicImportpath) === updatedMap).to.be.true;
55007ac75b1Sopenharmony_ci    // pop dynamicImportpath moduleInfo
55107ac75b1Sopenharmony_ci    this.rollup.moduleInfos.pop();
55207ac75b1Sopenharmony_ci    SourceMapGenerator.cleanSourceMapObject();
55307ac75b1Sopenharmony_ci  });
55407ac75b1Sopenharmony_ci
55507ac75b1Sopenharmony_ci  mocha.it('5-1: test isAotMode under build debug', function () {
55607ac75b1Sopenharmony_ci    this.rollup.build();
55707ac75b1Sopenharmony_ci    const returnInfo = isAotMode(this.rollup.share.projectConfig);
55807ac75b1Sopenharmony_ci    expect(returnInfo).to.be.false;
55907ac75b1Sopenharmony_ci  });
56007ac75b1Sopenharmony_ci
56107ac75b1Sopenharmony_ci  mocha.it('5-2: test isAotMode under build release', function () {
56207ac75b1Sopenharmony_ci    this.rollup.build(RELEASE);
56307ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.compileMode = ESMODULE;
56407ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.anBuildMode = AOT_FULL;
56507ac75b1Sopenharmony_ci    const returnInfo = isAotMode(this.rollup.share.projectConfig);
56607ac75b1Sopenharmony_ci    expect(returnInfo).to.be.true;
56707ac75b1Sopenharmony_ci  });
56807ac75b1Sopenharmony_ci
56907ac75b1Sopenharmony_ci  mocha.it('5-3: test isAotMode under preview debug', function () {
57007ac75b1Sopenharmony_ci    this.rollup.preview();
57107ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.compileMode = JSBUNDLE;
57207ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.anBuildMode = AOT_PARTIAL;
57307ac75b1Sopenharmony_ci    const buildModeIsAotType = isAotMode(this.rollup.share.projectConfig);
57407ac75b1Sopenharmony_ci    expect(buildModeIsAotType).to.be.false;
57507ac75b1Sopenharmony_ci  });
57607ac75b1Sopenharmony_ci
57707ac75b1Sopenharmony_ci  mocha.it('5-4: test isAotMode under hot reload debug', function () {
57807ac75b1Sopenharmony_ci    this.rollup.hotReload();
57907ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.compileMode = ESMODULE;
58007ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.anBuildMode = AOT_TYPE;
58107ac75b1Sopenharmony_ci    const buildModeIsAotType = isAotMode(this.rollup.share.projectConfig);
58207ac75b1Sopenharmony_ci    expect(buildModeIsAotType).to.be.true;
58307ac75b1Sopenharmony_ci  });
58407ac75b1Sopenharmony_ci
58507ac75b1Sopenharmony_ci  mocha.it('5-5: test isAotMode under hot fix debug', function () {
58607ac75b1Sopenharmony_ci    projectConfig.buildMode = DEBUG;
58707ac75b1Sopenharmony_ci    projectConfig.compileMode = JSBUNDLE;
58807ac75b1Sopenharmony_ci    projectConfig.anBuildMode = AOT_TYPE;
58907ac75b1Sopenharmony_ci    const buildModeIsAotType = isAotMode(projectConfig);
59007ac75b1Sopenharmony_ci    expect(buildModeIsAotType).to.be.false;
59107ac75b1Sopenharmony_ci  });
59207ac75b1Sopenharmony_ci
59307ac75b1Sopenharmony_ci  mocha.it('5-6: test isAotMode under hot fix release', function () {
59407ac75b1Sopenharmony_ci    projectConfig.buildMode = RELEASE;
59507ac75b1Sopenharmony_ci    projectConfig.compileMode = ESMODULE;
59607ac75b1Sopenharmony_ci    projectConfig.anBuildMode = AOT_PARTIAL;
59707ac75b1Sopenharmony_ci    const buildModeIsAotType = isAotMode(projectConfig);
59807ac75b1Sopenharmony_ci    expect(buildModeIsAotType).to.be.true;
59907ac75b1Sopenharmony_ci  });
60007ac75b1Sopenharmony_ci
60107ac75b1Sopenharmony_ci  mocha.it('6-1: test isDebug under build debug', function () {
60207ac75b1Sopenharmony_ci    this.rollup.build();
60307ac75b1Sopenharmony_ci    const returnInfo = isDebug(this.rollup.share.projectConfig);
60407ac75b1Sopenharmony_ci    expect(returnInfo).to.be.true;
60507ac75b1Sopenharmony_ci  });
60607ac75b1Sopenharmony_ci
60707ac75b1Sopenharmony_ci  mocha.it('6-2: test isDebug under build release', function () {
60807ac75b1Sopenharmony_ci    this.rollup.build(RELEASE);
60907ac75b1Sopenharmony_ci    const returnInfo = isDebug(this.rollup.share.projectConfig);
61007ac75b1Sopenharmony_ci    expect(returnInfo).to.be.false;
61107ac75b1Sopenharmony_ci  });
61207ac75b1Sopenharmony_ci
61307ac75b1Sopenharmony_ci  mocha.it('6-3: test isDebug under preview debug', function () {
61407ac75b1Sopenharmony_ci    this.rollup.preview();
61507ac75b1Sopenharmony_ci    const returnInfo = isDebug(this.rollup.share.projectConfig);
61607ac75b1Sopenharmony_ci    expect(returnInfo).to.be.true;
61707ac75b1Sopenharmony_ci  });
61807ac75b1Sopenharmony_ci
61907ac75b1Sopenharmony_ci  mocha.it('6-4: test isDebug under hot reload debug', function () {
62007ac75b1Sopenharmony_ci    this.rollup.hotReload();
62107ac75b1Sopenharmony_ci    const returnInfo = isDebug(this.rollup.share.projectConfig);
62207ac75b1Sopenharmony_ci    expect(returnInfo).to.be.true;
62307ac75b1Sopenharmony_ci  });
62407ac75b1Sopenharmony_ci
62507ac75b1Sopenharmony_ci  mocha.it('6-5: test isDebug under hot fix debug', function () {
62607ac75b1Sopenharmony_ci    projectConfig.buildMode = DEBUG;
62707ac75b1Sopenharmony_ci    const returnInfo = isDebug(projectConfig);
62807ac75b1Sopenharmony_ci    expect(returnInfo).to.be.true;
62907ac75b1Sopenharmony_ci  });
63007ac75b1Sopenharmony_ci
63107ac75b1Sopenharmony_ci  mocha.it('6-6: test isDebug under hot fix release', function () {
63207ac75b1Sopenharmony_ci    projectConfig.buildMode = RELEASE;
63307ac75b1Sopenharmony_ci    const returnInfo = isDebug(projectConfig);
63407ac75b1Sopenharmony_ci    expect(returnInfo).to.be.false;
63507ac75b1Sopenharmony_ci  });
63607ac75b1Sopenharmony_ci
63707ac75b1Sopenharmony_ci  mocha.it('7-1: test changeFileExtension under build debug', function () {
63807ac75b1Sopenharmony_ci    this.rollup.build();
63907ac75b1Sopenharmony_ci    const targetExt = EXTNAME_TS;
64007ac75b1Sopenharmony_ci    const originExt = '';
64107ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
64207ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
64307ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
64407ac75b1Sopenharmony_ci    for (const file of this.mockfileList) {
64507ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_TS) || file.endsWith(EXTNAME_ETS) || file.endsWith(EXTNAME_JS)) {
64607ac75b1Sopenharmony_ci        const currentExt = originExt.length === 0 ? path.extname(file) : originExt;
64707ac75b1Sopenharmony_ci        const fileWithoutExt = file.substring(0, file.lastIndexOf(currentExt));
64807ac75b1Sopenharmony_ci        const returnInfo = changeFileExtension(file, targetExt, originExt);
64907ac75b1Sopenharmony_ci        expect(returnInfo === fileWithoutExt + targetExt).to.be.true;
65007ac75b1Sopenharmony_ci      }
65107ac75b1Sopenharmony_ci    }
65207ac75b1Sopenharmony_ci  });
65307ac75b1Sopenharmony_ci
65407ac75b1Sopenharmony_ci  mocha.it('7-2: test changeFileExtension under build release', function () {
65507ac75b1Sopenharmony_ci    this.rollup.build(RELEASE);
65607ac75b1Sopenharmony_ci    const targetExt = EXTNAME_TS;
65707ac75b1Sopenharmony_ci    const originExt = '';
65807ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
65907ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
66007ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
66107ac75b1Sopenharmony_ci    for (const file of this.mockfileList) {
66207ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_TS) || file.endsWith(EXTNAME_ETS) || file.endsWith(EXTNAME_JS)) {
66307ac75b1Sopenharmony_ci        const currentExt = originExt.length === 0 ? path.extname(file) : originExt;
66407ac75b1Sopenharmony_ci        const fileWithoutExt = file.substring(0, file.lastIndexOf(currentExt));
66507ac75b1Sopenharmony_ci        const returnInfo = changeFileExtension(file, targetExt, originExt);
66607ac75b1Sopenharmony_ci        expect(returnInfo === fileWithoutExt + targetExt).to.be.true;
66707ac75b1Sopenharmony_ci      }
66807ac75b1Sopenharmony_ci    }
66907ac75b1Sopenharmony_ci  });
67007ac75b1Sopenharmony_ci
67107ac75b1Sopenharmony_ci  mocha.it('7-3: test changeFileExtension under preview debug', function () {
67207ac75b1Sopenharmony_ci    this.rollup.preview();
67307ac75b1Sopenharmony_ci    const targetExt = EXTNAME_TS;
67407ac75b1Sopenharmony_ci    const originExt = '';
67507ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
67607ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
67707ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
67807ac75b1Sopenharmony_ci    for (const file of this.mockfileList) {
67907ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_TS) || file.endsWith(EXTNAME_ETS) || file.endsWith(EXTNAME_JS)) {
68007ac75b1Sopenharmony_ci        const currentExt = originExt.length === 0 ? path.extname(file) : originExt;
68107ac75b1Sopenharmony_ci        const fileWithoutExt = file.substring(0, file.lastIndexOf(currentExt));
68207ac75b1Sopenharmony_ci        const returnInfo = changeFileExtension(file, targetExt, originExt);
68307ac75b1Sopenharmony_ci        expect(returnInfo === fileWithoutExt + targetExt).to.be.true;
68407ac75b1Sopenharmony_ci      }
68507ac75b1Sopenharmony_ci    }
68607ac75b1Sopenharmony_ci  });
68707ac75b1Sopenharmony_ci
68807ac75b1Sopenharmony_ci  mocha.it('7-4: test changeFileExtension under hot reload debug', function () {
68907ac75b1Sopenharmony_ci    this.rollup.hotReload();
69007ac75b1Sopenharmony_ci    const targetExt = EXTNAME_TS;
69107ac75b1Sopenharmony_ci    const originExt = '';
69207ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
69307ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
69407ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
69507ac75b1Sopenharmony_ci    for (const file of this.mockfileList) {
69607ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_TS) || file.endsWith(EXTNAME_ETS) || file.endsWith(EXTNAME_JS)) {
69707ac75b1Sopenharmony_ci        const currentExt = originExt.length === 0 ? path.extname(file) : originExt;
69807ac75b1Sopenharmony_ci        const fileWithoutExt = file.substring(0, file.lastIndexOf(currentExt));
69907ac75b1Sopenharmony_ci        const returnInfo = changeFileExtension(file, targetExt, originExt);
70007ac75b1Sopenharmony_ci        expect(returnInfo === fileWithoutExt + targetExt).to.be.true;
70107ac75b1Sopenharmony_ci      }
70207ac75b1Sopenharmony_ci    }
70307ac75b1Sopenharmony_ci  });
70407ac75b1Sopenharmony_ci
70507ac75b1Sopenharmony_ci  mocha.it('7-5: test changeFileExtension under hot fix debug', function () {
70607ac75b1Sopenharmony_ci    projectConfig.buildMode = DEBUG;
70707ac75b1Sopenharmony_ci    const file = TEST_TS;
70807ac75b1Sopenharmony_ci    const targetExt = EXTNAME_TS;
70907ac75b1Sopenharmony_ci    const originExt = '';
71007ac75b1Sopenharmony_ci    const currentExt = originExt.length === 0 ? path.extname(file) : originExt;
71107ac75b1Sopenharmony_ci    const fileWithoutExt = file.substring(0, file.lastIndexOf(currentExt));
71207ac75b1Sopenharmony_ci    const returnInfo = changeFileExtension(file, targetExt, originExt);
71307ac75b1Sopenharmony_ci    expect(returnInfo === fileWithoutExt + targetExt).to.be.true;
71407ac75b1Sopenharmony_ci  });
71507ac75b1Sopenharmony_ci
71607ac75b1Sopenharmony_ci  mocha.it('7-6: test changeFileExtension under hot fix release', function () {
71707ac75b1Sopenharmony_ci    projectConfig.buildMode = RELEASE;
71807ac75b1Sopenharmony_ci    const file = TEST_TS;
71907ac75b1Sopenharmony_ci    const targetExt = EXTNAME_TS;
72007ac75b1Sopenharmony_ci    const originExt = '';
72107ac75b1Sopenharmony_ci    const currentExt = originExt.length === 0 ? path.extname(file) : originExt;
72207ac75b1Sopenharmony_ci    const fileWithoutExt = file.substring(0, file.lastIndexOf(currentExt));
72307ac75b1Sopenharmony_ci    const returnInfo = changeFileExtension(file, targetExt, originExt);
72407ac75b1Sopenharmony_ci    expect(returnInfo === fileWithoutExt + targetExt).to.be.true;
72507ac75b1Sopenharmony_ci  });
72607ac75b1Sopenharmony_ci
72707ac75b1Sopenharmony_ci  mocha.it('8-1: test isCommonJsPluginVirtualFile under build debug', function () {
72807ac75b1Sopenharmony_ci    this.rollup.build();
72907ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
73007ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
73107ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
73207ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
73307ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
73407ac75b1Sopenharmony_ci        const returnInfo = isCommonJsPluginVirtualFile(filePath);
73507ac75b1Sopenharmony_ci        expect(returnInfo).to.be.false;
73607ac75b1Sopenharmony_ci      }
73707ac75b1Sopenharmony_ci    }
73807ac75b1Sopenharmony_ci  });
73907ac75b1Sopenharmony_ci
74007ac75b1Sopenharmony_ci  mocha.it('8-2: test isCommonJsPluginVirtualFile under build release', function () {
74107ac75b1Sopenharmony_ci    this.rollup.build(RELEASE);
74207ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
74307ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
74407ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
74507ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
74607ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
74707ac75b1Sopenharmony_ci        const returnInfo = isCommonJsPluginVirtualFile(filePath);
74807ac75b1Sopenharmony_ci        expect(returnInfo).to.be.false;
74907ac75b1Sopenharmony_ci      }
75007ac75b1Sopenharmony_ci    }
75107ac75b1Sopenharmony_ci  });
75207ac75b1Sopenharmony_ci
75307ac75b1Sopenharmony_ci  mocha.it('8-3: test isCommonJsPluginVirtualFile under preview debug', function () {
75407ac75b1Sopenharmony_ci    this.rollup.preview();
75507ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
75607ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
75707ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
75807ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
75907ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
76007ac75b1Sopenharmony_ci        const returnInfo = isCommonJsPluginVirtualFile(filePath);
76107ac75b1Sopenharmony_ci        expect(returnInfo).to.be.false;
76207ac75b1Sopenharmony_ci      }
76307ac75b1Sopenharmony_ci    }
76407ac75b1Sopenharmony_ci  });
76507ac75b1Sopenharmony_ci
76607ac75b1Sopenharmony_ci  mocha.it('8-4: test isCommonJsPluginVirtualFile under hot reload debug', function () {
76707ac75b1Sopenharmony_ci    this.rollup.hotReload();
76807ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
76907ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
77007ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
77107ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
77207ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
77307ac75b1Sopenharmony_ci        const returnInfo = isCommonJsPluginVirtualFile(filePath);
77407ac75b1Sopenharmony_ci        expect(returnInfo).to.be.false;
77507ac75b1Sopenharmony_ci      }
77607ac75b1Sopenharmony_ci    }
77707ac75b1Sopenharmony_ci  });
77807ac75b1Sopenharmony_ci
77907ac75b1Sopenharmony_ci  mocha.it('8-5: test isCommonJsPluginVirtualFile under hot fix debug', function () {
78007ac75b1Sopenharmony_ci    projectConfig.buildMode = DEBUG;
78107ac75b1Sopenharmony_ci    const filePath = TEST_TS;
78207ac75b1Sopenharmony_ci    const returnInfo = isCommonJsPluginVirtualFile(filePath);
78307ac75b1Sopenharmony_ci    expect(returnInfo).to.be.false;
78407ac75b1Sopenharmony_ci  });
78507ac75b1Sopenharmony_ci
78607ac75b1Sopenharmony_ci  mocha.it('8-6: test isCommonJsPluginVirtualFile under hot fix release', function () {
78707ac75b1Sopenharmony_ci    projectConfig.buildMode = RELEASE;
78807ac75b1Sopenharmony_ci    const filePath = TEST_TS;
78907ac75b1Sopenharmony_ci    const returnInfo = isCommonJsPluginVirtualFile(filePath);
79007ac75b1Sopenharmony_ci    expect(returnInfo).to.be.false;
79107ac75b1Sopenharmony_ci  });
79207ac75b1Sopenharmony_ci
79307ac75b1Sopenharmony_ci  mocha.it('9-1: test isCurrentProjectFiles under build debug', function () {
79407ac75b1Sopenharmony_ci    this.rollup.build();
79507ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
79607ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
79707ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
79807ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
79907ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
80007ac75b1Sopenharmony_ci        const returnInfo = isCurrentProjectFiles(filePath, this.rollup.share.projectConfig);
80107ac75b1Sopenharmony_ci        expect(returnInfo).to.be.true;
80207ac75b1Sopenharmony_ci      }
80307ac75b1Sopenharmony_ci    }
80407ac75b1Sopenharmony_ci  });
80507ac75b1Sopenharmony_ci
80607ac75b1Sopenharmony_ci  mocha.it('9-2: test isCurrentProjectFiles under build release', function () {
80707ac75b1Sopenharmony_ci    this.rollup.build(RELEASE);
80807ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
80907ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
81007ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
81107ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
81207ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
81307ac75b1Sopenharmony_ci        const returnInfo = isCurrentProjectFiles(filePath, this.rollup.share.projectConfig);
81407ac75b1Sopenharmony_ci        expect(returnInfo).to.be.true;
81507ac75b1Sopenharmony_ci      }
81607ac75b1Sopenharmony_ci    }
81707ac75b1Sopenharmony_ci  });
81807ac75b1Sopenharmony_ci
81907ac75b1Sopenharmony_ci  mocha.it('9-3: test isCurrentProjectFiles under preview debug', function () {
82007ac75b1Sopenharmony_ci    this.rollup.preview();
82107ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
82207ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
82307ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
82407ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
82507ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
82607ac75b1Sopenharmony_ci        const returnInfo = isCurrentProjectFiles(filePath, this.rollup.share.projectConfig);
82707ac75b1Sopenharmony_ci        expect(returnInfo).to.be.true;
82807ac75b1Sopenharmony_ci      }
82907ac75b1Sopenharmony_ci    }
83007ac75b1Sopenharmony_ci  });
83107ac75b1Sopenharmony_ci
83207ac75b1Sopenharmony_ci  mocha.it('9-4: test isCurrentProjectFiles under hot reload debug', function () {
83307ac75b1Sopenharmony_ci    this.rollup.hotReload();
83407ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
83507ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
83607ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
83707ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
83807ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
83907ac75b1Sopenharmony_ci        const returnInfo = isCurrentProjectFiles(filePath, this.rollup.share.projectConfig);
84007ac75b1Sopenharmony_ci        expect(returnInfo).to.be.true;
84107ac75b1Sopenharmony_ci      }
84207ac75b1Sopenharmony_ci    }
84307ac75b1Sopenharmony_ci  });
84407ac75b1Sopenharmony_ci
84507ac75b1Sopenharmony_ci  mocha.it('9-5: test isCurrentProjectFiles under hot fix debug', function () {
84607ac75b1Sopenharmony_ci    projectConfig.buildMode = DEBUG;
84707ac75b1Sopenharmony_ci    const filePath = TEST_TS;
84807ac75b1Sopenharmony_ci    const returnInfo = isCurrentProjectFiles(filePath, projectConfig);
84907ac75b1Sopenharmony_ci    expect(returnInfo).to.be.false;
85007ac75b1Sopenharmony_ci  });
85107ac75b1Sopenharmony_ci
85207ac75b1Sopenharmony_ci  mocha.it('9-6: test isCurrentProjectFiles under hot fix release', function () {
85307ac75b1Sopenharmony_ci    projectConfig.buildMode = RELEASE;
85407ac75b1Sopenharmony_ci    const filePath = TEST_TS;
85507ac75b1Sopenharmony_ci    const returnInfo = isCurrentProjectFiles(filePath, projectConfig);
85607ac75b1Sopenharmony_ci    expect(returnInfo).to.be.false;
85707ac75b1Sopenharmony_ci  });
85807ac75b1Sopenharmony_ci
85907ac75b1Sopenharmony_ci  mocha.it('10-1: test isSpecifiedExt under build debug', function () {
86007ac75b1Sopenharmony_ci    this.rollup.build();
86107ac75b1Sopenharmony_ci    const fileExtendName = EXTNAME_ETS;
86207ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
86307ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
86407ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
86507ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
86607ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
86707ac75b1Sopenharmony_ci        if (filePath.endsWith(EXTNAME_ETS)) {
86807ac75b1Sopenharmony_ci          expect(isSpecifiedExt(filePath, fileExtendName)).to.be.true;
86907ac75b1Sopenharmony_ci        } else {
87007ac75b1Sopenharmony_ci          expect(isSpecifiedExt(filePath, fileExtendName)).to.be.false;
87107ac75b1Sopenharmony_ci        }
87207ac75b1Sopenharmony_ci      }
87307ac75b1Sopenharmony_ci    }
87407ac75b1Sopenharmony_ci  });
87507ac75b1Sopenharmony_ci
87607ac75b1Sopenharmony_ci  mocha.it('10-2: test isSpecifiedExt under build release', function () {
87707ac75b1Sopenharmony_ci    this.rollup.build(RELEASE);
87807ac75b1Sopenharmony_ci    const fileExtendName = EXTNAME_JS;
87907ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
88007ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
88107ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
88207ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
88307ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
88407ac75b1Sopenharmony_ci        if (filePath.endsWith(EXTNAME_JS)) {
88507ac75b1Sopenharmony_ci          expect(isSpecifiedExt(filePath, fileExtendName)).to.be.true;
88607ac75b1Sopenharmony_ci        } else {
88707ac75b1Sopenharmony_ci          expect(isSpecifiedExt(filePath, fileExtendName)).to.be.false;
88807ac75b1Sopenharmony_ci        }
88907ac75b1Sopenharmony_ci      }
89007ac75b1Sopenharmony_ci    }
89107ac75b1Sopenharmony_ci  });
89207ac75b1Sopenharmony_ci
89307ac75b1Sopenharmony_ci  mocha.it('10-3: test isSpecifiedExt under preview debug', function () {
89407ac75b1Sopenharmony_ci    this.rollup.preview();
89507ac75b1Sopenharmony_ci    const fileExtendName = EXTNAME_TS;
89607ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
89707ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
89807ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
89907ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
90007ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
90107ac75b1Sopenharmony_ci        if (filePath.endsWith(EXTNAME_TS)) {
90207ac75b1Sopenharmony_ci          expect(isSpecifiedExt(filePath, fileExtendName)).to.be.true;
90307ac75b1Sopenharmony_ci        } else {
90407ac75b1Sopenharmony_ci          expect(isSpecifiedExt(filePath, fileExtendName)).to.be.false;
90507ac75b1Sopenharmony_ci        }
90607ac75b1Sopenharmony_ci      }
90707ac75b1Sopenharmony_ci    }
90807ac75b1Sopenharmony_ci  });
90907ac75b1Sopenharmony_ci
91007ac75b1Sopenharmony_ci  mocha.it('10-4: test isSpecifiedExt under hot reload debug', function () {
91107ac75b1Sopenharmony_ci    this.rollup.hotReload();
91207ac75b1Sopenharmony_ci    const fileExtendName = EXTNAME_JS;
91307ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
91407ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
91507ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
91607ac75b1Sopenharmony_ci    for (const filePath of this.mockfileList) {
91707ac75b1Sopenharmony_ci      if (filePath.endsWith(EXTNAME_TS) || filePath.endsWith(EXTNAME_ETS) || filePath.endsWith(EXTNAME_JS)) {
91807ac75b1Sopenharmony_ci        if (filePath.endsWith(EXTNAME_JS)) {
91907ac75b1Sopenharmony_ci          expect(isSpecifiedExt(filePath, fileExtendName)).to.be.true;
92007ac75b1Sopenharmony_ci        } else {
92107ac75b1Sopenharmony_ci          expect(isSpecifiedExt(filePath, fileExtendName)).to.be.false;
92207ac75b1Sopenharmony_ci        }
92307ac75b1Sopenharmony_ci      }
92407ac75b1Sopenharmony_ci    }
92507ac75b1Sopenharmony_ci  });
92607ac75b1Sopenharmony_ci
92707ac75b1Sopenharmony_ci  mocha.it('10-5: test isSpecifiedExt under hot fix debug', function () {
92807ac75b1Sopenharmony_ci    projectConfig.buildMode = DEBUG;
92907ac75b1Sopenharmony_ci    const fileExtendName = EXTNAME_JS;
93007ac75b1Sopenharmony_ci    const filePath = TEST_JS;
93107ac75b1Sopenharmony_ci    const returnInfo = isSpecifiedExt(filePath, fileExtendName);
93207ac75b1Sopenharmony_ci    expect(returnInfo).to.be.true;
93307ac75b1Sopenharmony_ci  });
93407ac75b1Sopenharmony_ci
93507ac75b1Sopenharmony_ci  mocha.it('10-6: test isSpecifiedExt under hot fix release', function () {
93607ac75b1Sopenharmony_ci    projectConfig.buildMode = RELEASE;
93707ac75b1Sopenharmony_ci    const fileExtendName = EXTNAME_JS;
93807ac75b1Sopenharmony_ci    const filePath = TEST_TS;
93907ac75b1Sopenharmony_ci    const returnInfo = isSpecifiedExt(filePath, fileExtendName);
94007ac75b1Sopenharmony_ci    expect(returnInfo).to.be.false;
94107ac75b1Sopenharmony_ci  });
94207ac75b1Sopenharmony_ci
94307ac75b1Sopenharmony_ci  mocha.it('11-1: test isTsOrEtsSourceFile under build debug', function () {
94407ac75b1Sopenharmony_ci    this.rollup.build();
94507ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
94607ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
94707ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
94807ac75b1Sopenharmony_ci    for (const file of this.mockfileList) {
94907ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_TS) || file.endsWith(EXTNAME_ETS)) {
95007ac75b1Sopenharmony_ci        const returnInfo = isTsOrEtsSourceFile(file);
95107ac75b1Sopenharmony_ci        expect(returnInfo).to.be.true;
95207ac75b1Sopenharmony_ci      }
95307ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_JS)) {
95407ac75b1Sopenharmony_ci        const returnInfoJs = isTsOrEtsSourceFile(file);
95507ac75b1Sopenharmony_ci        expect(returnInfoJs).to.be.false;
95607ac75b1Sopenharmony_ci      }
95707ac75b1Sopenharmony_ci    }
95807ac75b1Sopenharmony_ci  });
95907ac75b1Sopenharmony_ci
96007ac75b1Sopenharmony_ci  mocha.it('11-2: test isTsOrEtsSourceFile under build release', function () {
96107ac75b1Sopenharmony_ci    this.rollup.build(RELEASE);
96207ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
96307ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
96407ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
96507ac75b1Sopenharmony_ci    for (const file of this.mockfileList) {
96607ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_TS) || file.endsWith(EXTNAME_ETS)) {
96707ac75b1Sopenharmony_ci        const returnInfo = isTsOrEtsSourceFile(file);
96807ac75b1Sopenharmony_ci        expect(returnInfo).to.be.true;
96907ac75b1Sopenharmony_ci      }
97007ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_JS)) {
97107ac75b1Sopenharmony_ci        const returnInfoJs = isTsOrEtsSourceFile(file);
97207ac75b1Sopenharmony_ci        expect(returnInfoJs).to.be.false;
97307ac75b1Sopenharmony_ci      }
97407ac75b1Sopenharmony_ci    }
97507ac75b1Sopenharmony_ci  });
97607ac75b1Sopenharmony_ci
97707ac75b1Sopenharmony_ci  mocha.it('11-3: test isTsOrEtsSourceFile under preview debug', function () {
97807ac75b1Sopenharmony_ci    this.rollup.preview();
97907ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
98007ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
98107ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
98207ac75b1Sopenharmony_ci    for (const file of this.mockfileList) {
98307ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_TS) || file.endsWith(EXTNAME_ETS)) {
98407ac75b1Sopenharmony_ci        const returnInfo = isTsOrEtsSourceFile(file);
98507ac75b1Sopenharmony_ci        expect(returnInfo).to.be.true;
98607ac75b1Sopenharmony_ci      }
98707ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_JS)) {
98807ac75b1Sopenharmony_ci        const returnInfoJs = isTsOrEtsSourceFile(file);
98907ac75b1Sopenharmony_ci        expect(returnInfoJs).to.be.false;
99007ac75b1Sopenharmony_ci      }
99107ac75b1Sopenharmony_ci    }
99207ac75b1Sopenharmony_ci  });
99307ac75b1Sopenharmony_ci
99407ac75b1Sopenharmony_ci  mocha.it('11-4: test isTsOrEtsSourceFile under hot reload debug', function () {
99507ac75b1Sopenharmony_ci    this.rollup.hotReload();
99607ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
99707ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
99807ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
99907ac75b1Sopenharmony_ci    for (const file of this.mockfileList) {
100007ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_TS) || file.endsWith(EXTNAME_ETS)) {
100107ac75b1Sopenharmony_ci        const returnInfo = isTsOrEtsSourceFile(file);
100207ac75b1Sopenharmony_ci        expect(returnInfo).to.be.true;
100307ac75b1Sopenharmony_ci      }
100407ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_JS)) {
100507ac75b1Sopenharmony_ci        const returnInfoJs = isTsOrEtsSourceFile(file);
100607ac75b1Sopenharmony_ci        expect(returnInfoJs).to.be.false;
100707ac75b1Sopenharmony_ci      }
100807ac75b1Sopenharmony_ci    }
100907ac75b1Sopenharmony_ci  });
101007ac75b1Sopenharmony_ci
101107ac75b1Sopenharmony_ci  mocha.it('11-5: test isTsOrEtsSourceFile under hot fix debug', function () {
101207ac75b1Sopenharmony_ci    projectConfig.buildMode = DEBUG;
101307ac75b1Sopenharmony_ci    const file = TEST_TS;
101407ac75b1Sopenharmony_ci    const returnInfo = isTsOrEtsSourceFile(file);
101507ac75b1Sopenharmony_ci    expect(returnInfo).to.be.true;
101607ac75b1Sopenharmony_ci    const fileEts = TEST_ETS;
101707ac75b1Sopenharmony_ci    const returnInfoEts = isTsOrEtsSourceFile(fileEts);
101807ac75b1Sopenharmony_ci    expect(returnInfoEts).to.be.true;
101907ac75b1Sopenharmony_ci
102007ac75b1Sopenharmony_ci  });
102107ac75b1Sopenharmony_ci
102207ac75b1Sopenharmony_ci  mocha.it('11-6: test isTsOrEtsSourceFile under hot fix release', function () {
102307ac75b1Sopenharmony_ci    projectConfig.buildMode = RELEASE;
102407ac75b1Sopenharmony_ci    const file = TEST_TS;
102507ac75b1Sopenharmony_ci    const returnInfo = isTsOrEtsSourceFile(file);
102607ac75b1Sopenharmony_ci    expect(returnInfo).to.be.true;
102707ac75b1Sopenharmony_ci    const fileJs = TEST_JS;
102807ac75b1Sopenharmony_ci    const returnInfoJs = isTsOrEtsSourceFile(fileJs);
102907ac75b1Sopenharmony_ci    expect(returnInfoJs).to.be.false;
103007ac75b1Sopenharmony_ci  });
103107ac75b1Sopenharmony_ci
103207ac75b1Sopenharmony_ci  mocha.it('12-1: test isJsSourceFile under build debug', function () {
103307ac75b1Sopenharmony_ci    this.rollup.build();
103407ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
103507ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
103607ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
103707ac75b1Sopenharmony_ci    for (const file of this.mockfileList) {
103807ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_TS) || file.endsWith(EXTNAME_ETS)) {
103907ac75b1Sopenharmony_ci        const returnInfo = isJsSourceFile(file);
104007ac75b1Sopenharmony_ci        expect(returnInfo).to.be.false;
104107ac75b1Sopenharmony_ci      }
104207ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_JS)) {
104307ac75b1Sopenharmony_ci        const returnInfoJs = isJsSourceFile(file);
104407ac75b1Sopenharmony_ci        expect(returnInfoJs).to.be.true;
104507ac75b1Sopenharmony_ci      }
104607ac75b1Sopenharmony_ci    }
104707ac75b1Sopenharmony_ci  });
104807ac75b1Sopenharmony_ci
104907ac75b1Sopenharmony_ci  mocha.it('12-2: test isJsSourceFile under build release', function () {
105007ac75b1Sopenharmony_ci    this.rollup.build(RELEASE);
105107ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
105207ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
105307ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
105407ac75b1Sopenharmony_ci    for (const file of this.mockfileList) {
105507ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_TS) || file.endsWith(EXTNAME_ETS)) {
105607ac75b1Sopenharmony_ci        const returnInfo = isJsSourceFile(file);
105707ac75b1Sopenharmony_ci        expect(returnInfo).to.be.false;
105807ac75b1Sopenharmony_ci      }
105907ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_JS)) {
106007ac75b1Sopenharmony_ci        const returnInfoJs = isJsSourceFile(file);
106107ac75b1Sopenharmony_ci        expect(returnInfoJs).to.be.true;
106207ac75b1Sopenharmony_ci      }
106307ac75b1Sopenharmony_ci    }
106407ac75b1Sopenharmony_ci  });
106507ac75b1Sopenharmony_ci
106607ac75b1Sopenharmony_ci  mocha.it('12-3: test isJsSourceFile under preview debug', function () {
106707ac75b1Sopenharmony_ci    this.rollup.preview();
106807ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
106907ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
107007ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
107107ac75b1Sopenharmony_ci    for (const file of this.mockfileList) {
107207ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_TS) || file.endsWith(EXTNAME_ETS)) {
107307ac75b1Sopenharmony_ci        const returnInfo = isJsSourceFile(file);
107407ac75b1Sopenharmony_ci        expect(returnInfo).to.be.false;
107507ac75b1Sopenharmony_ci      }
107607ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_JS)) {
107707ac75b1Sopenharmony_ci        const returnInfoJs = isJsSourceFile(file);
107807ac75b1Sopenharmony_ci        expect(returnInfoJs).to.be.true;
107907ac75b1Sopenharmony_ci      }
108007ac75b1Sopenharmony_ci    }
108107ac75b1Sopenharmony_ci  });
108207ac75b1Sopenharmony_ci
108307ac75b1Sopenharmony_ci  mocha.it('12-4: test isJsSourceFile under hot reload debug', function () {
108407ac75b1Sopenharmony_ci    this.rollup.hotReload();
108507ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
108607ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
108707ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
108807ac75b1Sopenharmony_ci    for (const file of this.mockfileList) {
108907ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_TS) || file.endsWith(EXTNAME_ETS)) {
109007ac75b1Sopenharmony_ci        const returnInfo = isJsSourceFile(file);
109107ac75b1Sopenharmony_ci        expect(returnInfo).to.be.false;
109207ac75b1Sopenharmony_ci      }
109307ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_JS)) {
109407ac75b1Sopenharmony_ci        const returnInfoJs = isJsSourceFile(file);
109507ac75b1Sopenharmony_ci        expect(returnInfoJs).to.be.true;
109607ac75b1Sopenharmony_ci      }
109707ac75b1Sopenharmony_ci    }
109807ac75b1Sopenharmony_ci  });
109907ac75b1Sopenharmony_ci
110007ac75b1Sopenharmony_ci  mocha.it('12-5: test isJsSourceFile under hot fix debug', function () {
110107ac75b1Sopenharmony_ci    projectConfig.buildMode = DEBUG;
110207ac75b1Sopenharmony_ci    const file = TEST_JS;
110307ac75b1Sopenharmony_ci    const returnInfo = isJsSourceFile(file);
110407ac75b1Sopenharmony_ci    expect(returnInfo).to.be.true;
110507ac75b1Sopenharmony_ci    const fileTs = TEST_TS;
110607ac75b1Sopenharmony_ci    const returnInfoTs = isJsSourceFile(fileTs);
110707ac75b1Sopenharmony_ci    expect(returnInfoTs).to.be.false;
110807ac75b1Sopenharmony_ci  });
110907ac75b1Sopenharmony_ci
111007ac75b1Sopenharmony_ci  mocha.it('12-6: test isJsSourceFile under hot fix release', function () {
111107ac75b1Sopenharmony_ci    projectConfig.buildMode = RELEASE;
111207ac75b1Sopenharmony_ci    const file = TEST_JS;
111307ac75b1Sopenharmony_ci    const returnInfo = isJsSourceFile(file);
111407ac75b1Sopenharmony_ci    expect(returnInfo).to.be.true;
111507ac75b1Sopenharmony_ci    const fileTs = TEST_TS;
111607ac75b1Sopenharmony_ci    const returnInfoTs = isJsSourceFile(fileTs);
111707ac75b1Sopenharmony_ci    expect(returnInfoTs).to.be.false;
111807ac75b1Sopenharmony_ci  });
111907ac75b1Sopenharmony_ci
112007ac75b1Sopenharmony_ci  mocha.it('13-1: test isJsonSourceFile under build debug', function () {
112107ac75b1Sopenharmony_ci    this.rollup.build();
112207ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
112307ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
112407ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values(); for (const file of this.mockfileList) {
112507ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_TS) || file.endsWith(EXTNAME_ETS) || file.endsWith(EXTNAME_JS)) {
112607ac75b1Sopenharmony_ci        const returnInfo = isJsonSourceFile(file);
112707ac75b1Sopenharmony_ci        expect(returnInfo).to.be.false;
112807ac75b1Sopenharmony_ci      }
112907ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_JSON)) {
113007ac75b1Sopenharmony_ci        const returnInfoJson = isJsonSourceFile(file);
113107ac75b1Sopenharmony_ci        expect(returnInfoJson).to.be.true;
113207ac75b1Sopenharmony_ci      }
113307ac75b1Sopenharmony_ci    }
113407ac75b1Sopenharmony_ci  });
113507ac75b1Sopenharmony_ci
113607ac75b1Sopenharmony_ci  mocha.it('13-2: test isJsonSourceFile under build release', function () {
113707ac75b1Sopenharmony_ci    this.rollup.build(RELEASE);
113807ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
113907ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
114007ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
114107ac75b1Sopenharmony_ci    for (const file of this.mockfileList) {
114207ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_TS) || file.endsWith(EXTNAME_ETS) || file.endsWith(EXTNAME_JS)) {
114307ac75b1Sopenharmony_ci        const returnInfo = isJsonSourceFile(file);
114407ac75b1Sopenharmony_ci        expect(returnInfo).to.be.false;
114507ac75b1Sopenharmony_ci      }
114607ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_JSON)) {
114707ac75b1Sopenharmony_ci        const returnInfoJson = isJsonSourceFile(file);
114807ac75b1Sopenharmony_ci        expect(returnInfoJson).to.be.true;
114907ac75b1Sopenharmony_ci      }
115007ac75b1Sopenharmony_ci    }
115107ac75b1Sopenharmony_ci  });
115207ac75b1Sopenharmony_ci
115307ac75b1Sopenharmony_ci  mocha.it('13-3: test isJsonSourceFile under preview debug', function () {
115407ac75b1Sopenharmony_ci    this.rollup.preview();
115507ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
115607ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
115707ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
115807ac75b1Sopenharmony_ci    for (const file of this.mockfileList) {
115907ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_TS) || file.endsWith(EXTNAME_ETS) || file.endsWith(EXTNAME_JS)) {
116007ac75b1Sopenharmony_ci        const returnInfo = isJsonSourceFile(file);
116107ac75b1Sopenharmony_ci        expect(returnInfo).to.be.false;
116207ac75b1Sopenharmony_ci      }
116307ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_JSON)) {
116407ac75b1Sopenharmony_ci        const returnInfoJson = isJsonSourceFile(file);
116507ac75b1Sopenharmony_ci        expect(returnInfoJson).to.be.true;
116607ac75b1Sopenharmony_ci      }
116707ac75b1Sopenharmony_ci    }
116807ac75b1Sopenharmony_ci  });
116907ac75b1Sopenharmony_ci
117007ac75b1Sopenharmony_ci  mocha.it('13-4: test isJsonSourceFile under hot reload debug', function () {
117107ac75b1Sopenharmony_ci    this.rollup.hotReload();
117207ac75b1Sopenharmony_ci    const allFiles = new Set<string>();
117307ac75b1Sopenharmony_ci    scanFiles(this.rollup.share.projectConfig.modulePath, allFiles);
117407ac75b1Sopenharmony_ci    this.mockfileList = allFiles.values();
117507ac75b1Sopenharmony_ci    for (const file of this.mockfileList) {
117607ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_TS) || file.endsWith(EXTNAME_ETS) || file.endsWith(EXTNAME_JS)) {
117707ac75b1Sopenharmony_ci        const returnInfo = isJsonSourceFile(file);
117807ac75b1Sopenharmony_ci        expect(returnInfo).to.be.false;
117907ac75b1Sopenharmony_ci      }
118007ac75b1Sopenharmony_ci      if (file.endsWith(EXTNAME_JSON)) {
118107ac75b1Sopenharmony_ci        const returnInfoJson = isJsonSourceFile(file);
118207ac75b1Sopenharmony_ci        expect(returnInfoJson).to.be.true;
118307ac75b1Sopenharmony_ci      }
118407ac75b1Sopenharmony_ci    }
118507ac75b1Sopenharmony_ci  });
118607ac75b1Sopenharmony_ci
118707ac75b1Sopenharmony_ci  mocha.it('13-5: test isJsonSourceFile under hot fix debug', function () {
118807ac75b1Sopenharmony_ci    projectConfig.buildMode = DEBUG;
118907ac75b1Sopenharmony_ci    const file = TEST_TS;
119007ac75b1Sopenharmony_ci    const returnInfo = isJsonSourceFile(file);
119107ac75b1Sopenharmony_ci    expect(returnInfo).to.be.false;
119207ac75b1Sopenharmony_ci    const fileJson = TEST_JSON;
119307ac75b1Sopenharmony_ci    const returnInfoJson = isJsonSourceFile(fileJson);
119407ac75b1Sopenharmony_ci    expect(returnInfoJson).to.be.true;
119507ac75b1Sopenharmony_ci  });
119607ac75b1Sopenharmony_ci
119707ac75b1Sopenharmony_ci  mocha.it('13-6: test isJsonSourceFile under hot fix release', function () {
119807ac75b1Sopenharmony_ci    projectConfig.buildMode = RELEASE;
119907ac75b1Sopenharmony_ci    const file = TEST_TS;
120007ac75b1Sopenharmony_ci    const returnInfo = isJsonSourceFile(file);
120107ac75b1Sopenharmony_ci    expect(returnInfo).to.be.false;
120207ac75b1Sopenharmony_ci    const fileJson = TEST_JS;
120307ac75b1Sopenharmony_ci    const returnInfoJson = isJsonSourceFile(fileJson);
120407ac75b1Sopenharmony_ci    expect(returnInfoJson).to.be.false;
120507ac75b1Sopenharmony_ci  });
120607ac75b1Sopenharmony_ci
120707ac75b1Sopenharmony_ci  mocha.it('14-1: test moduleResolutionHost', function () {
120807ac75b1Sopenharmony_ci    const dirExists = moduleResolutionHostTest.directoryExists(path.resolve(__dirname));
120907ac75b1Sopenharmony_ci    const dirNotExists = moduleResolutionHostTest.directoryExists(path.resolve('./dirNotExists'));
121007ac75b1Sopenharmony_ci    expect(dirExists).to.be.true;
121107ac75b1Sopenharmony_ci    expect(dirNotExists).to.be.false;
121207ac75b1Sopenharmony_ci    const fileExists = moduleResolutionHostTest.fileExists(path.resolve(__filename));
121307ac75b1Sopenharmony_ci    const fileNotExists = moduleResolutionHostTest.fileExists(path.resolve('./fileNotExists'));
121407ac75b1Sopenharmony_ci    expect(fileExists).to.be.true;
121507ac75b1Sopenharmony_ci    expect(fileNotExists).to.be.false;
121607ac75b1Sopenharmony_ci    const dirExistsCache = moduleResolutionHostTest.directoryExists(path.resolve(__dirname));
121707ac75b1Sopenharmony_ci    const dirNotExistsCache = moduleResolutionHostTest.directoryExists(path.resolve('./dirNotExists'));
121807ac75b1Sopenharmony_ci    expect(dirExistsCache).to.be.true;
121907ac75b1Sopenharmony_ci    expect(dirNotExistsCache).to.be.false;
122007ac75b1Sopenharmony_ci    const fileExistsCache = moduleResolutionHostTest.fileExists(path.resolve(__filename));
122107ac75b1Sopenharmony_ci    const fileNotExistsCache = moduleResolutionHostTest.fileExists(path.resolve('./fileNotExists'));
122207ac75b1Sopenharmony_ci    expect(fileExistsCache).to.be.true;
122307ac75b1Sopenharmony_ci    expect(fileNotExistsCache).to.be.false;
122407ac75b1Sopenharmony_ci  });
122507ac75b1Sopenharmony_ci
122607ac75b1Sopenharmony_ci  mocha.it('15-1: test get/setRollupCache with hvigor provided cache interface', function () {
122707ac75b1Sopenharmony_ci    this.rollup.build();
122807ac75b1Sopenharmony_ci    let cacheKey: string = "cache1";
122907ac75b1Sopenharmony_ci    let cacheKeyNotExist: string = "cacheNotExist";
123007ac75b1Sopenharmony_ci    let cacheValue: object = {
123107ac75b1Sopenharmony_ci      value: "value1"
123207ac75b1Sopenharmony_ci    };
123307ac75b1Sopenharmony_ci    this.rollup.share.initWithCache();
123407ac75b1Sopenharmony_ci    setRollupCache(this.rollup.share, projectConfig, cacheKey, cacheValue);
123507ac75b1Sopenharmony_ci    expect(getRollupCache(this.rollup.share, projectConfig, cacheKey)).to.be.equal(cacheValue);
123607ac75b1Sopenharmony_ci    expect(getRollupCache(this.rollup.share, projectConfig, cacheKeyNotExist)).to.be.equal(undefined);
123707ac75b1Sopenharmony_ci  });
123807ac75b1Sopenharmony_ci
123907ac75b1Sopenharmony_ci  mocha.it('15-2: test get/setRollupCache with hvigor provided cacheStoreManager interface', function () {
124007ac75b1Sopenharmony_ci    this.rollup.build();
124107ac75b1Sopenharmony_ci    let cacheKey: string = "cache1";
124207ac75b1Sopenharmony_ci    let cacheKeyNotExist: string = "cacheNotExist";
124307ac75b1Sopenharmony_ci    let cacheValue: object = {
124407ac75b1Sopenharmony_ci      value: "value1"
124507ac75b1Sopenharmony_ci    };
124607ac75b1Sopenharmony_ci    this.rollup.share.initWithCacheStoreManager();
124707ac75b1Sopenharmony_ci    setRollupCache(this.rollup.share, projectConfig, cacheKey, cacheValue);
124807ac75b1Sopenharmony_ci    expect(getRollupCache(this.rollup.share, projectConfig, cacheKey)).to.be.equal(cacheValue);
124907ac75b1Sopenharmony_ci    expect(getRollupCache(this.rollup.share, projectConfig, cacheKeyNotExist)).to.be.equal(undefined);
125007ac75b1Sopenharmony_ci  });
125107ac75b1Sopenharmony_ci
125207ac75b1Sopenharmony_ci  mocha.it('15-3: test get/setRollupCache without hvigor cache interface provided', function () {
125307ac75b1Sopenharmony_ci    this.rollup.build();
125407ac75b1Sopenharmony_ci    let cacheKey: string = "cache1";
125507ac75b1Sopenharmony_ci    let cacheKeyNotExist: string = "cacheNotExist";
125607ac75b1Sopenharmony_ci    let cacheValue: object = {
125707ac75b1Sopenharmony_ci      value: "value1"
125807ac75b1Sopenharmony_ci    };
125907ac75b1Sopenharmony_ci    this.rollup.share.initWithoutCache();
126007ac75b1Sopenharmony_ci    setRollupCache(this.rollup.share, projectConfig, cacheKey, cacheValue);
126107ac75b1Sopenharmony_ci    expect(getRollupCache(this.rollup.share, projectConfig, cacheKey)).to.be.equal(undefined);
126207ac75b1Sopenharmony_ci    expect(getRollupCache(this.rollup.share, projectConfig, cacheKeyNotExist)).to.be.equal(undefined);
126307ac75b1Sopenharmony_ci  });
126407ac75b1Sopenharmony_ci
126507ac75b1Sopenharmony_ci  mocha.it('16-1: test genTemporaryPath adapt external modules', function () {
126607ac75b1Sopenharmony_ci    this.rollup.build();
126707ac75b1Sopenharmony_ci    const filePath: string = '/testHar/har/src/main/ets/utils/Calc.ets';
126807ac75b1Sopenharmony_ci    const moduleInfo = {
126907ac75b1Sopenharmony_ci      id: filePath,
127007ac75b1Sopenharmony_ci      meta: {
127107ac75b1Sopenharmony_ci        isLocalDependency: true,
127207ac75b1Sopenharmony_ci        moduleName: 'libhar',
127307ac75b1Sopenharmony_ci        belongModulePath: '/testHar/har',
127407ac75b1Sopenharmony_ci      }
127507ac75b1Sopenharmony_ci    };
127607ac75b1Sopenharmony_ci    this.rollup.moduleInfos.push(moduleInfo);
127707ac75b1Sopenharmony_ci    const projectConfig = this.rollup.share.projectConfig;
127807ac75b1Sopenharmony_ci    const metaInfo = this.rollup.getModuleInfo(filePath).meta;
127907ac75b1Sopenharmony_ci    const cacheFilePath = genTemporaryPath(filePath, projectConfig.projectPath, projectConfig.cachePath,
128007ac75b1Sopenharmony_ci      projectConfig, metaInfo);
128107ac75b1Sopenharmony_ci    const expectCacheFilePath = `${projectConfig.cachePath}/libhar/src/main/ets/utils/Calc.ets`;
128207ac75b1Sopenharmony_ci    expect(cacheFilePath === expectCacheFilePath).to.be.true;
128307ac75b1Sopenharmony_ci  });
128407ac75b1Sopenharmony_ci
128507ac75b1Sopenharmony_ci  mocha.it('16-2: test genTemporaryPath to concatenate the paths under the PackageHar directory', function () {
128607ac75b1Sopenharmony_ci    this.rollup.build();
128707ac75b1Sopenharmony_ci    const filePath: string = '/testHar/har/src/main/ets/utils/Calc.ets';
128807ac75b1Sopenharmony_ci    const moduleInfo = {
128907ac75b1Sopenharmony_ci      id: filePath,
129007ac75b1Sopenharmony_ci      meta: {
129107ac75b1Sopenharmony_ci        isLocalDependency: true,
129207ac75b1Sopenharmony_ci        moduleName: 'libhar',
129307ac75b1Sopenharmony_ci        belongModulePath: '/testHar/har',
129407ac75b1Sopenharmony_ci      }
129507ac75b1Sopenharmony_ci    };
129607ac75b1Sopenharmony_ci    this.rollup.moduleInfos.push(moduleInfo);
129707ac75b1Sopenharmony_ci    const projectConfig = this.rollup.share.projectConfig;
129807ac75b1Sopenharmony_ci    projectConfig.compileHar = true;
129907ac75b1Sopenharmony_ci    const metaInfo = this.rollup.getModuleInfo(filePath).meta;
130007ac75b1Sopenharmony_ci    const buildFilePath = genTemporaryPath(filePath, projectConfig.projectPath, projectConfig.buildPath,
130107ac75b1Sopenharmony_ci      projectConfig, metaInfo, true);
130207ac75b1Sopenharmony_ci    const expectBuildFilePath = `${projectConfig.buildPath}/src/main/ets/utils/Calc.ets`;
130307ac75b1Sopenharmony_ci    expect(buildFilePath === expectBuildFilePath).to.be.true;
130407ac75b1Sopenharmony_ci  });
130507ac75b1Sopenharmony_ci
130607ac75b1Sopenharmony_ci  mocha.it('17-1: test getProjectRootPath adapt external modules', function () {
130707ac75b1Sopenharmony_ci    this.rollup.build();
130807ac75b1Sopenharmony_ci    const filePath: string = '/testHar/har/src/main/ets/utils/Calc.ets';
130907ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.rootPathSet = ['/testHar', `${PROJECT_ROOT}/${DEFAULT_PROJECT}`];
131007ac75b1Sopenharmony_ci    const projectConfig = this.rollup.share.projectConfig;
131107ac75b1Sopenharmony_ci    const existsSyncStub = sinon.stub(fs, 'existsSync').returns(true);
131207ac75b1Sopenharmony_ci    const statSyncStub = sinon.stub(fs, 'statSync').returns({
131307ac75b1Sopenharmony_ci      isFile: sinon.stub().returns(true)
131407ac75b1Sopenharmony_ci    });
131507ac75b1Sopenharmony_ci    const projectRootPath: string = getProjectRootPath(filePath, projectConfig, projectConfig.rootPathSet);
131607ac75b1Sopenharmony_ci    const expectProjectConfig: string = '/testHar';
131707ac75b1Sopenharmony_ci    expect(projectRootPath === expectProjectConfig).to.be.true;
131807ac75b1Sopenharmony_ci    existsSyncStub.restore();
131907ac75b1Sopenharmony_ci    statSyncStub.restore();
132007ac75b1Sopenharmony_ci  });
132107ac75b1Sopenharmony_ci
132207ac75b1Sopenharmony_ci  mocha.it('17-2: test getProjectRootPath adapt external modules(multiple project names contain a relationship)',
132307ac75b1Sopenharmony_ci    function () {
132407ac75b1Sopenharmony_ci    this.rollup.build();
132507ac75b1Sopenharmony_ci    const filePath: string = '/project/testA/har/src/main/ets/utils/Calc.ets';
132607ac75b1Sopenharmony_ci    this.rollup.share.projectConfig.rootPathSet = ['/project/test', '/project/testA', '/project/testAB'];
132707ac75b1Sopenharmony_ci    const projectConfig = this.rollup.share.projectConfig;
132807ac75b1Sopenharmony_ci    const existsSyncStub = sinon.stub(fs, 'existsSync').returns(true);
132907ac75b1Sopenharmony_ci    const statSyncStub = sinon.stub(fs, 'statSync').returns({
133007ac75b1Sopenharmony_ci      isFile: sinon.stub().returns(true)
133107ac75b1Sopenharmony_ci    });
133207ac75b1Sopenharmony_ci    const projectRootPath: string = getProjectRootPath(filePath, projectConfig, projectConfig.rootPathSet);
133307ac75b1Sopenharmony_ci    const expectProjectConfig: string = '/project/testA';
133407ac75b1Sopenharmony_ci    expect(projectRootPath === expectProjectConfig).to.be.true;
133507ac75b1Sopenharmony_ci    existsSyncStub.restore();
133607ac75b1Sopenharmony_ci    statSyncStub.restore();
133707ac75b1Sopenharmony_ci  });
133807ac75b1Sopenharmony_ci
133907ac75b1Sopenharmony_ci  mocha.it('17-3: test getProjectRootPath under build', function () {
134007ac75b1Sopenharmony_ci    this.rollup.build();
134107ac75b1Sopenharmony_ci    const filePath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}/har/src/main/ets/utils/Calc.ets`;
134207ac75b1Sopenharmony_ci    const projectConfig = this.rollup.share.projectConfig;
134307ac75b1Sopenharmony_ci    const projectRootPath: string = getProjectRootPath(filePath, projectConfig, projectConfig.rootPathSet);
134407ac75b1Sopenharmony_ci    expect(projectRootPath === projectConfig.projectRootPath).to.be.true;
134507ac75b1Sopenharmony_ci  });
134607ac75b1Sopenharmony_ci
134707ac75b1Sopenharmony_ci  mocha.it('18-1: test getBelongModuleInfo under build file is local dependency', function () {
134807ac75b1Sopenharmony_ci    this.rollup.build();
134907ac75b1Sopenharmony_ci    const filePath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}/har/src/main/ets/utils/Calc.ets`;
135007ac75b1Sopenharmony_ci    const projectRootPath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}`;
135107ac75b1Sopenharmony_ci    const modulePathMap: Object = {
135207ac75b1Sopenharmony_ci        'enrty': `${PROJECT_ROOT}/${DEFAULT_PROJECT}/entry`,
135307ac75b1Sopenharmony_ci        'libhar': `${PROJECT_ROOT}/${DEFAULT_PROJECT}/har`
135407ac75b1Sopenharmony_ci    };
135507ac75b1Sopenharmony_ci    const expectBelongModuleInfo: Object = {
135607ac75b1Sopenharmony_ci      isLocalDependency: true,
135707ac75b1Sopenharmony_ci      moduleName: 'libhar',
135807ac75b1Sopenharmony_ci      belongModulePath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}/har`
135907ac75b1Sopenharmony_ci    };
136007ac75b1Sopenharmony_ci    const belongModuleInfo: Object = getBelongModuleInfo(filePath, modulePathMap, projectRootPath);
136107ac75b1Sopenharmony_ci    Object.keys(belongModuleInfo).forEach(item => {
136207ac75b1Sopenharmony_ci      expect(belongModuleInfo[item] === expectBelongModuleInfo[item]).to.be.true;
136307ac75b1Sopenharmony_ci    });
136407ac75b1Sopenharmony_ci  });
136507ac75b1Sopenharmony_ci
136607ac75b1Sopenharmony_ci  mocha.it('18-2: test getBelongModuleInfo under build file is not local dependency', function () {
136707ac75b1Sopenharmony_ci    this.rollup.build();
136807ac75b1Sopenharmony_ci    const filePath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}/oh_modules/.ohpm/json5/index.js`;
136907ac75b1Sopenharmony_ci    const projectRootPath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}`;
137007ac75b1Sopenharmony_ci    const modulePathMap: Object = {
137107ac75b1Sopenharmony_ci        'enrty': `${PROJECT_ROOT}/${DEFAULT_PROJECT}/entry`,
137207ac75b1Sopenharmony_ci        'libhar': `${PROJECT_ROOT}/${DEFAULT_PROJECT}/har`
137307ac75b1Sopenharmony_ci    };
137407ac75b1Sopenharmony_ci    const expectBelongModuleInfo: Object = {
137507ac75b1Sopenharmony_ci      isLocalDependency: false,
137607ac75b1Sopenharmony_ci      moduleName: '',
137707ac75b1Sopenharmony_ci      belongModulePath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}`
137807ac75b1Sopenharmony_ci    };
137907ac75b1Sopenharmony_ci    const belongModuleInfo: Object = getBelongModuleInfo(filePath, modulePathMap, projectRootPath);
138007ac75b1Sopenharmony_ci    Object.keys(belongModuleInfo).forEach(item => {
138107ac75b1Sopenharmony_ci      expect(belongModuleInfo[item] === expectBelongModuleInfo[item]).to.be.true;
138207ac75b1Sopenharmony_ci    });
138307ac75b1Sopenharmony_ci  });
138407ac75b1Sopenharmony_ci});