function getCwdConfigFileTest(extension) {
  return async t => {
    try {
      await spawn(path.resolve('..', 'markdownlint.js'), ['.'], {
        cwd: path.join(__dirname, 'config-files', extension)
      });
      t.fail();
    } catch (error) {
      const expected = ["heading-dollar.md:1:10 MD026/no-trailing-punctuation Trailing punctuation in heading [Punctuation: '$']"].join('\n');
      t.is(error.stdout, '');
      t.is(error.stderr, expected);
      t.is(error.exitCode, 1);
    }
  };
}
', '--ignore', 'subdir-incorrect']);
  t.is(result.stdout, '');
  t.is(result.stderr, '');
  t.is(result.exitCode, 0);
});

test('linting results are sorted by file/line/names/description', async t => {
  try {
    await spawn('../markdownlint.js', ['--config', 'test-config.json', 'incorrect.md']);
    t.fail();
  } catch (error) {
    const expected = ['incorrect.md:1 MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "## header 2"]', 'incorrect.md:1 MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "## header 2"]', 'incorrect.md:2 MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Above] [Context: "# header"]', 'incorrect.md:5:1 MD014/commands-show-output Dollar signs used before commands without showing output [Context: "$ code"]', 'incorrect.md:11:1 MD014/commands-show-output Dollar signs used before commands without showing output [Context: "$ code"]', 'incorrect.md:17:1 MD014/commands-show-output Dollar signs used before commands without showing output [Context: "$ code"]', 'incorrect.md:23:1 MD014/commands-show-output Dollar signs used before commands without showing output [Context: "$ code"]'].join('\n');
    t.is(error.stdout, '');
    t.is(error.stderr, expected);
    t.is(error.exitCode, 1);
  }
});

test('glob linting does not try to lint directories as files', async t => {
  try {
    await spawn('../markdownlint.js', ['--config', 'test-config.json', '*