Skip to content
Snippets Groups Projects
README.md 5.19 KiB
Newer Older
gilbo's avatar
gilbo committed
CSE 493X Browser Engineering
=============================
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
This repository contains the autograder tests for CSE 493x
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
Using this repository
---------------------
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
In the Github repository we create for you, run:
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
	git submodule update --init
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

Gilbert L Bernstein's avatar
Gilbert L Bernstein committed
This command downloads this repository in the `tests` subdirectory.
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
Throughout the class, we'll likely push new versions of this
repository, to fix bugs or maybe update class-relevant files. You can
update the copy on your computer by running:
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
	git submodule update --remote
	
When you do this, `git diff` or `git commit` or whatever other
commands will show changes to the `.gitmodules` file; those are fine,
go ahead and commit/push them together with any other changes.
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
Try running the `run.py` script. Specifically, from your main
repository run:
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
    $ python3 test/run.py
    
    Summarised results
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
                      chapter1-base-tests.md: passed
         chapter1-exercise-http-1-1-tests.md: passed
        chapter1-exercise-file-urls-tests.md: passed
        chapter1-exercise-redirects-tests.md: passed
          chapter1-exercise-caching-tests.md: passed
    ----------------------------------------------------
                                   Final: all passed
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
The same exact script is run by the autograder in Github Actions.
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
The tests
---------
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

Gilbert L Bernstein's avatar
Gilbert L Bernstein committed
You can find the tests themselves in the `tests/` subdirectory. (Yes, this is `tests/tests/`) The
gilbo's avatar
gilbo committed
`chapterN-base-tests.md` file always contains tests for the base
browser from the book for Chapter N. You should get those passing
first. The `chapterN-exercise-X-tests.md` file contains the tests for
the named exercise. Before doing those, read through the file itself.
It may indicate additional functions you have to implement for testing
(beyond those of the book itself) or have hints, additional rules, or
further explanations. You'll be graded on passing both the `base` and
`exercise` tests.
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
The full list of exercises we plan to assign in CSE 493x are:
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
**Chapter 1**: HTTP/1.1, `file://` URLs, redirects, caching
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
**Chapter 2**: Line breaks, resizing, scrollbar, emoji
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
**Chapter 3**: Centered text, superscripts, soft hyphens, small caps
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
**Chapter 4**: Comments, paragraphs, scripts, quoted attributes
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
**Chapter 5**: Links bar, hidden head, bullets, anonymous block boxes
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
**Chapter 6**: Fonts, width/height, class selectors, shorthand properties
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
**Chapter 7**: Backspace, middle-click, fragments, bookmarks
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
**Chapter 8**: Enter key, GET forms, check boxes, rich buttons
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
**Chapter 9**: `Node.children`, `createElement`, IDs, event bubbling
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
**Chapter 10**: New inputs, certificate errors, script access, referer
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
Note that the exercises assigned for future chapters may change
without notice during the quarter. Italicized exercises don't yet
have tests; they'll be written during the quarter.
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
Running the tests
-----------------
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
When run, the `run.py` script runs all tests for the current
chapter. But there are some additional options that might be handy:
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
The first argument select a specific chapter. For example, `python3
run.py chapter1` runs the tests for the first chapter. You
can use the argument `all` to run all available tests.
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
The first argument can also select a specific exercise. For example,
`python3 run.py chapter1-base` runs the base tests for the
first chapter, while `python3 run.py chapter1-file-urls`
runs tests for the file URLs exercise.
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
The tests themselves are written in Markdown using [doctest][doctest]
to run them. Any failing tests will output the relevant paragraph of
Markdown explanation as well as the expected and actual output. To
help with `print`-debugging, any line of output beginning with `!dbg`
is ignored.
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
[doctest]: https://docs.python.org/3/library/doctest.html
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
The test framework _mocks_ certain methods in the standard library,
meaning it overwrites them for testing purposes. For example,
`socket.socket` no longer creates a real OS socket; instead, it
creates a mock socket that does not actually make connections over the
network. This makes the tests reproducible and also makes it possible
for the test framework to, for example, inspect the exact bytes sent
over the "socket". For the tests to work, it's important only to use
mocked methods. Specifically, here are the mocked methods in various
modules:
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed

gilbo's avatar
gilbo committed
| Library             | Methods                                                           |
|---------------------|-------------------------------------------------------------------|
| `socket`            | `socket`                                                          |
| `socket.socket`     | `connect`, `send`, `makefile`, `close`                            |
| `ssl`               | `wrap_socket`                                                     |
| `certifi`           | `where`, `load_default_certs`, `load_verify_locations`            |
| `tkinter`           | `Tk`, `Canvas`, `font`                                            |
| `tkinter.Tk`        | `bind`                                                            |
| `tkinter.Canvas`    | `create_{text, rectangle, line, oval, polygon}`, `pack`, `delete` |
| `tkinter.font`      | `Font`                                                            |
| `tkinter.font.Font` | `measure`, `metrics`                                              |
Gilbert L Bernstein's avatar
Gilbert L Bernstein committed