Skip to content

Commit

Permalink
Fix regression in #70 (#72)
Browse files Browse the repository at this point in the history
Fix regression in #70
Fix wording in readme
Add midi sequence test
Allow testing a single rks file
  • Loading branch information
myrrc committed Jul 23, 2024
1 parent dbf46d3 commit 7cafe05
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 19 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ a # add fx
<ESC> # close fx window
im # insert midi item
<Space>so # open in midi editor
0 # get to item start
0 # jump to project start
a # add note and select it
5p # paste 5 more notes (last one is selected)
NN # select two more previous notes
Expand Down Expand Up @@ -159,7 +159,6 @@ chmod +x prepare copy-configs test

If you don't use X11 you can have a look at `.github/workflows/wf.yml` to see how x11 is
emulated with Xvfb.
Use `./test -s` to skip first invocation which bypasses "Still evaluating" window.

### Writing tests

Expand Down
1 change: 1 addition & 0 deletions internal/gui/feedback/controller.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function feedback.displayState(state)
and string_util.format("(rec %s..)", state['macro_register'])
or ""
model.setKeys({ right_text = right_text, mode = state['mode'] })
feedback.update()
end

function feedback.clear()
Expand Down
17 changes: 11 additions & 6 deletions internal/state_machine/state_machine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ end
local function input()
local _, _, section_id, _, _, _, _, ctx = reaper.get_action_context()
if ctx == "" then return end
local main_ctx = section_id == 0
---@type KeyPress
local hotkey = { context = section_id == 0 and "main" or "midi", key = ctxToState(ctx) }
local hotkey = { context = main_ctx and "main" or "midi", key = ctxToState(ctx) }

log.info("Input: " .. format.line(hotkey))
if config.show_feedback_window then feedback.clear() end
Expand All @@ -138,15 +139,19 @@ local function input()
if not config.show_feedback_window then return end

feedback.displayState(new_state)
feedback.update()

-- This works only when window is docked, nothing we can do otherwise
local defocus_window = section_id == 0
and actions.FocusTracks or actions.FocusMidiEditor
-- If window is floating, it's controlled by WM so we can't always defocus it
if not config.dock_feedback_window then return end

local defocus_window = main_ctx and actions.FocusTracks or actions.FocusMidiEditor
reaper.Main_OnCommand(reaper.NamedCommandLookup(defocus_window), 0)

-- When we insert track with feedback window closed, it steals focus and track is not renamed
if hotkey.key:lower() == "o" then reaper.Main_OnCommand(actions.RenameTrack, 0) end
if not main_ctx or not new_state or new_state.key_sequence ~= "" then return end
if not hotkey.key:lower():match "o" then return end
local keys = new_state.last_command.action_keys
if #keys ~= 1 or not keys[1]:match "^EnterTrack" then return end
reaper.Main_OnCommand(actions.RenameTrack, 0)
end

return input
2 changes: 1 addition & 1 deletion tests/compare
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from pathlib import Path
from sys import argv
left_file, right_file = Path(argv[1]).read_text(), Path(argv[2]).read_text()
out = 0
ignored_keys = ["<TRACK", "TRACKID", "EGUID", "FIXEDLANES"]
ignored_keys = Path("ignored_keys").read_text().split()

