Skip to content

Commit a2a8e6e

Browse files
committed
Tests: Drop ExecuteSweepFormulaInDB and prefer ExecuteSweepFormulaCode
We don't need two functions doing basically the same. So teach ExecuteSweepFormulaCode to also check the success/error state and use that instead.
1 parent 2530457 commit a2a8e6e

File tree

4 files changed

+27
-31
lines changed

4 files changed

+27
-31
lines changed

Packages/tests/Basic/UTF_SweepFormula.ipf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,7 +2051,7 @@ static Function TestVariablePlottingDoesNotModifyData()
20512051
graphBase = BSP_GetFormulaGraph(win)
20522052
graph = graphBase + "_#Graph" + "0"
20532053

2054-
ExecuteSweepFormulaInDB(code, win)
2054+
ExecuteSweepFormulaCode(win, code)
20552055
REQUIRE_EQUAL_VAR(WindowExists(graph), 1)
20562056

20572057
WAVE/WAVE varStorage = GetSFVarStorage(win)
@@ -2077,7 +2077,7 @@ static Function TestVariablePlottingDifferentSubsequentBaseTypes()
20772077
graphBase = BSP_GetFormulaGraph(win)
20782078
graph = graphBase + "_#Graph" + "0"
20792079

2080-
ExecuteSweepFormulaInDB(code, win)
2080+
ExecuteSweepFormulaCode(win, code)
20812081
REQUIRE_EQUAL_VAR(WindowExists(graph), 1)
20822082
WAVE/WAVE varStorage = GetSFVarStorage(win)
20832083
WAVE/WAVE dataRef = SFH_AttemptDatasetResolve(WaveText(WaveRef(varStorage, row = FindDimLabel(varStorage, ROWS, "data")), row = 0))
@@ -2090,7 +2090,7 @@ static Function TestVariablePlottingDifferentSubsequentBaseTypes()
20902090
Make/N=3 root:testData = p
20912091

20922092
code = "data=wave(root:testData)\r$data"
2093-
ExecuteSweepFormulaInDB(code, win)
2093+
ExecuteSweepFormulaCode(win, code)
20942094

20952095
WAVE/WAVE varStorage = GetSFVarStorage(win)
20962096
WAVE/WAVE dataRef = SFH_AttemptDatasetResolve(WaveText(WaveRef(varStorage, row = FindDimLabel(varStorage, ROWS, "data")), row = 0))
@@ -2114,7 +2114,7 @@ static Function TestVariableReadOnly()
21142114
Make/N=100 root:testData = p + offset
21152115

21162116
code = "data=wave(root:testData)\rpowerspectrum($data)"
2117-
ExecuteSweepFormulaInDB(code, win)
2117+
ExecuteSweepFormulaCode(win, code)
21182118

21192119
WAVE/WAVE varStorage = GetSFVarStorage(win)
21202120
WAVE/WAVE dataRef = SFH_AttemptDatasetResolve(WaveText(WaveRef(varStorage, row = FindDimLabel(varStorage, ROWS, "data")), row = 0))
@@ -2144,7 +2144,7 @@ static Function TestKeepsUnitsWhenMappingMultipleYToOne()
21442144
SetScale/P y, 0, 1, "y2", data2
21452145

21462146
code = "dataset(wave(data1), wave(data1)) vs dataset(wave(data2))"
2147-
ExecuteSweepFormulaInDB(code, win)
2147+
ExecuteSweepFormulaCode(win, code)
21482148
yAxis = AxisLabel(graph, "left")
21492149
CHECK_EQUAL_STR(yAxis, "(y1)")
21502150
xAxis = AxisLabel(graph, "bottom")
@@ -2175,7 +2175,7 @@ static Function TestAxisLabelGathering()
21752175
code = "wave(data1)\r" + \
21762176
"with \r" + \
21772177
"wave(data2) vs wave(data3)\r"
2178-
ExecuteSweepFormulaInDB(code, win)
2178+
ExecuteSweepFormulaCode(win, code)
21792179
yAxis = AxisLabel(graph, "left")
21802180
CHECK_EQUAL_STR(yAxis, "(y1) / (y2)")
21812181
xAxis = AxisLabel(graph, "bottom")

Packages/tests/Basic/UTF_SweepFormula_Operations.ipf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ static Function StoreChecksParameters([string str])
175175

176176
win = GetDataBrowserWithData()
177177

178-
CHECK(!ExecuteSweepFormulaInDB(str, win))
178+
ExecuteSweepFormulaCode(win, str, expectFailure = 1)
179179

180180
WAVE textualResultsValues = GetLogbookWaves(LBT_RESULTS, LBN_TEXTUAL_VALUES)
181181
CHECK_EQUAL_VAR(GetNumberFromWaveNote(textualResultsValues, NOTE_INDEX), 0)
@@ -194,7 +194,7 @@ static Function StoreWorks([WAVE wv])
194194
ref = "store(\"ABCD\", " + JSON_Dump(array) + " ) vs 0"
195195
JSON_Release(array)
196196

