Skip to content

test(output): Add comprehensive tests for files:false option across all styles - #1162

Open
hztBUAA wants to merge 1 commit into
yamadashy:mainfrom
hztBUAA:fix/files-false-option
Open

test(output): Add comprehensive tests for files:false option across all styles#1162
hztBUAA wants to merge 1 commit into
yamadashy:mainfrom
hztBUAA:fix/files-false-option

Conversation

@hztBUAA

@hztBUAA hztBUAA commented Feb 20, 2026

Copy link
Copy Markdown

Summary

Addresses #1060 by adding comprehensive test coverage for the output.files: false configuration option across all output styles and configuration paths.

After thorough investigation, the files: false option works correctly on the current main branch across all code paths (CLI options, config file, programmatic runCli API). However, the test coverage was limited to only the plain text output style. This PR adds tests to ensure the behavior remains correct across all output formats and configuration paths.

New tests added:

tests/cli/actions/defaultAction.test.ts (2 tests)

  • --no-files flag correctly maps to output.files: false in CLI config
  • Commander.js default (files: true when --no-files is not passed) does not override config file settings

tests/config/configLoad.test.ts (4 tests)

  • files: false from CLI config is respected in merged config
  • files: false from file config is respected in merged config
  • CLI files: false properly overrides file config files: true
  • Default value of files: true when not set anywhere

tests/core/output/outputGenerate.test.ts (5 tests)

  • XML style (Handlebars): no <file path= elements in output
  • Parsable XML style: files key is undefined in parsed XML
  • Markdown style: no # Files section or ## File: entries
  • JSON style: no files property in parsed JSON

Investigation Notes

