Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests for repypp.py #163

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open

Add unit tests for repypp.py #163

wants to merge 26 commits into from

Conversation

XuefengHuang
Copy link

This PR tests repypp.py:
1.Correct #include statements
2.Erroneous #include statements:
include non-existing files,
have multiple arguments,
have no arguments at all.

This script tests if repypp.py check erroneous #include statements(have multiple arguments).
This script tests if repypp.py check erroneous #include statements(include non-existing files
@@ -0,0 +1,28 @@
"""
ut_seattlelibv2_repypp_include.py -- -- This script tests correct #include statements

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a very terse description. We should mention the Repy preprocessor (as some other tests do), and what the expected correct outcome is.

@aaaaalbert
Copy link
Contributor

For reference, this is in response to #161.

@@ -0,0 +1,34 @@
#pragma out Error opening source file 'nonexit.py'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo: We want to refer to a non-existing file rather than a non-exiting (note "s").

Since the name using tempfile module which is not satisfied the requirement of Repy, so I discard it. And I give more explanations, modify file names. Also checking whether the file contents match what we expect.
Since the name using tempfile module which is not satisfied with the requirement of Repy, so I discard it. And I give more explanations, modify file names.
Since the name using tempfile module which is not satisfied the requirement of Repy, so I discard it. And I give more explanations, modify file names.
This script tests if repypp.py check erroneous #include statements(have multiple arguments).
This script tests if repypp.py check erroneous #include statements(have no arguments at all).
This script tests if some comments(include some_lib.repy # Ensure that comments are ignored, even if preceded by whitespace) 
are ignored.
@@ -0,0 +1,43 @@
"""
repypp.py is a preprocessor for repy. It includes dependent files as needed.This is used to help the
programmer avoid the need to use import. They can instead use "include X" which works somewhat like "from X import *".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please limit line lengths to approximately 70 characters. (This eases editing on text-based terminals.)


f = open('testfile_repypp_example2_preprocessed.repy','r')

if not correctresult1 in f.read() and not correctresult2 in f.read():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we split this test so that we can output two more specific error messages, e.g. "repypp failed to include the specified file .....", and "repypp incorrectly touched file contents" (or similar).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants