Skip to content

Commit 5649b56

Browse files
Merge pull request #79 from PhilippSalvisberg/66_show_running_time
#66 - Show overall elapsed time during test run
2 parents d840aec + db906e7 commit 5649b56

File tree

8 files changed

+55
-14
lines changed

8 files changed

+55
-14
lines changed

sqldev/src/main/java/org/utplsql/sqldev/model/runner/Run.xtend

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Run extends AbstractModel {
3737
String serverOutput
3838
LinkedHashMap<String, Test> tests
3939
String status
40+
Long start
4041

4142
new(String reporterId, String connectionName, List<String> pathList) {
4243
this.reporterId = reporterId
@@ -46,6 +47,11 @@ class Run extends AbstractModel {
4647
this.tests = new LinkedHashMap<String, Test>
4748
}
4849

50+
def void setStartTime(String startTime) {
51+
this.startTime = startTime
52+
start = System.currentTimeMillis
53+
}
54+
4955
def getName() {
5056
val time = startTime.substring(11,19)
5157
val conn = connectionName?.substring(15)

sqldev/src/main/java/org/utplsql/sqldev/runner/UtplsqlRunner.xtend

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class UtplsqlRunner implements RealtimeReporterEventConsumer {
129129
run.executionTime = event.executionTime
130130
run.errorStack = event.errorStack
131131
run.serverOutput = event.serverOutput
132-
run.status = String.format(UtplsqlResources.getString("RUNNER_FINNISHED_TEXT"), event.executionTime)
132+
run.status = UtplsqlResources.getString("RUNNER_FINNISHED_TEXT")
133133
panel.update(reporterId)
134134
}
135135

@@ -182,7 +182,7 @@ class UtplsqlRunner implements RealtimeReporterEventConsumer {
182182
} else {
183183
test.startTime = sysdate
184184
}
185-
run.status = event.id
185+
run.status = '''«event.id»...'''
186186
run.currentTestNumber = event.testNumber
187187
run.currentTest = test
188188
panel.update(reporterId)
@@ -241,6 +241,8 @@ class UtplsqlRunner implements RealtimeReporterEventConsumer {
241241
}
242242
if (run.totalNumberOfTests < 0) {
243243
run.status = UtplsqlResources.getString("RUNNER_NO_TESTS_FOUND_TEXT")
244+
run.executionTime = new Double(System.currentTimeMillis - run.start)/1000
245+
run.endTime = sysdate
244246
run.totalNumberOfTests = 0
245247
panel.update(reporterId)
246248
}

sqldev/src/main/java/org/utplsql/sqldev/ui/preference/PreferencePanel.xtend

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@ import javax.swing.JButton
2222
import javax.swing.JCheckBox
2323
import javax.swing.JOptionPane
2424
import javax.swing.JPanel
25-
import javax.swing.JSeparator
2625
import javax.swing.JSpinner
2726
import javax.swing.JTabbedPane
2827
import javax.swing.JTextField
2928
import javax.swing.SpinnerNumberModel
30-
import javax.swing.SwingConstants
3129
import javax.swing.table.DefaultTableModel
3230
import oracle.dbtools.raptor.templates.CodeTemplateUtil
3331
import oracle.ide.panels.DefaultTraversablePanel
@@ -110,7 +108,7 @@ class PreferencePanel extends DefaultTraversablePanel {
110108
runTab.add(
111109
runTab.field.label.withText(UtplsqlResources.getString("PREF_USE_SMART_TIMES_LABEL")).component(
112110
useSmartTimesCheckBox))
113-
runTab.addRow(new JSeparator(SwingConstants.HORIZONTAL))
111+
runTab.addVerticalGap
114112
runTab.addRow(importSnippetsButton)
115113
runTab.addVerticalSpring
116114

sqldev/src/main/java/org/utplsql/sqldev/ui/runner/RunnerPanel.xtend

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import javax.swing.JTabbedPane
4646
import javax.swing.JTable
4747
import javax.swing.RepaintManager
4848
import javax.swing.SwingConstants
49+
import javax.swing.Timer
4950
import javax.swing.UIManager
5051
import javax.swing.border.EmptyBorder
5152
import javax.swing.event.HyperlinkEvent
@@ -85,6 +86,8 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
8586
ToolbarButton clearButton
8687
JComboBox<ComboBoxItem<String, String>> runComboBox
8788
JLabel statusLabel
89+
JLabel elapsedTimeLabel
90+
Timer elapsedTimeTimer
8891
JLabel testCounterValueLabel
8992
JLabel errorCounterValueLabel
9093
JLabel failureCounterValueLabel
@@ -360,6 +363,7 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
360363
resetDerived
361364
val item = new ComboBoxItem<String, String>(currentRun.reporterId, currentRun.name)
362365
runComboBox.selectedItem = item
366+
elapsedTimeTimer.start
363367
}
364368
}
365369

@@ -765,7 +769,7 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
765769
toolbar.add(clearButton)
766770
c.gridx = 0
767771
c.gridy = 0
768-
c.gridwidth = 1
772+
c.gridwidth = 2
769773
c.gridheight = 1
770774
c.insets = new Insets(0, 0, 0, 0) // top, left, bottom, right
771775
c.anchor = GridBagConstraints::NORTH
@@ -780,12 +784,42 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
780784
c.gridy = 1
781785
c.gridwidth = 1
782786
c.gridheight = 1
783-
c.insets = new Insets(10, 10, 10, 10) // top, left, bottom, right
787+
c.insets = new Insets(10, 10, 10, 0) // top, left, bottom, right
784788
c.anchor = GridBagConstraints::WEST
785789
c.fill = GridBagConstraints::HORIZONTAL
786790
c.weightx = 1
787791
c.weighty = 0
788792
basePanel.add(statusLabel, c)
793+
elapsedTimeLabel = new JLabel
794+
elapsedTimeLabel.preferredSize = new Dimension(60, 0)
795+
c.gridx = 1
796+
c.gridy = 1
797+
c.gridwidth = 1
798+
c.gridheight = 1
799+
c.insets = new Insets(10, 10, 10, 10) // top, left, bottom, right
800+
c.anchor = GridBagConstraints::WEST
801+
c.fill = GridBagConstraints::NONE
802+
c.weightx = 0
803+
c.weighty = 0
804+
basePanel.add(elapsedTimeLabel, c)
805+
elapsedTimeTimer = new Timer(100, new ActionListener() {
806+
override actionPerformed(ActionEvent e) {
807+
if (currentRun !== null && currentRun.start !== null) {
808+
val time = new SmartTime
809+
time.smart = useSmartTimes
810+
if (currentRun.executionTime !== null) {
811+
time.seconds = currentRun.executionTime
812+
elapsedTimeTimer.stop
813+
} else {
814+
val long now = System.currentTimeMillis
815+
time.seconds = new Double(now - currentRun.start) / 1000
816+
}
817+
elapsedTimeLabel.text = '''«time.toString»«IF !useSmartTimes» s«ENDIF»'''
818+
} else {
819+
elapsedTimeLabel.text = null
820+
}
821+
}
822+
})
789823

790824
// Counters
791825
// - Test counter
@@ -822,7 +856,7 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
822856
// - add everything to basePanel
823857
c.gridx = 0
824858
c.gridy = 2
825-
c.gridwidth = 1
859+
c.gridwidth = 2
826860
c.gridheight = 1
827861
c.insets = new Insets(5, 0, 5, 0) // top, left, bottom, right
828862
c.anchor = GridBagConstraints::WEST
@@ -854,7 +888,7 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
854888
progressBar.UI = new BasicProgressBarUI
855889
c.gridx = 0
856890
c.gridy = 3
857-
c.gridwidth = 1
891+
c.gridwidth = 2
858892
c.gridheight = 1
859893
c.insets = new Insets(10, 10, 10, 10) // top, left, bottom, right
860894
c.anchor = GridBagConstraints::WEST
@@ -1206,7 +1240,7 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
12061240
horizontalSplitPane.resizeWeight = 0.5
12071241
c.gridx = 0
12081242
c.gridy = 4
1209-
c.gridwidth = 1
1243+
c.gridwidth = 2
12101244
c.gridheight = 1
12111245
c.insets = new Insets(10, 10, 10, 10) // top, left, bottom, right
12121246
c.anchor = GridBagConstraints::WEST

sqldev/src/main/java/org/utplsql/sqldev/ui/runner/SmartTime.xtend

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SmartTime {
3131
this.smart = smart
3232
}
3333

34-
def setMillis(Double seconds) {
34+
def setSeconds(Double seconds) {
3535
this.seconds = seconds
3636
}
3737

sqldev/src/main/resources/org/utplsql/sqldev/resources/UtplsqlResources.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ RUNNER_WARNINGS_LABEL=Warnings
8585
RUNNER_INFO_LABEL=Info
8686
RUNNER_INITIALIZING_TEXT=Initializing...
8787
RUNNER_RUNNING_TEXT=Running tests...
88-
RUNNER_FINNISHED_TEXT=Finished after %.3f seconds.
88+
RUNNER_FINNISHED_TEXT=Finished.
8989
RUNNER_NO_TESTS_FOUND_TEXT=No tests found.
9090
RUNNER_RUN_MENUITEM=Run test
9191
RUNNER_RUN_WORKSHEET_MENUITEM=Run test in new worksheet

sqldev/src/main/resources/org/utplsql/sqldev/resources/UtplsqlResources_de.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ RUNNER_WARNINGS_LABEL=Warnungen
6262
RUNNER_INFO_LABEL=Info
6363
RUNNER_INITIALIZING_TEXT=Initialisierung...
6464
RUNNER_RUNNING_TEXT=Starte Tests...
65-
RUNNER_FINNISHED_TEXT=Beendet nach %.3f Sekunden.
65+
RUNNER_FINNISHED_TEXT=Beendet.
6666
RUNNER_NO_TESTS_FOUND_TEXT=Keine Tests gefunden.
6767
RUNNER_RUN_MENUITEM=Run testTest ausführen
6868
RUNNER_RUN_WORKSHEET_MENUITEM=Test in neuem Arbeitsblatt ausführuen

sqldev/src/test/java/org/utplsql/sqldev/test/runner/UtplsqlRunnerPanelTest.xtend

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ class UtplsqlRunnerPanelTest {
8888
run.counter.success = run.counter.success + 1
8989
run.status="utplsql.test.e"
9090
val end = System.currentTimeMillis
91-
run.status = String.format(UtplsqlResources.getString("RUNNER_FINNISHED_TEXT"), new Double(end-start)/1000)
91+
run.executionTime = new Double(end-start)/1000
92+
run.status = UtplsqlResources.getString("RUNNER_FINNISHED_TEXT")
9293
panel.update(run.reporterId)
9394
Thread.sleep(2000);
9495
frame.dispose

0 commit comments

Comments
 (0)