mirror of
https://github.com/actions/setup-java.git
synced 2026-11-14 13:10:34 +08:00
Default the problem-matcher input to false so setup-java no longer registers Java compiler and uncaught-exception annotations unless explicitly enabled with problem-matcher: true. Fixes #1322 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
import {afterEach, beforeEach, describe, expect, it, jest} from '@jest/globals';
|
|
|
|
const mockGetInput = jest.fn<(...args: any[]) => any>();
|
|
const mockInfo = jest.fn<(...args: any[]) => any>();
|
|
const mockDebug = jest.fn<(...args: any[]) => any>();
|
|
|
|
jest.unstable_mockModule('@actions/core', () => ({
|
|
getInput: mockGetInput,
|
|
info: mockInfo,
|
|
debug: mockDebug,
|
|
warning: jest.fn(),
|
|
setSecret: jest.fn()
|
|
}));
|
|
|
|
const {configureProblemMatcher} = await import('../src/problem-matcher.js');
|
|
const {INPUT_PROBLEM_MATCHER} = await import('../src/constants.js');
|
|
|
|
describe('configureProblemMatcher', () => {
|
|
let inputs: Record<string, string>;
|
|
|
|
beforeEach(() => {
|
|
inputs = {};
|
|
mockGetInput.mockImplementation((name: string) => inputs[name] ?? '');
|
|
});
|
|
|
|
afterEach(() => {
|
|
jest.resetAllMocks();
|
|
});
|
|
|
|
it('does not register the Java problem matcher by default', () => {
|
|
configureProblemMatcher('/matchers/java.json');
|
|
|
|
expect(mockInfo).not.toHaveBeenCalled();
|
|
expect(mockDebug).toHaveBeenCalledWith('Java problem matcher is disabled');
|
|
});
|
|
|
|
it('registers the Java problem matcher when explicitly enabled', () => {
|
|
inputs[INPUT_PROBLEM_MATCHER] = 'true';
|
|
|
|
configureProblemMatcher('/matchers/java.json');
|
|
|
|
expect(mockInfo).toHaveBeenCalledWith('##[add-matcher]/matchers/java.json');
|
|
});
|
|
|
|
it('does not register the Java problem matcher when disabled', () => {
|
|
inputs[INPUT_PROBLEM_MATCHER] = 'false';
|
|
|
|
configureProblemMatcher('/matchers/java.json');
|
|
|
|
expect(mockInfo).not.toHaveBeenCalled();
|
|
expect(mockDebug).toHaveBeenCalledWith('Java problem matcher is disabled');
|
|
});
|
|
});
|