The files: false option is correctly handled at every level:

  1. CLI flag (--no-files): buildCliConfig() maps options.files === false to cliConfig.output.files = false
  2. Config file (repomix.config.json): output.files: false is correctly loaded and merged
  3. Programmatic API (runCli()): files: false in options is correctly processed
  4. Output generation: All templates (Handlebars xml/markdown/plain) use {{#if filesEnabled}}, and parsable xml/json generators check renderContext.filesEnabled

The reported issue may stem from placing files: false at the top level of repomix.config.json instead of nesting it under output (i.e., output: { files: false }). Top-level files is silently ignored by the config schema.

Checklist

  • npm run test - All 1105 tests pass (including 11 new)
  • Lint checks pass on changed files

Fixes #1060

@hztBUAA
hztBUAA requested a review from yamadashy as a code owner February 20, 2026 04:37
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @hztBUAA, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the test coverage for the files: false output option. It ensures that when this option is enabled, file content is correctly excluded across all supported output formats (XML, parsable XML, Markdown, JSON) and verifies the proper handling of the corresponding CLI flag and configuration settings. This enhances the robustness and reliability of the output generation feature.

Highlights

  • Enhanced files: false option testing: Comprehensive tests were added to outputGenerate.test.ts to verify the files: false option correctly excludes file content in XML, parsable XML, Markdown, and JSON output styles.
  • CLI flag and configuration handling: New tests in defaultAction.test.ts confirm that buildCliConfig correctly maps the --no-files CLI flag to output.files: false and that Commander's default files: true does not override config file settings.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • tests/cli/actions/defaultAction.test.ts
    • Added tests to ensure buildCliConfig correctly processes the --no-files CLI flag, setting output.files to false.
    • Included a test to confirm that Commander's default files: true option does not inadvertently set output.files in the configuration when not explicitly provided.
  • tests/core/output/outputGenerate.test.ts
    • Added a test to verify that the files: false option correctly excludes the files section in XML output.
    • Added a test to verify that the files: false option correctly excludes the files section in parsable XML output.
    • Added a test to verify that the files: false option correctly excludes the files section in Markdown output.
    • Added a test to verify that the files: false option correctly excludes the files property in JSON output.
Activity
  • No specific activity (comments, reviews, progress) was provided in the context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai

coderabbitai Bot commented Feb 20, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR adds test coverage for the --no-files CLI flag and its impact on output generation. Two test suites receive new test cases: one verifies CLI option handling converts the flag to config.output.files setting, and the other validates that generated outputs across multiple styles (XML, Markdown, JSON) exclude file sections when the flag is set.

Changes

Cohort / File(s) Summary
CLI Option Handling
tests/cli/actions/defaultAction.test.ts
Added two tests verifying --no-files flag behavior: confirms config.output.files is set to false when flag is present, and remains undefined when using Commander's default true value.
Output Rendering
tests/core/output/outputGenerate.test.ts
Added tests across XML (standard and parsable), Markdown, and JSON output styles verifying that file entries and file-related sections are excluded from generated output when config.output.files is false.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • PR #389: Implements the fix for correctly handling --no-* CLI options in buildCliConfig that these tests verify.
  • PR #491: Introduces the files output rendering conditional and behavior that these tests validate.
  • PR #224: Related changes to output configuration and file output structure in templates and tests.

Suggested reviewers

  • yamadashy
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding comprehensive tests for the files:false option across all output styles.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description is comprehensive and well-structured, including a clear summary, detailed list of new tests, investigation notes explaining the fix, and a completed checklist.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds valuable test coverage for the files: false option across all output styles, which was previously only tested for the plain style. The changes look good and correctly verify the intended behavior. I've added a couple of suggestions to refactor the new tests using parameterized tests (test.each and it.each). This will help reduce code duplication and improve the maintainability of the test suite. Overall, great work on improving the test coverage!

Comment on lines +308 to +324
it('should handle --no-files flag', () => {
const options = {
files: false,
};
const config = buildCliConfig(options);

expect(config.output?.files).toBe(false);
});

it('should not set files in config when files option is true (Commander default)', () => {
const options = {
files: true,
};
const config = buildCliConfig(options);

expect(config.output?.files).toBeUndefined();
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These two tests for the files option can be combined into a single parameterized test using it.each. This makes the test cases more explicit and reduces boilerplate, improving maintainability.

    it.each([
      { files: false, expected: false, description: 'should handle --no-files flag' },
      {
        files: true,
        expected: undefined,
        description: 'should not set files in config when files option is true (Commander default)',
      },
    ])('$description', ({ files, expected }) => {
      const options = {
        files,
      };
      const config = buildCliConfig(options);

      expect(config.output?.files).toBe(expected);
    });

Comment on lines +296 to +365
test('generateOutput should exclude files section in xml style when files is false', async () => {
const mockConfig = createMockConfig({
output: {
filePath: 'output.xml',
style: 'xml',
files: false,
},
});
const mockProcessedFiles: ProcessedFile[] = [{ path: 'file1.txt', content: 'content1' }];

const output = await generateOutput([process.cwd()], mockConfig, mockProcessedFiles, []);

expect(output).not.toContain('file1.txt');
expect(output).not.toContain('content1');
expect(output).not.toContain('<files>');
});

test('generateOutput should exclude files section in parsable xml style when files is false', async () => {
const mockConfig = createMockConfig({
output: {
filePath: 'output.xml',
style: 'xml',
parsableStyle: true,
files: false,
},
});
const mockProcessedFiles: ProcessedFile[] = [{ path: 'file1.txt', content: '<div>foo</div>' }];

const output = await generateOutput([process.cwd()], mockConfig, mockProcessedFiles, []);

const parser = new XMLParser({ ignoreAttributes: false });
const parsedOutput = parser.parse(output);
expect(parsedOutput.repomix.files).toBeUndefined();
});

test('generateOutput should exclude files section in markdown style when files is false', async () => {
const mockConfig = createMockConfig({
output: {
filePath: 'output.md',
style: 'markdown',
files: false,
},
});
const mockProcessedFiles: ProcessedFile[] = [{ path: 'file1.txt', content: 'content1' }];

const output = await generateOutput([process.cwd()], mockConfig, mockProcessedFiles, []);

expect(output).not.toContain('## File: file1.txt');
expect(output).not.toContain('content1');
expect(output).not.toContain('# Files');
});

test('generateOutput should exclude files section in json style when files is false', async () => {
const mockConfig = createMockConfig({
output: {
filePath: 'output.json',
style: 'json',
files: false,
},
});
const mockProcessedFiles: ProcessedFile[] = [
{ path: 'file1.txt', content: 'content1' },
{ path: 'file2.txt', content: 'content2' },
];

const output = await generateOutput([process.cwd()], mockConfig, mockProcessedFiles, []);

const parsed = JSON.parse(output);
expect(parsed).not.toHaveProperty('files');
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These four new tests are very similar in structure. They can be consolidated into a single parameterized test using test.each to reduce code duplication and improve maintainability.

  test.each([
    {
      description: 'xml style',
      config: { filePath: 'output.xml', style: 'xml' as const },
      processedFiles: [{ path: 'file1.txt', content: 'content1' }],
      check: (output: string) => {
        expect(output).not.toContain('file1.txt');
        expect(output).not.toContain('content1');
        expect(output).not.toContain('<files>');
      },
    },
    {
      description: 'parsable xml style',
      config: { filePath: 'output.xml', style: 'xml' as const, parsableStyle: true },
      processedFiles: [{ path: 'file1.txt', content: '<div>foo</div>' }],
      check: (output: string) => {
        const parser = new XMLParser({ ignoreAttributes: false });
        const parsedOutput = parser.parse(output);
        expect(parsedOutput.repomix.files).toBeUndefined();
      },
    },
    {
      description: 'markdown style',
      config: { filePath: 'output.md', style: 'markdown' as const },
      processedFiles: [{ path: 'file1.txt', content: 'content1' }],
      check: (output: string) => {
        expect(output).not.toContain('## File: file1.txt');
        expect(output).not.toContain('content1');
        expect(output).not.toContain('# Files');
      },
    },
    {
      description: 'json style',
      config: { filePath: 'output.json', style: 'json' as const },
      processedFiles: [
        { path: 'file1.txt', content: 'content1' },
        { path: 'file2.txt', content: 'content2' },
      ],
      check: (output: string) => {
        const parsed = JSON.parse(output);
        expect(parsed).not.toHaveProperty('files');
      },
    },
  ])(
    'generateOutput should exclude files section in $description when files is false',
    async ({ config, processedFiles, check }) => {
      const mockConfig = createMockConfig({
        output: {
          ...config,
          files: false,
        },
      });

      const output = await generateOutput([process.cwd()], mockConfig, processedFiles, []);

      check(output);
    },
  );

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

…ll output styles

Add test coverage for the `output.files: false` configuration option
to ensure file contents are properly excluded across all output formats.
This addresses the concern raised in yamadashy#1060.

New tests:
- buildCliConfig: --no-files flag mapping and Commander default handling
- mergeConfigs: files:false from CLI, file config, CLI override, defaults
- generateOutput: files:false for xml, parsable xml, markdown, json styles
@hztBUAA
hztBUAA force-pushed the fix/files-false-option branch from 5fbaf3d to d80de24 Compare February 20, 2026 04:52
@hztBUAA

hztBUAA commented Feb 25, 2026

Copy link
Copy Markdown
Author

Thanks for the review and feedback. I am following up on this PR now and will either push the requested changes or reply point-by-point shortly.

@hztBUAA

hztBUAA commented Feb 25, 2026

Copy link
Copy Markdown
Author

Quick follow-up: I am reviewing the feedback and will update this PR shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

files false doesn't work

1 participant