1/* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use rollupObject file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { expect } from 'chai'; 17import fs from 'fs'; 18import mocha from 'mocha'; 19import path from 'path'; 20 21import { 22 RELEASE 23} from '../../../lib/fast_build/ark_compiler/common/ark_define'; 24import RollUpPluginMock from '../mock/rollup_mock/rollup_plugin_mock'; 25import { SourceMapGenerator } from '../../../lib/fast_build/ark_compiler/generate_sourcemap'; 26import { 27 ENTRYABILITY_JS_PATH_DEFAULT, 28 ENTRYABILITY_TS_PATH_DEFAULT, 29 ENTRY_PACKAGE_NAME_DEFAULT, 30 ENTRY_MODULE_VERSION_DEFAULT, 31 INDEX_ETS_PATH_DEFAULT, 32 INDEX_JS_CACHE_PATH 33} from '../mock/rollup_mock/common'; 34import { 35 compilingEtsOrTsFiles, 36 hasTsNoCheckOrTsIgnoreFiles, 37 cleanUpFilesList 38} from '../../../lib/fast_build/ark_compiler/utils'; 39 40const prefix = `${ENTRY_PACKAGE_NAME_DEFAULT}|${ENTRY_PACKAGE_NAME_DEFAULT}|${ENTRY_MODULE_VERSION_DEFAULT}|`; 41let entryPkgInfo = `${ENTRY_PACKAGE_NAME_DEFAULT}|${ENTRY_MODULE_VERSION_DEFAULT}`; 42 43mocha.describe('test generate_sourcemap api', function () { 44 mocha.before(function () { 45 this.rollup = new RollUpPluginMock(); 46 }); 47 48 mocha.after(() => { 49 delete this.rollup; 50 }); 51 52 mocha.it('1-1: test getPkgInfoByModuleId under build debug', function () { 53 this.rollup.build(); 54 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 55 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 56 let pkgInfo = sourceMapGenerator.getPkgInfoByModuleId(moduleId); 57 58 expect(pkgInfo && pkgInfo.entry && pkgInfo.modulePath && pkgInfo.entry.name && pkgInfo.entry.version !== '' && pkgInfo.entry.version != undefined).to.be.true; 59 SourceMapGenerator.cleanSourceMapObject(); 60 }); 61 62 mocha.it('1-2: test getPkgInfoByModuleId under build release', function () { 63 this.rollup.build(RELEASE); 64 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 65 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 66 let pkgInfo = sourceMapGenerator.getPkgInfoByModuleId(moduleId); 67 68 expect(pkgInfo && pkgInfo.entry && pkgInfo.modulePath && pkgInfo.entry.name && pkgInfo.entry.version !== '' && pkgInfo.entry.version != undefined).to.be.true; 69 SourceMapGenerator.cleanSourceMapObject(); 70 }); 71 72 mocha.it('1-3: test getPkgInfoByModuleId under preview', function () { 73 this.rollup.preview(); 74 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 75 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 76 let pkgInfo = sourceMapGenerator.getPkgInfoByModuleId(moduleId); 77 78 expect(pkgInfo && pkgInfo.entry && pkgInfo.modulePath && pkgInfo.entry.name && pkgInfo.entry.version !== '' && pkgInfo.entry.version != undefined).to.be.true; 79 SourceMapGenerator.cleanSourceMapObject(); 80 }); 81 82 mocha.it('1-4: test getPkgInfoByModuleId under hotReload', function () { 83 this.rollup.hotReload(); 84 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 85 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 86 let pkgInfo = sourceMapGenerator.getPkgInfoByModuleId(moduleId); 87 88 expect(pkgInfo && pkgInfo.entry && pkgInfo.modulePath && pkgInfo.entry.name && pkgInfo.entry.version !== '' && pkgInfo.entry.version != undefined).to.be.true; 89 SourceMapGenerator.cleanSourceMapObject(); 90 }); 91 92 mocha.it('1-5: test getPkgInfoByModuleId with file name obfuscate', function () { 93 this.rollup.build(); 94 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 95 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 96 let pkgInfo = sourceMapGenerator.getPkgInfoByModuleId(moduleId, true); 97 expect(pkgInfo && pkgInfo.entry && pkgInfo.modulePath && pkgInfo.entry.name && pkgInfo.entry.version !== '' && pkgInfo.entry.version != undefined).to.be.true; 98 expect(pkgInfo.modulePath == 'src/main/a/b.js').to.be.true; 99 SourceMapGenerator.cleanSourceMapObject(); 100 }); 101 102 mocha.it('2-1: test genKey under build debug', function () { 103 this.rollup.build(); 104 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 105 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 106 let genKey = sourceMapGenerator.genKey(moduleId); 107 let expectKey = prefix + ENTRYABILITY_JS_PATH_DEFAULT.substring(1); 108 109 expect(genKey === expectKey).to.be.true; 110 SourceMapGenerator.cleanSourceMapObject(); 111 }); 112 113 mocha.it('2-2: test genKey under build release', function () { 114 this.rollup.build(RELEASE); 115 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 116 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 117 let genKey = sourceMapGenerator.genKey(moduleId); 118 let expectKey = prefix + ENTRYABILITY_JS_PATH_DEFAULT.substring(1); 119 120 expect(genKey === expectKey).to.be.true; 121 SourceMapGenerator.cleanSourceMapObject(); 122 }); 123 124 mocha.it('2-3: test genKey under preview', function () { 125 this.rollup.preview(); 126 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 127 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 128 let genKey = sourceMapGenerator.genKey(moduleId); 129 let expectKey = prefix + ENTRYABILITY_JS_PATH_DEFAULT.substring(1); 130 131 expect(genKey === expectKey).to.be.true; 132 SourceMapGenerator.cleanSourceMapObject(); 133 }); 134 135 mocha.it('2-4: test genKey under hotReload', function () { 136 this.rollup.hotReload(); 137 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 138 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 139 let genKey = sourceMapGenerator.genKey(moduleId); 140 let expectKey = prefix + ENTRYABILITY_JS_PATH_DEFAULT.substring(1); 141 142 expect(genKey === expectKey).to.be.true; 143 SourceMapGenerator.cleanSourceMapObject(); 144 }); 145 146 mocha.it('2-5: test genKey with file name obfuscate', function () { 147 this.rollup.build(); 148 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 149 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 150 let genKey = sourceMapGenerator.genKey(moduleId, true); 151 let expectKey = 'entry|entry|1.0.0|src/main/a/b.js'; 152 expect(genKey === expectKey).to.be.true; 153 SourceMapGenerator.cleanSourceMapObject(); 154 }); 155 156 mocha.it('3-1: test updateSourceMap under build debug', function () { 157 this.rollup.build(); 158 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 159 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 160 let sourceMapData = { version: '1.0.0' }; 161 sourceMapGenerator.updateSourceMap(moduleId, sourceMapData); 162 let sourceMapDataGet = sourceMapGenerator.getSourceMap(moduleId); 163 expect(sourceMapData === sourceMapDataGet).to.be.true; 164 SourceMapGenerator.cleanSourceMapObject(); 165 }); 166 167 mocha.it('3-2: test updateSourceMap under build release', function () { 168 this.rollup.build(RELEASE); 169 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 170 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 171 let sourceMapData = { version: '1.0.0' }; 172 sourceMapGenerator.updateSourceMap(moduleId, sourceMapData); 173 let sourceMapDataGet = sourceMapGenerator.getSourceMap(moduleId); 174 expect(sourceMapData === sourceMapDataGet).to.be.true; 175 SourceMapGenerator.cleanSourceMapObject(); 176 }); 177 178 mocha.it('3-3: test updateSourceMap under preview', function () { 179 this.rollup.preview(); 180 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 181 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 182 let sourceMapData = { version: '1.0.0' }; 183 sourceMapGenerator.updateSourceMap(moduleId, sourceMapData); 184 let sourceMapDataGet = sourceMapGenerator.getSourceMap(moduleId); 185 expect(sourceMapData === sourceMapDataGet).to.be.true; 186 SourceMapGenerator.cleanSourceMapObject(); 187 }); 188 189 mocha.it('3-4: test updateSourceMap under hotReload', function () { 190 this.rollup.hotReload(); 191 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 192 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 193 let sourceMapData = { version: '1.0.0' }; 194 sourceMapGenerator.updateSourceMap(moduleId, sourceMapData); 195 let sourceMapDataGet = sourceMapGenerator.getSourceMap(moduleId); 196 expect(sourceMapData === sourceMapDataGet).to.be.true; 197 SourceMapGenerator.cleanSourceMapObject(); 198 }); 199 200 mocha.it('4-1: test fillSourceMapPackageInfo under build debug', function () { 201 this.rollup.build(); 202 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 203 204 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 205 let sourceMapData = {}; 206 sourceMapGenerator.fillSourceMapPackageInfo(moduleId, sourceMapData); 207 expect(sourceMapData['entry-package-info'] && sourceMapData['entry-package-info'] === entryPkgInfo).to.be.true; 208 SourceMapGenerator.cleanSourceMapObject(); 209 }); 210 211 mocha.it('4-2: test fillSourceMapPackageInfo under build release', function () { 212 this.rollup.build(RELEASE); 213 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 214 215 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 216 let sourceMapData = {}; 217 sourceMapGenerator.fillSourceMapPackageInfo(moduleId, sourceMapData); 218 expect(sourceMapData['entry-package-info'] && sourceMapData['entry-package-info'] === entryPkgInfo).to.be.true; 219 SourceMapGenerator.cleanSourceMapObject(); 220 }); 221 222 mocha.it('4-3: test fillSourceMapPackageInfo under preview', function () { 223 this.rollup.preview(); 224 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 225 226 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 227 let sourceMapData = {}; 228 sourceMapGenerator.fillSourceMapPackageInfo(moduleId, sourceMapData); 229 expect(sourceMapData['entry-package-info'] && sourceMapData['entry-package-info'] === entryPkgInfo).to.be.true; 230 SourceMapGenerator.cleanSourceMapObject(); 231 }); 232 233 mocha.it('4-4: test fillSourceMapPackageInfo under hotReload', function () { 234 this.rollup.hotReload(); 235 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 236 237 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 238 let sourceMapData = {}; 239 sourceMapGenerator.fillSourceMapPackageInfo(moduleId, sourceMapData); 240 expect(sourceMapData['entry-package-info'] && sourceMapData['entry-package-info'] === entryPkgInfo).to.be.true; 241 SourceMapGenerator.cleanSourceMapObject(); 242 }); 243 244 mocha.it('5-1: test genKey under build debug: arkProjectConfig.processTs is true', function () { 245 this.rollup.build(); 246 this.rollup.share.arkProjectConfig.processTs = true; 247 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 248 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 249 compilingEtsOrTsFiles.push(moduleId); 250 hasTsNoCheckOrTsIgnoreFiles.push(moduleId); 251 let genKey = sourceMapGenerator.genKey(moduleId); 252 cleanUpFilesList(); 253 let expectKey = prefix + ENTRYABILITY_JS_PATH_DEFAULT.substring(1); 254 expect(genKey === expectKey).to.be.true; 255 SourceMapGenerator.cleanSourceMapObject(); 256 }); 257 258 mocha.it('5-2: test genKey under build release: arkProjectConfig.processTs is true', function () { 259 this.rollup.build(RELEASE); 260 this.rollup.share.arkProjectConfig.processTs = true; 261 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 262 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 263 compilingEtsOrTsFiles.push(moduleId); 264 hasTsNoCheckOrTsIgnoreFiles.push(moduleId); 265 let genKey = sourceMapGenerator.genKey(moduleId); 266 cleanUpFilesList(); 267 let expectKey = prefix + ENTRYABILITY_JS_PATH_DEFAULT.substring(1); 268 expect(genKey === expectKey).to.be.true; 269 SourceMapGenerator.cleanSourceMapObject(); 270 }); 271 272 mocha.it('5-3: test genKey under preview: arkProjectConfig.processTs is true', function () { 273 this.rollup.preview(); 274 this.rollup.share.arkProjectConfig.processTs = true; 275 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 276 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 277 compilingEtsOrTsFiles.push(moduleId); 278 hasTsNoCheckOrTsIgnoreFiles.push(moduleId); 279 let genKey = sourceMapGenerator.genKey(moduleId); 280 cleanUpFilesList(); 281 let expectKey = prefix + ENTRYABILITY_JS_PATH_DEFAULT.substring(1); 282 expect(genKey === expectKey).to.be.true; 283 SourceMapGenerator.cleanSourceMapObject(); 284 }); 285 286 mocha.it('5-4: test genKey under hotReload: arkProjectConfig.processTs is true', function () { 287 this.rollup.hotReload(); 288 this.rollup.share.arkProjectConfig.processTs = true; 289 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 290 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, ENTRYABILITY_TS_PATH_DEFAULT); 291 compilingEtsOrTsFiles.push(moduleId); 292 hasTsNoCheckOrTsIgnoreFiles.push(moduleId); 293 let genKey = sourceMapGenerator.genKey(moduleId); 294 cleanUpFilesList(); 295 let expectKey = prefix + ENTRYABILITY_JS_PATH_DEFAULT.substring(1); 296 expect(genKey === expectKey).to.be.true; 297 SourceMapGenerator.cleanSourceMapObject(); 298 }); 299 300 mocha.it('6-1: test updateCachedSourceMaps under build debug: arkProjectConfig.processTs is true', function () { 301 this.rollup.build(); 302 this.rollup.share.arkProjectConfig.processTs = true; 303 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, INDEX_ETS_PATH_DEFAULT); 304 compilingEtsOrTsFiles.push(moduleId); 305 hasTsNoCheckOrTsIgnoreFiles.push(moduleId); 306 const indexCachePath = this.rollup.share.projectConfig.projectRootPath + '/' + INDEX_JS_CACHE_PATH; 307 if (fs.existsSync(indexCachePath)) { 308 fs.rmSync(indexCachePath); 309 } 310 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 311 sourceMapGenerator.isNewSourceMap = false; 312 const rootPath = this.rollup.share.projectConfig.projectRootPath + '/cache/'; 313 const sourceMapEdit = JSON.parse(fs.readFileSync(rootPath + 'source_map_edit.json').toString()); 314 const sourceMapExpect = JSON.parse(fs.readFileSync(rootPath + 'source_map_expect.json').toString()); 315 sourceMapGenerator.cacheSourceMapPath = rootPath + 'source_map_cache.json'; 316 sourceMapGenerator.sourceMaps = sourceMapEdit; 317 const sourceMapResult = sourceMapGenerator.updateCachedSourceMaps(); 318 expect(Object.keys(sourceMapResult).length == Object.keys(sourceMapExpect).length).to.be.true; 319 Object.keys(sourceMapResult).forEach(key => { 320 expect(sourceMapExpect).to.include.keys(key); 321 }); 322 SourceMapGenerator.cleanSourceMapObject(); 323 }); 324 325 mocha.it('6-2: test updateCachedSourceMaps under build release: arkProjectConfig.processTs is true', function () { 326 this.rollup.build(RELEASE); 327 this.rollup.share.arkProjectConfig.processTs = true; 328 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, INDEX_ETS_PATH_DEFAULT); 329 compilingEtsOrTsFiles.push(moduleId); 330 hasTsNoCheckOrTsIgnoreFiles.push(moduleId); 331 const indexCachePath = this.rollup.share.projectConfig.projectRootPath + '/' + INDEX_JS_CACHE_PATH; 332 if (fs.existsSync(indexCachePath)) { 333 fs.rmSync(indexCachePath); 334 } 335 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 336 sourceMapGenerator.isNewSourceMap = false; 337 const rootPath = this.rollup.share.projectConfig.projectRootPath + '/cache/'; 338 const sourceMapEdit = JSON.parse(fs.readFileSync(rootPath + 'source_map_edit.json').toString()); 339 const sourceMapExpect = JSON.parse(fs.readFileSync(rootPath + 'source_map_expect.json').toString()); 340 sourceMapGenerator.cacheSourceMapPath = rootPath + 'source_map_cache.json'; 341 sourceMapGenerator.sourceMaps = sourceMapEdit; 342 const sourceMapResult = sourceMapGenerator.updateCachedSourceMaps(); 343 expect(Object.keys(sourceMapResult).length == Object.keys(sourceMapExpect).length).to.be.true; 344 Object.keys(sourceMapResult).forEach(key => { 345 expect(sourceMapExpect).to.include.keys(key); 346 }); 347 SourceMapGenerator.cleanSourceMapObject(); 348 }); 349 350 mocha.it('6-3: test updateCachedSourceMaps under preview: arkProjectConfig.processTs is true', function () { 351 this.rollup.preview(); 352 this.rollup.share.arkProjectConfig.processTs = true; 353 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, INDEX_ETS_PATH_DEFAULT); 354 compilingEtsOrTsFiles.push(moduleId); 355 hasTsNoCheckOrTsIgnoreFiles.push(moduleId); 356 const indexCachePath = this.rollup.share.projectConfig.projectRootPath + '/' + INDEX_JS_CACHE_PATH; 357 if (fs.existsSync(indexCachePath)) { 358 fs.rmSync(indexCachePath); 359 } 360 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 361 sourceMapGenerator.isNewSourceMap = false; 362 const rootPath = this.rollup.share.projectConfig.projectRootPath + '/cache/'; 363 const sourceMapEdit = JSON.parse(fs.readFileSync(rootPath + 'source_map_edit.json').toString()); 364 const sourceMapExpect = JSON.parse(fs.readFileSync(rootPath + 'source_map_expect_preview.json').toString()); 365 sourceMapGenerator.cacheSourceMapPath = rootPath + 'source_map_cache_preview.json'; 366 sourceMapGenerator.sourceMaps = sourceMapEdit; 367 const sourceMapResult = sourceMapGenerator.updateCachedSourceMaps(); 368 expect(Object.keys(sourceMapResult).length == Object.keys(sourceMapExpect).length).to.be.true; 369 Object.keys(sourceMapResult).forEach(key => { 370 expect(sourceMapExpect).to.include.keys(key); 371 }); 372 SourceMapGenerator.cleanSourceMapObject(); 373 }); 374 375 mocha.it('6-4: test updateCachedSourceMaps under hotReload: arkProjectConfig.processTs is true', function () { 376 this.rollup.hotReload(); 377 this.rollup.share.arkProjectConfig.processTs = true; 378 let moduleId = path.join(this.rollup.share.projectConfig.modulePath, INDEX_ETS_PATH_DEFAULT); 379 compilingEtsOrTsFiles.push(moduleId); 380 hasTsNoCheckOrTsIgnoreFiles.push(moduleId); 381 const indexCachePath = this.rollup.share.projectConfig.projectRootPath + '/' + INDEX_JS_CACHE_PATH; 382 if (fs.existsSync(indexCachePath)) { 383 fs.rmSync(indexCachePath); 384 } 385 const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.initInstance(this.rollup); 386 sourceMapGenerator.isNewSourceMap = false; 387 const rootPath = this.rollup.share.projectConfig.projectRootPath + '/cache/'; 388 const sourceMapEdit = JSON.parse(fs.readFileSync(rootPath + 'source_map_edit.json').toString()); 389 const sourceMapExpect = JSON.parse(fs.readFileSync(rootPath + 'source_map_expect.json').toString()); 390 sourceMapGenerator.cacheSourceMapPath = rootPath + 'source_map_cache.json'; 391 sourceMapGenerator.sourceMaps = sourceMapEdit; 392 const sourceMapResult = sourceMapGenerator.updateCachedSourceMaps(); 393 expect(Object.keys(sourceMapResult).length == Object.keys(sourceMapExpect).length).to.be.true; 394 Object.keys(sourceMapResult).forEach(key => { 395 expect(sourceMapExpect).to.include.keys(key); 396 }); 397 SourceMapGenerator.cleanSourceMapObject(); 398 }); 399 400});