Skip to content

cross platform: python script to run test files [suggestion] #951

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

Merged
merged 1 commit into from
May 12, 2016
Merged

cross platform: python script to run test files [suggestion] #951

merged 1 commit into from
May 12, 2016

Conversation

obastemur
Copy link
Collaborator

@obastemur obastemur commented May 9, 2016

This PR

  • adds a Python based test script to run all the test files or the ones from
    a given folder. In addition to executing JS files, it also compares the results
    to predefined baseline files.
  • replaces the functionality of runtests.sh to call runtests.py

Try:

./build.sh
./test/runtests.py Basics

In order to run a single file

./test/runtests.py Basics/hello.js

@obastemur
Copy link
Collaborator Author

obastemur commented May 9, 2016

@dilijev I guess Copyright check fails because of py file?

@obastemur
Copy link
Collaborator Author

@dilijev I've updated netci.groovy to use runtests.py instead of runtests.sh (which is no longer exist) but somehow CI doesn't take this change into consideration?

@dilijev
Copy link
Contributor

dilijev commented May 9, 2016

@obastemur Yes, changes to the CI script need to be merged in to the branch and then the tasks need to be regenerated before the CI will use them. netci.groovy is not used during the CI checks, it is only used to generate them. (That's part of why changes to the CI are so difficult to test.)

Probably the fastest thing to do for now is to have runtests.sh wrap runtests.py.

@dilijev
Copy link
Contributor

dilijev commented May 9, 2016

@obastemur as for the copyright failure, yes, you can see in the logs:

test/runtests.py ... does not contain a correct Microsoft copyright notice.

@@ -42,6 +42,7 @@ install_manifest.txt
*.xcworkspace

# additional *nix generated files
/ch
Copy link
Contributor

@dilijev dilijev May 9, 2016

Choose a reason for hiding this comment

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

Why /ch instead of just ch? Doesn't the leading slash only exclude the file if it is in the same directory as the .gitignore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's my intention. new build script creates a symbolic link for ch on the root. I want it to be ignored on git.

Copy link
Contributor

Choose a reason for hiding this comment

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

To be more general, we could ignore that file in any directory it happens to appear by simply removing the leading /

@obastemur
Copy link
Collaborator Author

Probably the fastest thing to do for now is to have runtests.sh wrap runtests.py.

and send an empty config to delete runtests.sh?

Do we have to do this? BTW; Where do we update that Copyright Check algorithm to cover py files ?

@@ -0,0 +1,120 @@
#!/usr/bin/env python
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I figured this would come up. Files that need shebangs will break the copyright check. This is arguably a bug in the copyright check that needs a special case. Previously I had specified that the copyright notice had to be the VERY FIRST thing in the file. But since semantically, the shebang needs to come first when it is present, I'll add an exception.
@digitalinfinity does this exception seem reasonable?

@dilijev
Copy link
Contributor

dilijev commented May 9, 2016

@obastemur Why do you want to delete runtests.sh? It seems better to have a script which could run any test harness in any configuration and abstract the details of running the tests from the build definition?

Anyway changes to the CI script should be done as separate pull requests (and in a separate branch, as you've noted, to avoid disruption while we sort out the details).

@dilijev
Copy link
Contributor

dilijev commented May 9, 2016

@obastemur
Copy link
Collaborator Author

Why do you want to delete runtests.sh? It seems better to have a script which could run any test harness in any configuration and abstract the details of running the tests from the build definition?

Both are executable scripts, I don't see any reason to keep both.

Anyway changes to the CI script should be done as separate pull requests (and in a separate branch, as you've noted, to avoid disruption while we sort out the details).

Great. Gonna cherry-pick this to separate branch and let's see what's going to happen


result=$?
if [[ $result == 0 && ! -f ../ch ]]; then
ln -s BuildLinux/ch ../ch
Copy link

Choose a reason for hiding this comment

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

I assume you did this change to save some typing while testing manually? I tried it out and this broke my personal settings. I have "." at head of PATH. When I build at repo root and run "ch", it prints

dlopen() failed; dlerror says 'ch: cannot open shared object file: No such file or directory'

The same happens if I have <repo>/BuildLinux at head of PATH.

My workaround was a wrapper script "ch" in my PATH to invoke BuildLinux/ch. That doesn't have this problem.

So maybe a top-level symbolic link to "ch" isn't very useful?

  • It has above problem. (maybe we can investigate and fix it.)
  • The primary binary is "chakracore", not "ch". "ch" is mostly a testing binary. A top-level link feels over kill for it.
  • We might consider build type subdirs like BuildLinux/x64_debug, BuildLinux/x64_release. Top-level ch link doesn't work with that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with the above concerns. It's fairly straightforward to know where the test binary is. Especially as long as this is intended to use with already-written test code, saving typing is a moot point. For manual testing, there's not that much extra typing to do, and a wrapper script might be more useful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried it out and this broke my personal settings. I have "." at head of PATH. When I build at repo root and run "ch", it prints

local one is available at ./ch

I agree with the above concerns. It's fairly straightforward to know where the test binary is.

you can call ls -l ch

We might consider build type subdirs like BuildLinux/x64_debug,

We could have ch_d or ch_debug etc..

Especially as long as this is intended to use with already-written test code, saving typing is a moot point.

Sorry, didnt' understand. Could you please explain more?

@obastemur
Copy link
Collaborator Author

@jianchun ch is removed from root for now.
@dilijev see env is removed. Do you think that should cover?

Although I don't expect any problem from this PR, I'm still +1 on cherry-picking this PR to separate branch and run through CI first. However, I'm also okay if you don't see any reason for that too J

@dilijev
Copy link
Contributor

dilijev commented May 9, 2016

@obastemur I still strongly oppose modifying netci.groovy as part of this change, or removing runtests.sh at all, until the test harness for linux becomes more mature. We might change mechanisms and having a single script which will automate whatever we need will remove churn from the netci.groovy file, which is difficult to manage, as you've seen. I think removing that script and making a change here is jumping the gun.

@@ -42,6 +42,8 @@ def report_incorrect(file_name, pairs):
linecount = 0
pairs = []
with open(file_name, 'r') as sourcefile:
if not re.match(r'#!/usr/bin/env.*', sourcefile.readline(), 0):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just sourcefile.readline().startswith("#!")? I think we're imposing too much structure on the shebang.

@obastemur
Copy link
Collaborator Author

CI related file changes are removed from the PR. I guess that's all ?

# Eventual test running harness on *nix for ChakraCore
# Today, it's simply there to make sure hello.js doesn't regress
#
# REMOVE THIS AFTER MERGING runtests.py in!
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there's any need for this comment. We can make this decision later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

AFAIK the decision is done. Is there any technical reason to keep this file?

Copy link
Contributor

@dilijev dilijev May 9, 2016

Choose a reason for hiding this comment

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

The idea is that, since netci.groovy is much slower to update and the way we run the tests could change, I'm ultimately trying to reduce resistance to changes by keeping this file as a wrapper for whatever mechanism we actually use to run tests. I think that's a fair enough technical reason (based on a technical limitation of the netci.groovy task generation mechanism).

I'm not aware of any decision regarding netci.groovy task changes or this file in particular. I'll start an email thread with @curtisman to sort out the details.

@dilijev
Copy link
Contributor

dilijev commented May 9, 2016

Unless you include an exception to not return a failure error code for now, the linux tasks will keep failing until clang 3.8 is installed on the build machines, which should happen later today. Since that change is incoming, it's probably best to wait until it is done and then re-run the tests before merging this in.

This PR

- adds a Python based test script to run all the test files or the ones from
a given folder. In addition to executing JS files, it also compares the results
to predefined baseline files.

- adds a shebang support for copyright check

- replaces runtests.sh on CI/linux

Try;

'''
./build.sh
./test/runtests.py Basics
'''

In order to run a single file
'''
./test/runtests.py Basics/hello.js
'''
chakrabot pushed a commit that referenced this pull request May 10, 2016
…op of scripts.

Merge pull request #957 from dilijev:copy
Unblocks copyright check on #951
@dilijev
Copy link
Contributor

dilijev commented May 10, 2016

@dotnet-bot test Copyright Check please

@dilijev
Copy link
Contributor

dilijev commented May 10, 2016

Following completion of the Copyright Check, LGTM and this is good to merge.

@dilijev
Copy link
Contributor

dilijev commented May 11, 2016

Since the toolchain has been updated...
@dotnet-bot
test Ubuntu ubuntu_linux_debug please
test Ubuntu ubuntu_linux_release please

@chakrabot chakrabot merged commit f45468c into chakra-core:linux May 12, 2016
chakrabot pushed a commit that referenced this pull request May 12, 2016
…ion]

Merge pull request #951 from obastemur:testing
This PR

- adds a Python based test script to run all the test files or the ones from
a given folder. In addition to executing JS files, it also compares the results
to predefined baseline files.
- replaces the functionality of `runtests.sh` to call `runtests.py`

Try:

```
./build.sh
./test/runtests.py Basics
```

In order to run a single file
```
./test/runtests.py Basics/hello.js
```
@obastemur obastemur deleted the testing branch June 7, 2016 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants