Skip to content

Commit

Permalink
Prepare IdeHookTest to run in configuration cache mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg committed Oct 24, 2024
1 parent 7feb013 commit 0f88859
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
37 changes: 37 additions & 0 deletions lib/src/main/java/com/diffplug/spotless/TestingOnly.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2024 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.diffplug.spotless;

import java.util.Locale;

/** These FormatterStep are meant to be used for testing only. */
public class TestingOnly {
public static FormatterStep lowercase() {
return FormatterStep.create("lowercase", "lowercaseStateUnused", unused -> TestingOnly::lowercase);
}

private static String lowercase(String raw) {
return raw.toLowerCase(Locale.ROOT);
}

public static FormatterStep diverge() {
return FormatterStep.create("diverge", "divergeStateUnused", unused -> TestingOnly::diverge);
}

private static String diverge(String raw) {
return raw + " ";
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 DiffPlug
* Copyright 2016-2024 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,11 +40,11 @@ void before() throws IOException {
"spotless {",
" format 'misc', {",
" target 'DIRTY.md', 'CLEAN.md'",
" custom 'lowercase', { str -> str.toLowerCase(Locale.ROOT) }",
" addStep com.diffplug.spotless.TestingOnly.lowercase()",
" }",
" format 'diverge', {",
" target 'DIVERGE.md'",
" custom 'diverge', { str -> str + ' ' }",
" addStep com.diffplug.spotless.TestingOnly.diverge()",
" }",
"}");
dirty = new File(rootFolder(), "DIRTY.md");
Expand Down

0 comments on commit 0f88859

Please sign in to comment.