# skip project declaration
for left, right in zip(left_file.split("\n")[1:], right_file.split("\n")[1:]):
Expand Down
13 changes: 13 additions & 0 deletions tests/ignored_keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<TRACK
AUTOXFADE
CFGEDITVIEW
CURSOR
EGUID
FIXEDLANES
GUID
IGUID
POOLEDEVTS
SEL
TRACKID
VELLANE
CFGEDIT
165 changes: 165 additions & 0 deletions tests/midi-sequence.RPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<REAPER_PROJECT 0.1 "7.18/linux-x86_64" 1721777320
<NOTES 0 2
>
RIPPLE 0
GROUPOVERRIDE 0 0 0
AUTOXFADE 1
ENVATTACH 3
POOLEDENVATTACH 0
MIXERUIFLAGS 11 48
ENVFADESZ10 40
PEAKGAIN 1
FEEDBACK 0
PANLAW 1
PROJOFFS 0 0 0
MAXPROJLEN 0 0
GRID 3199 8 1 8 1 0 0 0
TIMEMODE 1 5 -1 30 0 0 -1
VIDEO_CONFIG 0 0 256
PANMODE 3
PANLAWFLAGS 3
CURSOR 0.75
ZOOM 100 0 0
VZOOMEX 6 0
USE_REC_CFG 0
RECMODE 1
SMPTESYNC 0 30 100 40 1000 300 0 0 1 0 0
LOOP 0
LOOPGRAN 0 4
RECORD_PATH "Media" ""
<RECORD_CFG
ZXZhdxgAAQ==
>
<APPLYFX_CFG
>
RENDER_FILE ""
RENDER_PATTERN ""
RENDER_FMT 0 2 0
RENDER_1X 0
RENDER_RANGE 1 0 0 18 1000
RENDER_RESAMPLE 3 0 1
RENDER_ADDTOPROJ 0
RENDER_STEMS 0
RENDER_DITHER 0
TIMELOCKMODE 1
TEMPOENVLOCKMODE 1
ITEMMIX 1
DEFPITCHMODE 589824 0
TAKELANE 1
SAMPLERATE 44100 0 0
<RENDER_CFG
ZXZhdxgAAQ==
>
LOCK 1
<METRONOME 6 2
VOL 0.25 0.125
FREQ 800 1600 1
BEATLEN 4
SAMPLES "" ""
PATTERN 2863311530 2863311529
MULT 1
>
GLOBAL_AUTO -1
TEMPO 120 4 4
PLAYRATE 1 0 0.25 4
SELECTION 0 0
SELECTION2 0 0
MASTERAUTOMODE 0
MASTERTRACKHEIGHT 0 0
MASTERPEAKCOL 16576
MASTERMUTESOLO 0
MASTERTRACKVIEW 0 0.6667 0.5 0.5 0 0 0 0 0 0 0 0 0 0
MASTERHWOUT 0 0 1 0 0 0 0 -1
MASTER_NCH 2 2
MASTER_VOLUME 1 0 -1 -1 1
MASTER_PANMODE 3
MASTER_PANLAWFLAGS 3
MASTER_FX 1
MASTER_SEL 0
<MASTERPLAYSPEEDENV
EGUID {E8FA64DF-A2AF-3558-B24E-6C62FDE87CE6}
ACT 0 -1
VIS 0 1 1
LANEHEIGHT 0 0
ARM 0
DEFSHAPE 0 -1 -1
>
<TEMPOENVEX
EGUID {06912506-8A9F-8418-E463-5B91B53ABBAC}
ACT 1 -1
VIS 1 0 1
LANEHEIGHT 0 0
ARM 0
DEFSHAPE 1 -1 -1
>
<PROJBAY
>
<TRACK {F34DB8F3-9FD0-C2BC-BA6D-2D935E41FED7}
NAME test
PEAKCOL 16576
BEAT -1
AUTOMODE 0
PANLAWFLAGS 3
VOLPAN 1 0 -1 -1 1
MUTESOLO 0 0 0
IPHASE 0
PLAYOFFS 0 1
ISBUS 0 0
BUSCOMP 0 0 0 0 0
SHOWINMIX 1 0.6667 0.5 1 0.5 0 0 0
FIXEDLANES 9 0 0 0 0
SEL 1
REC 0 0 1 0 0 0 0 0
VU 2
TRACKHEIGHT 0 0 0 0 0 0 0
INQ 0 0 0 0.5 100 0 0 100
NCHAN 2
FX 1
TRACKID {F34DB8F3-9FD0-C2BC-BA6D-2D935E41FED7}
PERF 0
MIDIOUT -1
MAINSEND 1 0
<ITEM
POSITION 0.5
SNAPOFFS 0
LENGTH 2
LOOP 1
ALLTAKES 0
FADEIN 1 0 0 1 0 0 0
FADEOUT 1 0 0 1 0 0 0
MUTE 0 0
SEL 0
IGUID {CBDD15F9-076E-951C-7931-A4A0798B5A11}
IID 1
NAME 01-test-MIDI
VOLPAN 1 0 1 -1
SOFFS 0 0
PLAYRATE 1 1 0 -1 0 0.0025
CHANMODE 0
GUID {E68DB955-2317-5AC4-3F14-8B77DC8000F8}
<SOURCE MIDI
HASDATA 1 960 QN
CCINTERP 32
POOLEDEVTS {33AD4A31-6FC8-383B-ABBC-D29A1E25176A}
E 0 90 3f 60
E 120 80 3f 00
e 240 90 40 60
e 120 80 40 00
E 3360 b0 7b 00
CCINTERP 32
CHASE_CC_TAKEOFFS 1
GUID {AA1FAB4F-5634-A656-78D8-8A30B8A15A4B}
IGNTEMPO 0 120 4 4
SRCCOLOR 0
VELLANE -1 9 0 0 1
CFGEDITVIEW 0 0.226823 24 12 0 -1 0 0 0 0.5
KEYSNAP 0
TRACKSEL 0
EVTFILTER 0 -1 -1 -1 -1 0 0 0 0 -1 -1 -1 -1 0 -1 0 -1 -1
CFGEDIT 1 1 0 1 0 0 1 1 1 1 1 0.125 0 0 1398 1430 0 0 0 0 0 0 0 0 0 0.5 0 0 1 64
>
>
>
<EXTENSIONS
>
>
14 changes: 14 additions & 0 deletions tests/midi-sequence.rks
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
o
test
&Return
0
l
im
b
&space
so
a
2l
k
a
Z
21 changes: 11 additions & 10 deletions tests/test
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
#!/bin/bash
ret=0
[ $# -eq 0 ] && timeout 6 ./reaper/reaper -new -nosplash &>/dev/null # still evaluating
if [ $# -eq 0 ]; then
timeout 6 ./reaper/reaper -new -nosplash &>/dev/null # still evaluating
tests="*.rks"
else
tests=$@
fi

for test in *.rks; do
for test in $tests; do
echo "Running $test"
expected=${test%.rks}.RPP
out=out.RPP

./reaper/reaper -saveas $out -new -nosplash 1>stdout 2>stderr &
./reaper/reaper -saveas $out -new -nosplash &>/dev/null &
pid=$(echo $!)
sleep 1
xdotool search --onlyvisible --all reaper windowfocus
xdotool search --onlyvisible --all reaper windowfocus &>/dev/null

while read cmd; do
if [[ $cmd == "&"* ]]; then
xdotool key "${cmd#&}"
else
xdotool type "$cmd"
fi
sleep .1
done <$test

xdotool type " ps"
Expand All @@ -27,13 +33,8 @@ for test in *.rks; do
./compare $expected $out
diff_ret=$(echo $?)
echo "Test exit code $diff_ret"
echo Stdout:
cat stdout
echo Stderr:
cat stderr

ret=$(( ret + diff_ret ))
rm $out stdout stderr
rm $out
done

exit $ret

0 comments on commit 7cafe05

Please sign in to comment.