File: build.gradle

package info (click to toggle)
svnkit 1.8.14-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 18,080 kB
  • sloc: java: 230,914; xml: 273; sh: 262; makefile: 36; python: 17; perl: 8
file content (249 lines) | stat: -rw-r--r-- 7,728 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
configurations {
    pythonTests16
    svnBinaries16

    pythonTests17
    svnBinaries17
}
dependencies {
    pythonTests16 'org.tigris.subversion:svn-python-tests:1.6.18-v2@tgz'
    if (!project.hasProperty('svn.binaries.local')) { svnBinaries16 'org.tigris.subversion:svn-binaries:1.6.18-v2@tgz' }

    pythonTests17 'org.apache.subversion:svn-python-tests:1.9.0@tgz'
    if (!project.hasProperty('svn.binaries.local')) { svnBinaries17 'org.apache.subversion:svn-binaries:1.9.0@tgz' }
}

sourceSets {
    main {
        java {
            srcDir 'nailgun/src/java/prod'
        }
    }
}
project.ext {
    sandboxDir = getSandboxLocation()
    logsDir = new File(sandboxDir, 'logs')
    svnBinariesDir = getSvnBinariesLocation()

    pythonTestsDir = new File(sandboxDir, 'svn-python-tests')
    testPropertiesFile = new File(sandboxDir, 'test.properties')
    svnVersion = project.hasProperty('svnVersion') ? project.getProperty('svnVersion') : '16'
    singleFormat = project.hasProperty('singleFormat')
    testConfiguration = project.hasProperty('testConfiguration') ? project.getProperty('testConfiguration') : 'default'
}


classes << {
    copy {
        into file('build/classes/main')
        from file('nailgun/src/java/prod')
        include '**/*.properties'
    }
}

task testPython {
    dependsOn classes
    dependsOn configurations."pythonTests${project.svnVersion}"
    dependsOn configurations."svnBinaries${project.svnVersion}"
}

testPython.doFirst {
    project.mkdir(sandboxDir)
    project.mkdir(logsDir)

    buildNailgun()
    
    // create wc.h file at build/libsvn_wc/wc.h
    File wcHeader = new File(buildDir, "libsvn_wc/wc.h");
    wcHeader.getParentFile().mkdirs();
    wcHeader << "\n#define SVN_WC__VERSION 31\n";

    try {
        runPythonTests()
    } finally {
        cleanSandbox()
    }
}

def runPythonTests() {
    File pythonTestsTar = configurations."pythonTests${project.svnVersion}".files.find {return true}
    File svnBinariesTar = configurations."svnBinaries${project.svnVersion}".files.find {return true}

    untar(pythonTestsTar, sandboxDir)
    copy {
        into sandboxDir
        into('svn-python-tests') {
            from 'configurations/svn' + project.svnVersion + '/cmdline'
        }
        
    }
    if (!project.hasProperty('svn.binaries.local')) { untar(svnBinariesTar, sandboxDir) }

    if (getOSName() != 'windows' && project.svnVersion == '17') {
         File link = new File(sandboxDir, 'svn-python-tests/entries-dump')
         File target = new File(svnBinariesDir, 'bin/entries-dump')
         if (!link.exists() && target.exists()) {
             ant.symlink(link: link.absolutePath, resource: target.absolutePath)
         }
         File libSvnWc = new File(sandboxDir, "libsvn_wc");
         libSvnWc.mkdirs();
         link = new File(libSvnWc, 'wc-lock-tester')
         target = new File(svnBinariesDir, 'bin/wc-lock-tester')
         if (!link.exists() && target.exists()) {
             ant.symlink(link: link.absolutePath, resource: target.absolutePath)
         }
    }

    copy {
        into sandboxDir
        into('') {
            from "configurations/shared"
        }
        into('') {
            from "configurations/svn${project.svnVersion}"
            exclude "**/*.properties"
        }
    }
    if (svnBinariesDir == null || !svnBinariesDir.isDirectory()) {
        println "Cannot locate subversion binaries for '${getOSName()}' OS, skipping python tests."
        return
    }

    if (getOSName() != 'windows') {
        exec {
           commandLine 'ldd'
           args new File(svnBinariesDir, 'bin/svn').absolutePath
           environment 'LD_LIBRARY_PATH' : new File(svnBinariesDir, 'lib').absolutePath
        }
    }
    exec {
        commandLine new File(svnBinariesDir, 'bin/svn').absolutePath
        args '--version'
        environment 'LD_LIBRARY_PATH' : new File(svnBinariesDir, 'lib').absolutePath
    }

    // 2. generate test environment properties and merge them with the test properties
    def testProperties = generateTestEnvironmentProperties(svnBinariesDir)
    appendDefaultTestProperties(project.svnVersion, project.testConfiguration, testProperties)

    testPropertiesFile.withOutputStream { stream ->
        testProperties.save(stream, null)
    }

    javaexec {

    	if (project.hasProperty('debug')) { debug = true }

        workingDir = sandboxDir
        
        enableAssertions = true

        systemProperty 'sun.io.useCanonCaches', 'false'
        systemProperty 'svnkit.compatibleHash', 'true'
        systemProperty 'svnkit.wc.17', (project.svnVersion == '17')
        systemProperty 'svnkit.wc.17only', project.singleFormat

        environment 'LD_LIBRARY_PATH' : new File(svnBinariesDir, 'lib').absolutePath
        main = 'org.tmatesoft.svn.core.test.PythonTests'
        classpath = sourceSets.main.runtimeClasspath

        args testPropertiesFile.absolutePath, new File(sandboxDir, 'daemon').absolutePath
    }

}

