Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
126 lines (96 sloc) 3.18 KB
---
title: Code Testing
layout: default
---
<p>The easiest way is to use the tests built into 'make'. See
<a href="https://github.com/theimpossibleastronaut/rmw/tree/master/test">test/README</a>
for instructions. To learn the "inner-workings" of rmw, continue
reading this page.</p>
<h3>Method 1</h3>
<p>By default (specified in the config file) rmw will not perform
operations on your regular Trash folder; the configuration option for
that is</p>
<p class="w3-panel">$HOME/.trash.rmw</p>
<p>rmw will create that folder and your personal configuration file
($HOME/.config/rmw/config) the first time it's run.</p>
<p>One method of testing is to change the HOME environmental variable
at run time. At the command line, use:</p>
<p class="w3-panel">
HOME=$PWD rmw
</p>
<p>(use `./rmw` if the program is not yet in your PATH)</p>
<p>rmw would detect your home directory as your present working directory,
and would create the necessary directories. Now create a blank file:
</p>
<p class="w3-panel">
touch tempfile
</p>
<p>And then remove it to your temporary rmw trash folder:</p>
<p class="w3-panel">
HOME=$PWD rmw tempfile
</p>
<p>
tempfile would be moved to $PWD/.trash.rmw/files, and a `.trashinfo`
file will be created in $PWD/.trash.rmw/info. The format of the
.trashinfo file is the same that your Desktop trash uses:
</p>
<p class="w3-panel">
[Trash Info]
Path=/home/andy/src/rmw/tempfile
DeletionDate=2017-11-17T13:44:04a
</p>
<p>Now try</p>
<p class="w3-panel">
HOME=$PWD rmw -u
</p>
<p>You'll see that tempfile has been restored to its original
location.</p>
<h3>Method 2</h3>
<p>The following method is a little more complex</p>
<p>In rmw.h, change DATA_DIR</p>
<p class="w3-panel">
`#define DATA_DIR "/testing/.config/testrmw"`
</p>
<p>Then build it.</p>
<p>Run the rebuilt binary to create that folder. Then copy '/etc/rmwrc'
(if it's not there, try /usr/local/etc/ or the rmw source directory
(./etc)) into it, and rename the newly-placed 'rmwrc' to 'config'.</p>
<p>Add a WASTE folder to the top of 'config', such as
WASTE=$HOME/testing/.local/share/Trash.test</p>
<p>Comment out any other WASTE folders.</p>
<p class="w3-panel">
`~: mkdir $HOME/testing/.local/share/Trash.test`
</p>
<p class="w3-panel w3-yellow">
Copy all the files from your regular Trash into the test folder:
</p>
<p class="w3-panel">
cd $HOME/testing/.local/share/Trash.test<br />
cp -a $HOME/.local/share/Trash/* .
</p>
<p>Now run 'ls'. You should see 2 directories: files, info</p>
<p>Now 'cd' back to $HOME/testing</p>
<p>Create some unnecessary files.</p>
<p class="w3-panel">
touch {a..z}
</p>
<p>will create 26 empty files, a-z.</p>
<p class="w3-panel">
`touch {1..10}`
</p>
<p>will create 10 empty files, 1-10</p>
<p>
You can now use 'rmw' on these files, or copy real files and
directories into ~/testing to try it out.
</p>
<h3>Testing the purge feature</h3>
<p>Setting the RMWTRASH environmental variable at run-time to "fake-year"
will write the year 1999 to the DeletionDate string in the .trashinfo
file.</p>
<p class="w3-panel">
RMWTRASH=fake-year rmw some.txt temp.asc files.doc
</p>
<p>Then run rmw with the purge option</p>
<p class="w3-panel">
rmw -fg
</p>