@@ -36,6 +36,7 @@ import { |
36 | 36 | mockCodeQLVersion, |
37 | 37 | createTestConfig, |
38 | 38 | makeMacro, |
| 39 | + initAllState, |
39 | 40 | } from "./testing-utils"; |
40 | 41 | import { |
41 | 42 | GitHubVariant, |
@@ -160,8 +161,9 @@ test.serial("load empty config", async (t) => { |
160 | 161 | }, |
161 | 162 | }); |
162 | 163 |
|
| 164 | + const state = initAllState({ logger }); |
163 | 165 | const config = await configUtils.initConfig( |
164 | | - createFeatures([]), |
| 166 | + state, |
165 | 167 | createTestInitConfigInputs({ |
166 | 168 | languagesInput: languages, |
167 | 169 | repository: { owner: "github", repo: "example" }, |
@@ -202,8 +204,9 @@ test.serial("load code quality config", async (t) => { |
202 | 204 | }, |
203 | 205 | }); |
204 | 206 |
|
| 207 | + const state = initAllState({ logger }); |
205 | 208 | const config = await configUtils.initConfig( |
206 | | - createFeatures([]), |
| 209 | + state, |
207 | 210 | createTestInitConfigInputs({ |
208 | 211 | analysisKinds: [AnalysisKind.CodeQuality], |
209 | 212 | languagesInput: languages, |
@@ -280,9 +283,10 @@ test.serial( |
280 | 283 | repositoryProperties, |
281 | 284 | }); |
282 | 285 |
|
| 286 | + const state = initAllState({ logger }); |
283 | 287 | await t.notThrowsAsync(async () => { |
284 | 288 | const config = await configUtils.initConfig( |
285 | | - createFeatures([]), |
| 289 | + state, |
286 | 290 | createTestInitConfigInputs({ |
287 | 291 | analysisKinds: [AnalysisKind.CodeQuality], |
288 | 292 | languagesInput: languages, |
@@ -321,8 +325,9 @@ test.serial("loading a saved config produces the same config", async (t) => { |
321 | 325 | // Sanity check that getConfig returns undefined before we have called initConfig |
322 | 326 | t.deepEqual(await configUtils.getConfig(tempDir, logger), undefined); |
323 | 327 |
|
| 328 | + const state = initAllState({ logger }); |
324 | 329 | const config1 = await configUtils.initConfig( |
325 | | - createFeatures([]), |
| 330 | + state, |
326 | 331 | createTestInitConfigInputs({ |
327 | 332 | languagesInput: "javascript,python", |
328 | 333 | tempDir, |
@@ -373,8 +378,9 @@ test.serial("loading config with version mismatch throws", async (t) => { |
373 | 378 | .stub(actionsUtil, "getActionVersion") |
374 | 379 | .returns("does-not-exist"); |
375 | 380 |
|
| 381 | + const state = initAllState({ logger }); |
376 | 382 | const config = await configUtils.initConfig( |
377 | | - createFeatures([]), |
| 383 | + state, |
378 | 384 | createTestInitConfigInputs({ |
379 | 385 | languagesInput: "javascript,python", |
380 | 386 | tempDir, |
@@ -402,8 +408,9 @@ test.serial("loading config with version mismatch throws", async (t) => { |
402 | 408 | test.serial("load input outside of workspace", async (t) => { |
403 | 409 | return await withTmpDir(async (tempDir) => { |
404 | 410 | try { |
| 411 | + const state = initAllState(); |
405 | 412 | await configUtils.initConfig( |
406 | | - createFeatures([]), |
| 413 | + state, |
407 | 414 | createTestInitConfigInputs({ |
408 | 415 | configFile: "../input", |
409 | 416 | tempDir, |
@@ -424,43 +431,16 @@ test.serial("load input outside of workspace", async (t) => { |
424 | 431 | }); |
425 | 432 | }); |
426 | 433 |
|
427 | | -test.serial("load non-local input with invalid repo syntax", async (t) => { |
428 | | - return await withTmpDir(async (tempDir) => { |
429 | | - // no filename given, just a repo |
430 | | - const configFile = "octo-org/codeql-config@main"; |
431 | | - |
432 | | - try { |
433 | | - await configUtils.initConfig( |
434 | | - createFeatures([]), |
435 | | - createTestInitConfigInputs({ |
436 | | - configFile, |
437 | | - tempDir, |
438 | | - workspacePath: tempDir, |
439 | | - }), |
440 | | - ); |
441 | | - throw new Error("initConfig did not throw error"); |
442 | | - } catch (err) { |
443 | | - t.deepEqual( |
444 | | - err, |
445 | | - new ConfigurationError( |
446 | | - errorMessages.getConfigFileRepoFormatInvalidMessage( |
447 | | - "octo-org/codeql-config@main", |
448 | | - ), |
449 | | - ), |
450 | | - ); |
451 | | - } |
452 | | - }); |
453 | | -}); |
454 | | - |
455 | 434 | test.serial("load non-existent input", async (t) => { |
456 | 435 | return await withTmpDir(async (tempDir) => { |
457 | 436 | const languagesInput = "javascript"; |
458 | 437 | const configFile = "input"; |
459 | 438 | t.false(fs.existsSync(path.join(tempDir, configFile))); |
460 | 439 |
|
461 | 440 | try { |
| 441 | + const state = initAllState(); |
462 | 442 | await configUtils.initConfig( |
463 | | - createFeatures([]), |
| 443 | + state, |
464 | 444 | createTestInitConfigInputs({ |
465 | 445 | languagesInput, |
466 | 446 | configFile, |
@@ -536,8 +516,9 @@ test.serial("load non-empty input", async (t) => { |
536 | 516 | const languagesInput = "javascript"; |
537 | 517 | const configFilePath = createConfigFile(inputFileContents, tempDir); |
538 | 518 |
|
| 519 | + const state = initAllState(); |
539 | 520 | const actualConfig = await configUtils.initConfig( |
540 | | - createFeatures([]), |
| 521 | + state, |
541 | 522 | createTestInitConfigInputs({ |
542 | 523 | languagesInput, |
543 | 524 | buildModeInput: "none", |
@@ -595,8 +576,9 @@ test.serial( |
595 | 576 | // Only JS, python packs will be ignored |
596 | 577 | const languagesInput = "javascript"; |
597 | 578 |
|
| 579 | + const state = initAllState(); |
598 | 580 | const config = await configUtils.initConfig( |
599 | | - createFeatures([]), |
| 581 | + state, |
600 | 582 | createTestInitConfigInputs({ |
601 | 583 | languagesInput, |
602 | 584 | configFile: configFilePath, |
@@ -647,8 +629,9 @@ test.serial("API client used when reading remote config", async (t) => { |
647 | 629 | const configFile = "octo-org/codeql-config/config.yaml@main"; |
648 | 630 | const languagesInput = "javascript"; |
649 | 631 |
|
| 632 | + const state = initAllState(); |
650 | 633 | await configUtils.initConfig( |
651 | | - createFeatures([]), |
| 634 | + state, |
652 | 635 | createTestInitConfigInputs({ |
653 | 636 | languagesInput, |
654 | 637 | configFile, |
@@ -669,9 +652,10 @@ test.serial( |
669 | 652 | mockGetContents(dummyResponse); |
670 | 653 |
|
671 | 654 | const repoReference = "octo-org/codeql-config/config.yaml@main"; |
| 655 | + const state = initAllState(); |
672 | 656 | try { |
673 | 657 | await configUtils.initConfig( |
674 | | - createFeatures([]), |
| 658 | + state, |
675 | 659 | createTestInitConfigInputs({ |
676 | 660 | configFile: repoReference, |
677 | 661 | tempDir, |
@@ -699,9 +683,10 @@ test.serial("Invalid format of remote config handled correctly", async (t) => { |
699 | 683 | mockGetContents(dummyResponse); |
700 | 684 |
|
701 | 685 | const repoReference = "octo-org/codeql-config/config.yaml@main"; |
| 686 | + const state = initAllState(); |
702 | 687 | try { |
703 | 688 | await configUtils.initConfig( |
704 | | - createFeatures([]), |
| 689 | + state, |
705 | 690 | createTestInitConfigInputs({ |
706 | 691 | configFile: repoReference, |
707 | 692 | tempDir, |
@@ -729,9 +714,10 @@ test.serial("No detected languages", async (t) => { |
729 | 714 | }, |
730 | 715 | }); |
731 | 716 |
|
| 717 | + const state = initAllState(); |
732 | 718 | try { |
733 | 719 | await configUtils.initConfig( |
734 | | - createFeatures([]), |
| 720 | + state, |
735 | 721 | createTestInitConfigInputs({ |
736 | 722 | tempDir, |
737 | 723 | codeql, |
@@ -752,9 +738,10 @@ test.serial("Unknown languages", async (t) => { |
752 | 738 | return await withTmpDir(async (tempDir) => { |
753 | 739 | const languagesInput = "rubbish,english"; |
754 | 740 |
|
| 741 | + const state = initAllState(); |
755 | 742 | try { |
756 | 743 | await configUtils.initConfig( |
757 | | - createFeatures([]), |
| 744 | + state, |
758 | 745 | createTestInitConfigInputs({ |
759 | 746 | languagesInput, |
760 | 747 | tempDir, |
|