def appendDefaultTestProperties(String svnVersion, String configurationName, Properties properties) {
    File propertiesFile = file("configurations/svn${svnVersion}/${configurationName}.properties")
    propertiesFile.withInputStream {
        properties.load(it)
    }
    return properties
}

def generateTestEnvironmentProperties(File svnBinaries) {
    Properties properties = new Properties()

    properties.put('daemon', 'true')

    properties.put('svn.home', svnBinariesDir.absolutePath )
    properties.put('svnserve.path', new File(svnBinaries, 'bin/svnserve').absolutePath )

    properties.put('apache.path', '/usr/sbin/apache2ctl')
    properties.put('apache.root', '/usr/lib/apache2')
    properties.put('apache.svn.modules', new File(svnBinaries, 'modules').absolutePath )

    properties.put('python.launcher', 'python')

    properties.put('python.tests', pythonTestsDir.absolutePath )
    properties.put('python.tests.results', testResultsDir.absolutePath)
    properties.put('python.tests.logDir', logsDir.absolutePath)

    return properties
}

def untar(File tgz, File into) {
    if (getOSName() != 'windows') {
        exec {
            commandLine 'tar'
            args '-C', into.absolutePath, '-xzf', tgz.absolutePath
        }
    } else {
        ant.untar(src: tgz.absolutePath, dest: into.absolutePath, compression: 'gzip')
    }
}

def buildNailgun() {
    copy {
        from file('nailgun')
        into new File(sandboxDir, 'daemon')

        include '**/ng.exe'
        include 'src/**'
        include 'Makefile'
    }

    if (getOSName() != 'windows') {
        exec {
           commandLine 'make'
           args 'ng'
           workingDir = new File(sandboxDir, 'daemon')
        }
    }

}

def getOSName() {
    String osNameProperty = System.getProperty('os.name')
    osNameProperty = osNameProperty.toLowerCase()
    if (osNameProperty.indexOf('windows') >= 0) {
        return 'windows'
    } else if (osNameProperty.indexOf('mac') >= 0) {
        return 'osx'
    }
    return 'linux'
}

def getSvnBinariesLocation() {
    if (System.getenv()['SVN_TEST_HOME'] != null) {
        return new File(System.getenv()['SVN_TEST_HOME'])
    }
    return new File(sandboxDir, 'svn-binaries/' + getOSName())

}

def getSandboxLocation() {
    String systemLocation = System.getenv()['SVN_TEST_SANDBOX'];
    if (systemLocation != null) {
        File sandbox = File.createTempFile('svnkit.', '.sandbox', new File(systemLocation))
        sandbox.delete()
        return sandbox
    }
    return new File(buildDir, 'sandbox')
}

def cleanSandbox() {
    String systemLocation = System.getenv()['SVN_TEST_SANDBOX'];
    if (systemLocation != null) {
        project.delete(sandboxDir.absolutePath)
    }
}