-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
AbstractUnexportMainSymbolIntegrationTest.groovy
176 lines (145 loc) · 6.14 KB
/
AbstractUnexportMainSymbolIntegrationTest.groovy
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
/*
* Copyright 2019 the original author or authors.
*
* 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 org.gradle.language.nativeplatform.tasks
import org.gradle.integtests.fixtures.ToBeFixedForConfigurationCache
import org.gradle.nativeplatform.fixtures.AbstractInstalledToolChainIntegrationSpec
import org.gradle.nativeplatform.fixtures.NativeBinaryFixture
import org.gradle.nativeplatform.fixtures.app.IncrementalElement
import org.gradle.nativeplatform.fixtures.app.SourceElement
import org.gradle.nativeplatform.fixtures.app.SourceFileElement
import org.gradle.nativeplatform.fixtures.binaryinfo.BinaryInfo
import org.gradle.test.fixtures.file.TestFile
import spock.lang.Ignore
import spock.lang.Issue
abstract class AbstractUnexportMainSymbolIntegrationTest extends AbstractInstalledToolChainIntegrationSpec {
protected abstract void makeSingleProject()
protected abstract String getDevelopmentBinaryCompileTask();
protected abstract IncrementalElement getComponentUnderTest();
protected abstract SourceElement getComponentWithOtherFileUnderTest();
protected abstract SourceFileElement getOtherFile();
protected abstract SourceFileElement getMainFile(String filenameWithoutExtension = "main")
protected abstract SourceElement getComponentWithoutMainUnderTest()
protected void assertMainSymbolIsNotExported(TestFile objectFile) {
assert !findMainSymbol(objectFile).exported
}
private BinaryInfo.Symbol findMainSymbol(TestFile objectFile) {
def binary = new NativeBinaryFixture(objectFile, toolChain)
def symbols = binary.binaryInfo.listSymbols()
def mainSymbol = symbols.find({ it.name in mainSymbols })
assert mainSymbol
mainSymbol
}
protected abstract List<String> getMainSymbols()
@Issue("https://github.com/gradle/gradle-native/issues/304")
@ToBeFixedForConfigurationCache
def "clean build works"() {
makeSingleProject()
componentUnderTest.writeToProject(testDirectory)
expect:
succeeds("clean", "unexport")
}
@Issue("https://github.com/gradle/gradle-native/issues/297")
@ToBeFixedForConfigurationCache
@Ignore("This is failing on release6x and we don't want to spent time on it")
def "unexport is incremental"() {
makeSingleProject()
componentUnderTest.writeToProject(testDirectory)
when:
succeeds("unexport")
then:
result.assertTasksNotSkipped(developmentBinaryCompileTask, ":unexport")
when:
succeeds("unexport")
then:
result.assertTasksSkipped(developmentBinaryCompileTask, ":unexport")
when:
componentUnderTest.applyChangesToProject(testDirectory)
succeeds("unexport")
then:
result.assertTasksNotSkipped(developmentBinaryCompileTask, ":unexport")
}
@ToBeFixedForConfigurationCache
def "relocate _main symbol with main.<ext>"() {
makeSingleProject()
componentUnderTest.writeToProject(testDirectory)
when:
succeeds("unexport")
then:
assertMainSymbolIsNotExported(objectFile("build/relocated/main"))
}
@ToBeFixedForConfigurationCache
def "relocate _main symbol with notMain.<ext>"() {
makeSingleProject()
getMainFile("notMain").writeToProject(testDirectory)
when:
succeeds("unexport")
then:
assertMainSymbolIsNotExported(objectFile("build/relocated/notMain"))
}
@ToBeFixedForConfigurationCache
def "relocate _main symbol with multiple files"() {
makeSingleProject()
componentWithOtherFileUnderTest.writeToProject(testDirectory)
when:
succeeds("unexport")
then:
assertMainSymbolIsNotExported(objectFile("build/relocated/main"))
file("build/relocated").assertHasDescendants(objectFile("main").name, objectFile("other").name)
}
@ToBeFixedForConfigurationCache
def "relocate _main symbol works incrementally"() {
makeSingleProject()
componentUnderTest.writeToProject(testDirectory)
when:
succeeds("unexport")
then:
assertMainSymbolIsNotExported(objectFile("build/relocated/main"))
file("build/relocated").assertHasDescendants(objectFile("main").name)
when:
def mainObject = objectFile("build/relocated/main")
mainObject.makeOlder()
def oldTimestamp = mainObject.lastModified()
otherFile.writeToProject(testDirectory)
succeeds("unexport")
then:
assertMainSymbolIsNotExported(objectFile("build/relocated/main"))
file("build/relocated").assertHasDescendants(objectFile("main").name, objectFile("other").name)
mainObject.lastModified() == oldTimestamp
when:
assert file(otherFile.sourceFile.withPath("src/main")).delete()
succeeds("unexport")
then:
assertMainSymbolIsNotExported(objectFile("build/relocated/main"))
file("build/relocated").assertHasDescendants(objectFile("main").name)
mainObject.lastModified() == oldTimestamp
when:
otherFile.writeToProject(testDirectory)
succeeds("unexport")
assert objectFile("build/relocated/other").delete()
succeeds("unexport")
then:
mainObject.lastModified() > oldTimestamp
}
@ToBeFixedForConfigurationCache
def "can relocate when there is no main symbol"() {
makeSingleProject()
componentWithoutMainUnderTest.writeToProject(testDirectory)
when:
succeeds("unexport")
then:
file("build/relocated").assertHasDescendants(objectFile("greeter").name, objectFile("sum").name, objectFile("multiply").name)
}
}