Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2013 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.profile
import org.gradle.StartParameter
import org.gradle.api.tasks.TaskState
import org.gradle.test.fixtures.file.TestNameTestDirectoryProvider
import org.junit.Rule
import spock.lang.Specification
import static org.gradle.util.internal.TextUtil.toPlatformLineSeparators
class ProfileReportRendererTest extends Specification {
@Rule TestNameTestDirectoryProvider temp = new TestNameTestDirectoryProvider(getClass())
def "renders report"() {
def model = new BuildProfile(new StartParameter())
def file = temp.file("report.html")
model.profilingStarted = time(12, 20, 0)
model.buildStarted = time(12, 20, 0, 700)
model.settingsEvaluated = time(12, 20, 3)
model.projectsLoaded = time(12, 20, 6)
model.buildFinished = time(12, 35, 30)
model.getDependencySetProfile("compile").start = time(12, 22, 0)
model.getDependencySetProfile("compile").finish = time(12, 23, 30)
model.getDependencySetProfile("runtime").start = time(12, 24, 0)
model.getDependencySetProfile("runtime").finish = time(12, 24, 30)
model.getTransformationProfile("some transform").start(time(12, 22, 0)).setFinish(time(12, 22, 12))
model.getTransformationProfile("some other transform").start(time(12, 23, 0)).setFinish(time(12, 23, 19))
model.getProjectProfile("a").configurationOperation.start = time(12, 20, 7)
model.getProjectProfile("a").configurationOperation.finish = time(12, 20, 10)
model.getProjectProfile("a").getTaskProfile("a:foo").completed(Stub(TaskState)).setStart(time(12, 25, 0)).setFinish(time(12, 26, 30))
model.getProjectProfile("a").getTaskProfile("a:bar").completed(Stub(TaskState)).setStart(time(12, 26, 30)).setFinish(time(12, 27, 0))
model.getProjectProfile("b").configurationOperation.start = time(12, 20, 10)
model.getProjectProfile("b").configurationOperation.finish = time(12, 20, 15)
//let's say they run in parallel, hence same start time
model.getProjectProfile("b").getTaskProfile("b:foo").completed(Stub(TaskState)).setStart(time(12, 27, 0)).setFinish(time(12, 29, 30))
model.getProjectProfile("b").getTaskProfile("b:bar").completed(Stub(TaskState)).setStart(time(12, 27, 0)).setFinish(time(12, 29, 0))
when:
new ProfileReportRenderer().writeTo(model, file)
then:
file.text.contains(toPlatformLineSeparators("""
Profile report
"""))
}
private static long time(int hour, int mins, int secs, int ms = 0) {
def cal = new GregorianCalendar(2010, 1, 5, hour, mins, secs)
cal.add(Calendar.MILLISECOND, ms)
cal.getTimeInMillis()
}
}