Skip to content

Commit 384f309

Browse files
committed
NEW @W-19374413@ Added test that should fail on Windows
1 parent 6cc4f08 commit 384f309

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

.gitattributes

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
# We do not wish to have GitHub add carriage returns for these files on windows.
33
# So we forcefully set any file that ends in .goldfile.<ext> to only have \n characters:
44
# See https://help.github.com/articles/dealing-with-line-endings/
5-
*.goldfile.* text eol=lf
5+
*.goldfile.* text eol=lf
6+
7+
*.lf.* text eol=lf

packages/code-analyzer-regex-engine/test/engine.test.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const SAMPLE_CUSTOM_RULES: RegexRules = {
3939
NoTalkingAboutFightClub: {
4040
regex: '/fight club/gi',
4141
description: "The first rule of Fight Club is do not talk about Fight Club",
42-
file_extensions: [".abc-def.xyz"],
42+
file_extensions: [".abc-def.xyz", ".lf.cls"],
4343
violation_message: "The second rule of Fight Club is DO NOT. TALK. ABOUT FIGHT CLUB.",
4444
severity: DEFAULT_SEVERITY_LEVEL,
4545
tags: ['PopCulture']
@@ -783,6 +783,34 @@ describe('Tests for runRules', () => {
783783
}
784784
});
785785

786+
it('When workspace contains files that use \\n instead of \\r\\n, violations are right regardless of OS', async () => {
787+
const runOptions: RunOptions = createRunOptions(
788+
new Workspace('id', [path.resolve(__dirname, "test-data", "workspaceWithLfNewlines")]));
789+
const runResults: EngineRunResults = await engine.runRules(['NoTalkingAboutFightClub'], runOptions);
790+
791+
const expectedViolations: Violation[] = [
792+
{
793+
ruleName: "NoTalkingAboutFightClub",
794+
message: "The second rule of Fight Club is DO NOT. TALK. ABOUT FIGHT CLUB.",
795+
primaryLocationIndex: 0,
796+
codeLocations: [
797+
{
798+
file: path.resolve(__dirname, "test-data", "workspaceWithLfNewlines", "testClass.lf.cls"),
799+
startLine: 3,
800+
startColumn: 87,
801+
endLine: 3,
802+
endColumn: 97
803+
}
804+
]
805+
}
806+
];
807+
808+
expect(runResults.violations).toHaveLength(expectedViolations.length);
809+
for (const expectedViolation of expectedViolations) {
810+
expect(runResults.violations).toContainEqual(expectedViolation);
811+
}
812+
});
813+
786814
it("When running all rules compared to some rules, then output correctly returns what the correct violations according to specified rules", async () => {
787815
const runOptions: RunOptions = createRunOptions(
788816
new Workspace('id', [path.resolve(__dirname, "test-data", "sampleWorkspace")]));
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
public class TestClass {
2+
public static boolean doTheThing() {
3+
List<String> strings = new List<String>{'THis is fine', 'THis is also fine', 'fight club', 'OH NO, that last string was bad!'};
4+
return false;
5+
}
6+
}

0 commit comments

Comments
 (0)