test.sh (3844B)
1 #!/bin/sh 2 3 echo "Setup:" 4 5 make > /dev/null 6 7 [ -d testinput/ ] || mkdir testinput 8 [ -d testinput/subfolder ] || mkdir testinput/subfolder 9 [ -d testoutput/ ] || mkdir testoutput 10 [ -d testoutput/subfolder ] || mkdir testoutput/subfolder 11 12 echo "<p> 13 <h1>h1</h1> 14 <li> 15 <ul>thing</ul> 16 <ul>thing2</ul> 17 <ul>thing3</ul> 18 <!-- Start Substitute - HTML_Test --> 19 <ul>one line</ul> 20 <ul>two line</ul> 21 <!-- End Substitute --> 22 <ul>thing6</ul> 23 </ul> 24 </p> 25 " > testinput/test.html 26 27 echo "bind -n C-Tab select-window -n 28 bind -n C-BTab select-window -p 29 # Start Substitute - tmux_Test 30 set -g mouse on 31 # End Substitute 32 set -g escape-time 0 33 34 # Start Substitute - Other 35 option 1 36 option 2 37 option 3 38 # End Substitute 39 option 4 40 option 5 41 " > testinput/subfolder/tmux.conf 42 43 ./sub save test.html testinput/ testinput/test.html << EOF 44 sub1 45 EOF 46 echo "" 47 sed 's/two line/other line/g' testinput/test.html > /tmp/out && mv /tmp/out testinput/test.html 48 ./sub save test.html testinput/ testinput/test.html << EOF 49 sub_2 50 EOF 51 echo "" 52 53 ./sub save tmux.conf testinput/subfolder testinput/subfolder/tmux.conf << EOF 54 mouse_on 55 other_sub 56 EOF 57 echo "" 58 sed 's/mouse on/mouse off/g' testinput/subfolder/tmux.conf > /tmp/out && mv /tmp/out testinput/subfolder/tmux.conf 59 ./sub save tmux.conf testinput/subfolder testinput/subfolder/tmux.conf << EOF 60 mouse_off 61 EOF 62 echo "" 63 64 ./sub clean test.html testinput/ testinput/test.html testinput/test_clean.html 65 ./sub clean tmux.conf testinput/subfolder testinput/subfolder/tmux.conf testinput/subfolder/tmux_clean.conf 66 67 ./sub make test.html testinput/ testinput/test_clean.html testoutput/test_out.html << EOF 68 2 69 EOF 70 echo "" 71 ./sub make tmux.conf testinput/subfolder testinput/subfolder/tmux_clean.conf testoutput/subfolder/tmux_out.conf << EOF 72 1 73 1 74 EOF 75 echo "" 76 echo "" 77 78 79 echo "Tests:" 80 echo "No output = all tests passed" 81 82 echo " <!-- Start Substitute - HTML_Test --> 83 <ul>one line</ul> 84 <ul>two line</ul> 85 <!-- End Substitute -->" > /tmp/testfile 86 diff /tmp/testfile testinput/HTML_Test-Substitution-sub1-test.html 87 echo " <!-- Start Substitute - HTML_Test --> 88 <ul>one line</ul> 89 <ul>other line</ul> 90 <!-- End Substitute -->" > /tmp/testfile 91 diff /tmp/testfile testinput/HTML_Test-Substitution-sub_2-test.html 92 93 echo "# Start Substitute - tmux_Test 94 set -g mouse on 95 # End Substitute" > /tmp/testfile 96 diff /tmp/testfile testinput/subfolder/tmux_Test-Substitution-mouse_on-tmux.conf 97 echo "# Start Substitute - tmux_Test 98 set -g mouse off 99 # End Substitute" > /tmp/testfile 100 diff /tmp/testfile testinput/subfolder/tmux_Test-Substitution-mouse_off-tmux.conf 101 102 echo "# Start Substitute - Other 103 option 1 104 option 2 105 option 3 106 # End Substitute" > /tmp/testfile 107 diff /tmp/testfile testinput/subfolder/Other-Substitution-other_sub-tmux.conf 108 109 echo "<p> 110 <h1>h1</h1> 111 <li> 112 <ul>thing</ul> 113 <ul>thing2</ul> 114 <ul>thing3</ul> 115 <!-- Start Substitute - HTML_Test --> 116 <ul>thing6</ul> 117 </ul> 118 </p> 119 " > /tmp/testfile 120 diff /tmp/testfile testinput/test_clean.html 121 echo "bind -n C-Tab select-window -n 122 bind -n C-BTab select-window -p 123 # Start Substitute - tmux_Test 124 set -g escape-time 0 125 126 # Start Substitute - Other 127 option 4 128 option 5 129 " > /tmp/testfile 130 diff /tmp/testfile testinput/subfolder/tmux_clean.conf 131 echo "<p> 132 <h1>h1</h1> 133 <li> 134 <ul>thing</ul> 135 <ul>thing2</ul> 136 <ul>thing3</ul> 137 <!-- Start Substitute - HTML_Test --> 138 <ul>one line</ul> 139 <ul>other line</ul> 140 <!-- End Substitute --> 141 <ul>thing6</ul> 142 </ul> 143 </p> 144 " > /tmp/testfile 145 diff /tmp/testfile testoutput/test_out.html 146 147 echo "bind -n C-Tab select-window -n 148 bind -n C-BTab select-window -p 149 # Start Substitute - tmux_Test 150 set -g mouse off 151 # End Substitute 152 set -g escape-time 0 153 154 # Start Substitute - Other 155 option 1 156 option 2 157 option 3 158 # End Substitute 159 option 4 160 option 5 161 " > /tmp/testfile 162 diff /tmp/testfile testoutput/subfolder/tmux_out.conf 163 164 make clean > /dev/null 165 rm -rf testinput/ 166 rm -rf testoutput/