Skip to content

Commit

Permalink
make CI more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreMarchand20 committed Dec 9, 2023
1 parent 1b5d637 commit 615a87d
Show file tree
Hide file tree
Showing 17 changed files with 156 additions and 110 deletions.
23 changes: 10 additions & 13 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,28 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"


- name: Set up Python package
run: |
python -m pip install --upgrade pip
python -m pip install .[test]
python3 -m pip install --upgrade pip
python3 -m pip install .[test]
- name: Run regression tests
run: |
pytest
set enable-bracketed-paste off
python3 -m pytest
- name: Check module imports with isort
run: |
python -m pip install isort
python -m isort . --check-only --diff
python3 -m pip install isort
python3 -m isort . --check-only --diff
# uses: isort/isort-action@master

- name: Check formatting with black
uses: psf/black@stable

- name: Check building a binary wheel and a source tarball
run: |
python -m pip install twine build --user
python -m build --sdist --wheel --outdir dist/ .
python -m twine check dist/*
python3 -m pip install twine build --user
python3 -m build --sdist --wheel --outdir dist/ .
python3 -m twine check dist/*
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ venv.bak/

# Others
.DS_Store

.vscode-server
2 changes: 1 addition & 1 deletion examples/backward_search.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rm my_first_file.txt
#$ delay 500

#$ send touch
#$ expect second
#$ expect second_file.txt

#$ wait 1000

Expand Down
5 changes: 4 additions & 1 deletion examples/history.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ rm my_first_file.txt

#$ delay 800

#$ sendarrow up 2
#$ sendarrow up 1
#$ expect rm my_first_file.txt

#$ sendarrow up 1
#$ expect touch my_second_file.txt

#$ sendarrow up
Expand Down
2 changes: 2 additions & 0 deletions examples/special_character.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

#$ expect \$
#$ sendcharacter #
This is a test with URL (https://github.com)
6 changes: 6 additions & 0 deletions tests/custom_rc_file_dumb_term
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export PS1="$ "
export HOME=~
export TERM=xterm
export PATH=/usr/bin:/usr/local/bin/
shopt -u checkwinsize
set enable-bracketed-paste off
6 changes: 6 additions & 0 deletions tests/custom_rc_file_xterm_term
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export PS1="$ "
export HOME=~
export TERM=xterm
export PATH=/usr/bin:/usr/local/bin/
shopt -u checkwinsize
set enable-bracketed-paste off
17 changes: 8 additions & 9 deletions tests/reference_output/asciinema_hello_world.cast
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[?2004h$ asciinema rec temp_test.cast \
[?2004l[?2004h> --overwrite \
[?2004l[?2004h> -c 'env -i PS1=$ bash --noprofile --norc' \
[?2004l[?2004h> -q
[?2004l$echo "Hello World"
$ asciinema rec temp_test.cast \
> --overwrite \
> -c 'env -i PS1=$ bash --noprofile --norc' \
> -q
$echo "Hello World"
Hello World
$exit
[?2004h$ asciinema play temp_test.cast
[?2004l$echo "Hello World"
$ asciinema play temp_test.cast
$echo "Hello World"
Hello World
$exit
[?2004h$ [?2004l
exit
$ exit
11 changes: 5 additions & 6 deletions tests/reference_output/autocompletion.cast
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[?2004h$ mkdir my_folder_with_a_very_long_name
[?2004l[?2004h$ cd my_folder_with_a_very_long_name/
[?2004l[?2004h$ basename $PWD
[?2004lmy_folder_with_a_very_long_name
[?2004h$ [?2004l
exit
$ mkdir my_folder_with_a_very_long_name
$ cd my_folder_with_a_very_long_name/
$ basename $PWD
my_folder_with_a_very_long_name
$ exit
19 changes: 11 additions & 8 deletions tests/reference_output/backward_search.cast
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[?2004h$ touch my_first_file.txt
[?2004l[?2004h$ touch my_second_file.txt
[?2004l[?2004h$ rm my_first_file.txt
[?2004l[?2004h$ (reverse-i-search)`': t': rm my_first_file.txt(reverse-i-search)`to': touch my_second_file.txt[1@u': tou[1@c': touc[1@h': touchtouch my_first$ touch$
[?2004l[?2004h$ ls my_first_file.txt
[?2004lmy_first_file.txt
[?2004h$ [?2004l
exit
$ touch my_first_file.txt
$ touch my_second_file.txt
$ rm my_first_file.txt
$
(reverse-i-search)`': t': rm my_first_file.txt
(reverse-i-search)`to': touch my_second_file.txtu': touc': touch': touchtouch my_first
$ touch
$
$ ls my_first_file.txt
my_first_file.txt
$ exit
27 changes: 13 additions & 14 deletions tests/reference_output/change_structure.cast
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[?2004h$ mkdir my_directory
[?2004l[?2004h$ cd my_directory
[?2004l[?2004h$ basename $PWD
[?2004lmy_directory
[?2004h$ touch my_textfile.txt
[?2004l[?2004h$ ls
[?2004lmy_textfile.txt
[?2004h$ rm my_textfile.txt
[?2004l[?2004h$ ls
[?2004l[?2004h$ cd ..
[?2004l[?2004h$ rm -r my_directory
[?2004l[?2004h$ ls
[?2004l[?2004h$ [?2004l
exit
$ mkdir my_directory
$ cd my_directory
$ basename $PWD
my_directory
$ touch my_textfile.txt
$ ls
my_textfile.txt
$ rm my_textfile.txt
$ ls
$ cd ..
$ rm -r my_directory
$ ls
$ exit
11 changes: 5 additions & 6 deletions tests/reference_output/escaped_command.cast
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[?2004h$ echo "Very" \
[?2004l[?2004h> "long" \
[?2004l[?2004h> "command"
[?2004lVery long command
[?2004h$ [?2004l
exit
$ echo "Very" \
> "long" \
> "command"
Very long command
$ exit
15 changes: 7 additions & 8 deletions tests/reference_output/hello_world.cast
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[?2004h$ echo "Hello world"
[?2004lHello world
[?2004h$ echo "I have waited 1000ms"
[?2004lI have waited 1000ms
[?2004h$ echo "I am writing with a 10ms delay"
[?2004lI am writing with a 10ms delay
[?2004h$ [?2004l
exit
$ echo "Hello world"
Hello world
$ echo "I have waited 1000ms"
I have waited 1000ms
$ echo "I am writing with a 10ms delay"
I am writing with a 10ms delay
$ exit
17 changes: 9 additions & 8 deletions tests/reference_output/history.cast
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[?2004h$ touch my_first_file.txt
[?2004l[?2004h$ touch my_second_file.txt
[?2004l[?2004h$ rm my_first_file.txt
[?2004l[?2004h$ rm my_first_file.txt$ [4@touch my_second_file.txt$ touch my_first_file.txt
[?2004l[?2004h$ ls
[?2004lmy_first_file.txt my_second_file.txt
[?2004h$ [?2004l
exit
$ touch my_first_file.txt
$ touch my_second_file.txt
$ rm my_first_file.txt
$ rm my_first_file.txt
$ touch my_second_file.txt
$ touch my_first_file.txt
$ ls
my_first_file.txt my_second_file.txt
$ exit
78 changes: 47 additions & 31 deletions tests/reference_output/man_page.cast
Original file line number Diff line number Diff line change
@@ -1,31 +1,47 @@
[?2004h$ man echo
[?2004l[?1049h[?1h=ECHO(1) User Commands ECHO(1)

NAME
echo - display a line of text

SYNOPSIS
echo [SHORT-OPTION]... [STRING]...
echo LONG-OPTION

DESCRIPTION
Echo the STRING(s) to standard output.

-n do not output the trailing newline

-e enable interpretation of backslash escapes

-E disable interpretation of backslash escapes (default)

--help display this help and exit

--version
output version information and exit

 Manual page echo(1) line 1 (press h for help or q to quit) ESCESC[[BB Manual page echo(1) line 1 (press h for help or q to quit) If -e is in effect, the following sequences are recognized:
 Manual page echo(1) line 2 (press h for help or q to quit) ESCESC[[BB Manual page echo(1) line 2 (press h for help or q to quit)
 Manual page echo(1) line 3 (press h for help or q to quit) ESCESC[[BB Manual page echo(1) line 3 (press h for help or q to quit) \\ backslash
 Manual page echo(1) line 4 (press h for help or q to quit) ESCESC[[BB Manual page echo(1) line 4 (press h for help or q to quit)
 Manual page echo(1) line 5 (press h for help or q to quit) ESCESC[[BB Manual page echo(1) line 5 (press h for help or q to quit) \a alert (BEL)
 Manual page echo(1) line 6 (press h for help or q to quit)[?1l>[?1049l[?2004h$ [?2004l
exit
$ man echo
=
ECHO(1) User Commands ECHO(1)

NAME
echo - display a line of text

SYNOPSIS
echo [SHORT-OPTION]... [STRING]...
echo LONG-OPTION

DESCRIPTION
Echo the STRING(s) to standard output.

-n do not output the trailing newline

-e enable interpretation of backslash escapes

-E disable interpretation of backslash escapes (default)

--help display this help and exit

--version
output version information and exit

Manual page echo(1) line 1 (press h for help or q to quit)
ESCESC[[BB
Manual page echo(1) line 1 (press h for help or q to quit)
If -e is in effect, the following sequences are recognized:
Manual page echo(1) line 2 (press h for help or q to quit)
ESCESC[[BB
Manual page echo(1) line 2 (press h for help or q to quit)

Manual page echo(1) line 3 (press h for help or q to quit)
ESCESC[[BB
Manual page echo(1) line 3 (press h for help or q to quit)
\\ backslash
Manual page echo(1) line 4 (press h for help or q to quit)
ESCESC[[BB
Manual page echo(1) line 4 (press h for help or q to quit)

Manual page echo(1) line 5 (press h for help or q to quit)
ESCESC[[BB
Manual page echo(1) line 5 (press h for help or q to quit)
\a alert (BEL)
Manual page echo(1) line 6 (press h for help or q to quit)
>$ exit
5 changes: 2 additions & 3 deletions tests/reference_output/special_character.cast
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[?2004h$ #This is a test with URL (https://github.com)
[?2004l[?2004h$ [?2004l
exit
$ #This is a test with URL (https://github.com)
$ exit
20 changes: 18 additions & 2 deletions tests/test_regression.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pathlib
import re

import pytest

Expand Down Expand Up @@ -28,19 +29,34 @@ def test_regression(tmp_path, request, inputfile: pathlib.Path):
reference_folder = (
request.config.invocation_params.dir / "tests" / "reference_output"
)
custom_rc_file = (
request.config.invocation_params.dir / "tests" / "custom_rc_file_dumb_term"
)
output_folder = tmp_path
output_file_name = inputfile.stem + ".cast"
print(pathlib.Path().cwd())

if inputfile.name in ["backward_search.sh", "history.sh", "man_page.sh"]:
custom_rc_file = (
request.config.invocation_params.dir / "tests" / "custom_rc_file_xterm_term"
)
cli(
[
"--debug",
"--asciinema-arguments",
"""--raw --overwrite -c 'env -i TERM=xterm-256color HOME=~ PS1="$ " PATH=/usr/bin:/usr/local/bin/ bash --noprofile --norc'""",
"""--raw --overwrite -c 'env -i bash --noprofile --rcfile """
+ str(custom_rc_file)
+ """'""",
str(example_folder / inputfile.name),
str(output_folder / output_file_name),
]
)

with open(output_folder / output_file_name, "r") as output_file:
with pathlib.Path(reference_folder / output_file_name).open() as reference_file:
assert output_file.readlines() == reference_file.readlines()
ansi_escape = re.compile(
r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])", re.VERBOSE
)
output_text = output_file.read()
cleaned_output_text = ansi_escape.sub("", output_text)
assert cleaned_output_text == reference_file.read()

0 comments on commit 615a87d

Please sign in to comment.