Batch testing: a lab1 directory of test cases and a batch test file (as discussed in class May 11th)
can be found here: lab1 repo.
To run the test cases enter the command bash batchtest |
If you've taken 161 in the past then you probably already have a csci161
directory. You're not going to want to mix up this year's 161 stuff with the old stuff,
so before you mkdir csci161 I'd suggest doing something like mv csci161 old161 |
0. double-check that the instructor has posted the repo
Run the command below, and check to make sure that the csci 161 lab1
repository appears in the list (if it isn't posted yet then don't proceed yet)
ssh -x csci info
This lists all the repositories you currently have access to, and the one you're specifically looking for will look like csci161/lab1.
A WARNING AGAINST TRYING THE REMAINING STEPS BEFORE YOUR LAB SESSION:
none of the remaining lab instructions will work correctly until the repository
has been set up by the instructor, which may not happen until the day of the lab
1. create the server-side copy of the repo
To do this, enter the following command:
ssh -x csci fork csci161/lab1 csci161/$USER/lab1
($USER will automatically get replaced by your linux userid)
You can check if this worked correctly by running the ssh -x csci info command
again, and it should now show an additional repository:
csci161/yourusername/lab1
2. clone your own local working copy
If you haven't previously done so, you'll want to create a csci161 directory
in your home directory, i.e.
cd
mkdir csci161
cd csci161
now clone your server-side copy, creating a working lab1 repository here
git clone csci:csci161/$USER/lab1
We can check if this has been successful by entering our lab1 directory and checking which files are present:
cd lab1 lsThis should show lab1.cpp, lab1.h, makefile, and README
3. compile/run the skeleton, and try a git push
We'll use the supplied makefile to compile the files and create a lab1x executable:
make
That will thow a lot of warnings about unused parameters (since the functions
are mostly empty so far), but it should compile and create a lab1x executable.
You can check that using ls, then try running it:
./lab1x
The initial lab1.cpp is pretty much just a simple main routine to get an array of words from the user, sort them, and print the results using five functions. Skeletal versions of each of the functions are provided, the implementations are to be completed by you. You'll be working on the lab1.cpp content in step 4 below.
We'll try submitting your repository, just to make sure everything has been set up correctly:
git add lab1.cpp git add lab1x git commit -m "compiled the original lab1" git push(The commit will produce a couple of lines of messages about how many files were changed leading up to the commit and the create mode for lab1x.
This will have copied your work back to the server where the instructor can access/mark it. You can repeat this cycle as often as you like, each time it sends the updated content. (Thus the instructor will always have your most up to date version for marking.)
If anything goes wrong see step 5 at the bottom of this page for some basic trouble-shooting, and if that doesn't solve the problem then talk to your instructor for help.
4. complete the lab1.cpp file as per specifications
Now we finally get into the actual programming details for lab1.
The specifications for lab1.cpp are as follows:
Be sure you read, understand, and follow the code standards for CSCI 161, as they will most likely be different than the standards you were given in your CSCI 159/160 course. Marks will be deducted for failing to follow standards.
I also strongly recommend that after each successful modification of your .cpp program you perform the following two commands:
git add lab1.cpp git commit -m "some message describing the changes you just made"These use git to take and store a snapshot of your latest set of changes, which will subsequently allow you to roll back to the current state of your code if you ever need to (e.g. if you accidentally trash your lab1.cpp file later, or make changes you wish to undo).
A sample run of the program is shown below. (For the sake of clarity in the example, user input is shown in bold italics - this is of course not something your program actually could/would do.)
Please enter the desired number of words for your dictionary (max 100) Please enter an integer in the range 1..100 foo Sorry, foo is not an integer, please try again Please enter an integer in the range 1..100 -1 Sorry, 4294967295 is not in the range 1..100, please try again Please enter an integer in the range 1..100 101 Sorry, 101 is not in the range 1..100, please try again Please enter an integer in the range 1..100 0 Sorry, 0 is not in the range 1..100, please try again Please enter an integer in the range 1..100 5 Please enter a word that is 3 to 10 characters long blah Please enter a word that is 3 to 10 characters long ick Please enter a word that is 3 to 10 characters long abcdefghij Please enter a word that is 3 to 10 characters long me Sorry, me is not of a valid length, please try again Please enter a word that is 3 to 10 characters long trythisword Sorry, trythisword is not of a valid length, please try again Please enter a word that is 3 to 10 characters long ok123 Please enter a word that is 3 to 10 characters long 123456 The 5 words in the dictionary are: 123456 abcdefghij blah ick ok123 |
5. add, commit, and push your finished lab back to the git server
We'll perform two git adds to ensure git has tracked your changes to lab1.cpp and lab1x,
and a git commit to take a snapshot of the current repository state:
git add lab1.cpp git add lab1x git commit -m "lab1 complete"Finally we need to push all your updates to the server for marking:
Note that if you forget any of those steps (the adds, commit, or push) then the changes you made will not reach the instructor for marking.
If you're ever in doubt about the current state of your repository you can run the command git status, which should eventually give a message like "up-to-date with origin master". Here are the most common other messages it may give you:
What to do if, on a push, you get an error like this:
FATAL: W any csci161/lab1 yourusername DENIED by fallthru (or you mis-spelled the reponame) fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.Note the push should be trying to go to "csci161/yourusername/lab1", not to "csci161/lab1" (which is the instructor repo), so this error message suggests that in step 2 you may have cloned the wrong repo, e.g. you may have done git clone csci:csci161/lab1 instead of the correct git clone csci:csci161/$USER/lab1 thus now in step 5 when you push it's trying to overwrite the instructor's version, so is giving you that permission error.
It's not an uncommon mistake, and easily fixed.
We need your lab1 repo to think it was cloned from *your* space
on the git server, not from the instructor's, so we'll reset where
your repository thinks it came from using the following command:
After that, you should be able to push normally. If you ever want to completely start over:
|