197-
CHECK(ExecuteSweepFormulaInDB(ref, win))
197+
ExecuteSweepFormulaCode(win, ref)
198198

199199
WAVE textualResultsValues = GetLogbookWaves(LBT_RESULTS, LBN_TEXTUAL_VALUES)
200200

@@ -240,7 +240,7 @@ static Function StoreWorksWithMultipleDataSets()
240240
[numSweeps, numChannels, WAVE/U/I channels] = FillFakeDatabrowserWindow(win, device, XOP_CHANNEL_TYPE_ADC, textKey, textValue)
241241

242242
str = "store(\"ABCD\", data(select(selrange(), selchannels(), selsweeps())))"
243-
CHECK(ExecuteSweepFormulaInDB(str, win))
243+
ExecuteSweepFormulaCode(win, str)
244244

245245
WAVE textualResultsValues = GetLogbookWaves(LBT_RESULTS, LBN_TEXTUAL_VALUES)
246246

@@ -3257,7 +3257,7 @@ static Function TPWithModelCell()
32573257

32583258
win = DB_GetBoundDataBrowser(device)
32593259

3260-
CHECK(ExecuteSweepFormulaInDB("store(\"inst\",tp(tpinst()))\n and \nstore(\"ss\",tp(tpss()))", win))
3260+
ExecuteSweepFormulaCode(win, "store(\"inst\",tp(tpinst()))\n and \nstore(\"ss\",tp(tpss()))")
32613261

32623262
WAVE textualResultsValues = GetLogbookWaves(LBT_RESULTS, LBN_TEXTUAL_VALUES)
32633263

Packages/tests/Basic/UTF_SweepFormula_PSX.ipf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2886,7 +2886,7 @@ static Function NoEventsAtAll()
28862886

28872887
code = "psx(psxKernel(select(selrange([50, 150]), selchannels(AD6), selsweeps([0, 2]), selvis(all))), 100, 100, 0)"
28882888

2889-
win = ExecuteSweepFormulaCode(browser, code)
2889+
win = ExecuteSweepFormulaCode(browser, code, expectFailure = 1)
28902890

28912891
try
28922892
psxGraph = MIES_PSX#PSX_GetPSXGraph(win)

Packages/tests/UTF_HelperFunctions.ipf

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,24 +1542,6 @@ static Function CompareEpochsHistoricChannel(WAVE/T epochChannelRef, WAVE/T epoc
15421542
endfor
15431543
End
15441544

1545-
Function ExecuteSweepFormulaInDB(string code, string win)
1546-
1547-
string sfFormula, bsPanel
1548-
variable errorSeverity
1549-
1550-
bsPanel = BSP_GetPanel(win)
1551-
1552-
sfFormula = BSP_GetSFFormula(win)
1553-
ReplaceNotebookText(sfFormula, code)
1554-
1555-
PGC_SetAndActivateControl(bsPanel, "check_BrowserSettings_SF", val = CHECKBOX_SELECTED)
1556-
PGC_SetAndActivateControl(bsPanel, "button_sweepFormula_display")
1557-
1558-
errorSeverity = ROVar(GetSweepFormulaOutputSeverity())
1559-
1560-
return errorSeverity == SF_MSG_OK
1561-
End
1562-
15631545
/// @brief test two jsonIDs for equal content
15641546
Function CHECK_EQUAL_JSON(variable jsonID0, variable jsonID1)
15651547

@@ -1733,9 +1715,16 @@ Function LoadMIESFolderFromPXP(string fName)
17331715
End
17341716

17351717
/// @brief Execute the given SweepFormula code in the browser and return the formula graph
1736-
Function/S ExecuteSweepFormulaCode(string browser, string code)
1718+
Function/S ExecuteSweepFormulaCode(string browser, string code, [variable expectFailure])
1719+
1720+
string bsPanel
1721+
variable errorSeverity
17371722

1738-
string bsPanel
1723+
if(ParamIsDefault(expectFailure))
1724+
expectFailure = 0
1725+
else
1726+
expectFailure = !!expectFailure
1727+
endif
17391728

17401729
SF_SetFormula(browser, code)
17411730

@@ -1744,6 +1733,13 @@ Function/S ExecuteSweepFormulaCode(string browser, string code)
17441733
PGC_SetAndActivateControl(bsPanel, "check_BrowserSettings_SF", val = 1)
17451734
PGC_SetAndActivateControl(bsPanel, "button_sweepFormula_display", val = NaN)
17461735

1736+
errorSeverity = ROVar(GetSweepFormulaOutputSeverity())
1737+
if(expectFailure)
1738+
CHECK_EQUAL_VAR(errorSeverity, SF_MSG_ERROR)
1739+
else
1740+
CHECK_EQUAL_VAR(errorSeverity, SF_MSG_OK)
1741+
endif
1742+
17471743
return SFH_GetFormulaGraphForBrowser(browser)
17481744
End
17491745

0 commit comments

Comments
 (0)