One of the most frustrating aspects of programming is just setting up the development environment. When you want to share your code, as in a team, and make sure it runs on other computers, this becomes even more of a problem. One solution that has become popular in the profession is virtualization, running a program that simulates a computer that runs software, usually another operating system. This simulation is called a virtual machine.
This concerns you as a student since you want to be sure the code you turn in can be graded fairly. As an instructor, I have the same concern, but I also want to get feedback and grades back to you as soon as possible with minimal back-and-forth. To solve this we will use a virtual machine so that you can verify that your code works on the exact same (virtual) system we will grade it in.
We will use two tools for this (that you should have installed during Exercise 01), VirtualBox, which runs the virtual machine, and Vagrant which automates creating and provisioning (installing all the software for) a virtual machine. The virtual machine we will use is based on a minimal Linux environment so there are no licensing issues.
The goal of this exercise is to learn how to use Vagrant to setup and use the reference environment, including how to build the starter code for the course project.
Prerequisites:
Exercise 01: Setup
and have a working installation of VirtualBox and VagrantSteps:
Clone the plotscript project after accepting the GitHub invitation at this link.
git clone https://github.com/VTECE3574/plotscript-USER.git
where USER is your GitHub username. You may have to enter your GitHub username and password.
Change to the repository directory and run vagrant to setup the virtual machine.
vagrant up
This will take a several minutes to complete.
After step 3 completes. Halt the VM using:
vagrant halt
This is how you stop the reference environment, but leave it ready to start up again.
Restart the VM using step 3 again. You should now see a graphical window.
Open a command line in the VM window by right clicking and selecting Terminal emulator.
See what directory you are in
pwd
You are in the /home/vagrant directory. This is the home directory for the default user setup by Vagrant. Feel free to just remove the default directories created using rm -r *
.
List the files in the host operating system shared with the machine.
ls /vagrant
You should see the files from the cloned repsitory.
Build the starter code using cmake.
cmake /vagrant
Then
cmake --build .
or just
make
Run the plotscript executable
./plotscript
It should start the REPL. Experiment with a few expressions. Type Cntl-D
to exit the REPL.
On your host machine, create a file in the tests subdirectory of the repository named exercise03.pls
and type in some plotscript code. Save the file.
Back in the reference environment execute your example using
./plotscript /vagrant/tests/exercise03.pls
You should see the expected output.
Go back to your host command line and halt the machine.
vagrant halt
When you no longer need the machine or want to recreate it from scratch, you can destroy it.
vagrant destroy
It prompts you to be sure.
Now, use git to commit the source file you changed to the local repository.
git add tests/exercies03.pls
git commit -m "Added a testing file."
Finally, use git push to synchronize the repository with that on GitHub
git push
You may have to enter your GitHub username and password.
You have completed the Exercise.
This is the basic process for verifying your code works as you expect in the grading environment. It also demonstrates how to make changes to your project repository and record them using git and GitHub.