File tree 2 files changed +34
-1
lines changed
main/java/org/gradle/profiler/mutations
test/groovy/org/gradle/profiler/mutations
2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 3
3
import com .google .common .base .Strings ;
4
4
import com .google .common .io .Files ;
5
5
import com .typesafe .config .Config ;
6
+
7
+ import org .apache .commons .io .FileUtils ;
6
8
import org .gradle .profiler .BuildMutator ;
7
9
import org .gradle .profiler .CompositeBuildMutator ;
8
10
import org .gradle .profiler .ConfigUtil ;
@@ -30,7 +32,11 @@ protected void executeOnSchedule() {
30
32
if (!target .exists ()) {
31
33
Files .createParentDirs (target );
32
34
}
33
- Files .copy (source , target );
35
+ if (source .isDirectory ()) {
36
+ FileUtils .copyDirectory (source , target );
37
+ } else {
38
+ Files .copy (source , target );
39
+ }
34
40
} catch (IOException e ) {
35
41
throw new UncheckedIOException ("Failed to copy '" + source .getAbsolutePath () + "' to '" + target .getAbsolutePath () + "'" , e );
36
42
}
Original file line number Diff line number Diff line change @@ -27,6 +27,33 @@ class CopyFileMutatorTest extends AbstractMutatorTest {
27
27
target. text == expectedContents
28
28
}
29
29
30
+ def " copies directory and contents from source to target" () {
31
+ def testDir = tmpDir. newFolder()
32
+
33
+ def expectedContents = " Copy file from source to target"
34
+ def source = new File (testDir, " source/file.txt" )
35
+ source. parentFile. mkdirs()
36
+ source. text = expectedContents
37
+
38
+ def target = new File (testDir, " nested/target/file.txt" )
39
+
40
+ def spec = mockConfigSpec(""" {
41
+ copy-file = {
42
+ source = "source"
43
+ target = "nested/target"
44
+ }
45
+ }""" )
46
+ _ * spec. projectDir >> testDir
47
+
48
+ when :
49
+ def mutator = new CopyFileMutator.Configurator (). configure(" copy-file" , spec)
50
+ mutator. beforeScenario(scenarioContext)
51
+
52
+ then :
53
+ target. exists()
54
+ target. text == expectedContents
55
+ }
56
+
30
57
def " copies multiple sets of source and target" () {
31
58
def testDir = tmpDir. newFolder()
32
59
You can’t perform that action at this time.
0 commit comments