8000 Test Failing Examples Tests?? by JeffersGlass · Pull Request #1468 · pyscript/pyscript · GitHub
[go: up one dir, main page]

Skip to content

Test Failing Examples Tests?? #1468

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

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions .github/workflows/build-unstable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,18 @@ jobs:
with:
node-version: 18.x

- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: setup Miniconda
uses: conda-incubator/setup-miniconda@v2

- name: Setup Environment
run: make setup

- name: Clean
run: make clean

- name: Build
run: make build

- name: TypeScript Tests
run: make test-ts

- name: Python Tests
run: make test-py

- name: Integration Tests
run: make test-integration-parallel

Expand Down
10 changes: 6 additions & 4 deletions pyscriptjs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ examples:
rm -rf ./examples/build
mkdir -p ./examples/build
cp -R ./build/* ./examples/build
ls ./examples
ls ./examples/build
@echo "To serve examples run: $(conda_run) python -m http.server 8080 --directory examples"

# run prerequisites and serve pyscript examples at http://localhost:8000/examples/
Expand All @@ -87,19 +89,19 @@ run-examples: setup build examples

test:
make examples
make test-ts
make test-py
# make test-ts
# make test-py
make test-integration-parallel

test-integration:
make examples
mkdir -p test_results
$(PYTEST_EXE) -vv $(ARGS) tests/integration/ --log-cli-level=warning --junitxml=test_results/integration.xml
$(PYTEST_EXE) -vv $(ARGS) tests/integration/ --log-cli-level=warning --junitxml=test_results/integration.xml -k 'zz_examples'

test-integration-parallel:
make examples
mkdir -p test_results
$(PYTEST_EXE) --numprocesses auto -vv $(ARGS) tests/integration/ --log-cli-level=warning --junitxml=test_results/integration.xml
$(PYTEST_EXE) --numprocesses auto -vv $(ARGS) tests/integration/ --log-cli-level=warning --junitxml=test_results/integration.xml -k 'zz_examples'

test-py:
@echo "Tests from $(src_dir)"
Expand Down
3 changes: 3 additions & 0 deletions pyscriptjs/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import * as Synclink from 'synclink';

const logger = getLogger('pyscript/main');

// This is a dummy comment for the purposes of this experiment
// This is a second dummy content

/**
* Monkey patching the error transfer handler to preserve the `$$isUserError`
* marker so as to detect `UserError` subclasses in the error handling code.
Expand Down
29 changes: 29 additions & 0 deletions pyscriptjs/tests/integration/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ def log_request(self, status, kind, url):

def _router(self, route):
full_url = route.request.url
self.logger.log("route", f"Request for {full_url}")
url = urllib.parse.urlparse(full_url)
assert url.scheme in ("http", "https")

Expand All @@ -942,9 +943,37 @@ def _router(self, route):
self.log_request(200, "fake_server", full_url)
assert url.path[0] == "/"
relative_path = url.path[1:]
self.logger.log("url", f"{url.path= }")
if os.path.exists(relative_path):
route.fulfill(status=200, headers=self.headers, path=relative_path)
else:

def printFilesInPath(path):
for file in sorted(os.listdir(path)):
print(">>> ", file)

def walkFiles(path):
# traverse root directory, and list directories as dirs and files as files
for root, _dirs, files in os.walk("."):
path = root.split(os.sep)
print((len(path) - 1) * "---", os.path.basename(root))
for file in files:
print(len(path) * "---", file)

print(
f"This code is executing in file {__file__=} with parent dir {os.path.dirname(__file__)=}"
)

enclosing_folder = "/".join(relative_path.split("/")[:-1])
enclosing_folder = enclosing_folder if enclosing_folder else "."
print(
f"Failed to find '{relative_path} (based on full path {url.path= })'"
)
print(f"Current working directory is: {os.getcwd()}")
print("Contents of cwd are:")
# walkFiles(os.getcwd())
print("Contents of {enclosing_folder} :")
printFilesInPath(enclosing_folder)
route.fulfill(status=404, headers=self.headers)
return

Expand Down
1 change: 1 addition & 0 deletions pyscriptjs/tests/integration/test_zz_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def test_hello_world(self):
assert re.search(pattern, content)
self.assert_no_banners()
self.check_tutor_generated_code()
raise AssertionError()

def test_simple_clock(self):
self.goto("examples/simple_clock.html")
Expand Down
0