mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-12-25 12:05:32 +03:00
Merge pull request #157 from Orange-OpenSource/feature/run-test-integ-in-windows
Run Tests integ in windows
This commit is contained in:
commit
c6424526b2
@ -76,6 +76,13 @@ cd c:\hurl\integration
|
||||
start /B server.py
|
||||
```
|
||||
|
||||
launch the ssl server
|
||||
|
||||
```cmd
|
||||
cd c:\hurl\integration
|
||||
start /B ssl/server.py
|
||||
```
|
||||
|
||||
launch hurl unit tests
|
||||
|
||||
```cmd
|
||||
@ -85,8 +92,9 @@ cargo test
|
||||
|
||||
launch hurl integration tests
|
||||
|
||||
```
|
||||
coming soon ... ;)
|
||||
```cmd
|
||||
cd c:\hurl\integration
|
||||
./integration.py
|
||||
```
|
||||
|
||||
## Generate version.txt file
|
||||
|
@ -39,6 +39,7 @@ $env:VCPKGRS_DYNAMIC = [System.Environment]::GetEnvironmentVariable("VCPKGRS_DYN
|
||||
## Clone hurl project
|
||||
|
||||
```powershell
|
||||
git.exe config --global core.autocrlf false
|
||||
git.exe clone https://github.com/Orange-OpenSource/hurl
|
||||
```
|
||||
|
||||
@ -57,6 +58,10 @@ New-Item -ItemType "Directory" -Path "c:\hurl\target" -Name "win-package"
|
||||
Get-ChildItem -Path "c:\hurl\target\release" -Recurse -Include *.dll -File | Copy-Item -Destination "c:\hurl\target\win-package"
|
||||
Get-ChildItem -Path "c:\hurl\target\release" -Recurse -Include hurl*.exe -File | Copy-Item -Destination "c:\hurl\target\win-package"
|
||||
((c:\hurl\target\win-package\hurl.exe --version) -Split " ")[1] > c:\hurl\target\win-package\version.txt
|
||||
$oldpath = Get-ItemProperty -Path HKCU:\Environment -Name Path
|
||||
$newpath = $oldpath.Path += ";c:\hurl\target\win-package"
|
||||
Set-ItemProperty -Path HKCU:\Environment -Name Path -Value $newpath
|
||||
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
|
||||
```
|
||||
|
||||
## Test your app
|
||||
@ -74,6 +79,14 @@ cd c:\hurl\integration
|
||||
python server.py
|
||||
```
|
||||
|
||||
Keep original powershell prompt on background, and open one more separate powershell prompt to launch the ssl server
|
||||
|
||||
```powershell
|
||||
cd c:\hurl\integration
|
||||
python ssl/server.py
|
||||
```
|
||||
|
||||
|
||||
Keep original powershell prompt on background, and open one more separate powershell prompt to launch the proxy
|
||||
|
||||
```powershell
|
||||
@ -90,7 +103,8 @@ cargo test --verbose
|
||||
launch hurl integration tests
|
||||
|
||||
```powershell
|
||||
coming soon ... ;)
|
||||
cd c:\hurl\integration
|
||||
./integration.py
|
||||
```
|
||||
|
||||
## Generate version.txt file
|
||||
|
@ -6,16 +6,20 @@ import test_lint
|
||||
import test_format
|
||||
import test_hurl
|
||||
|
||||
|
||||
def get_files(glob_expr):
|
||||
return sorted([f.replace('\\', '/') for f in glob.glob(glob_expr)])
|
||||
|
||||
def main():
|
||||
# Static run (without server)
|
||||
[test_echo.test(f) for f in sorted(glob.glob('tests/*.hurl') + glob.glob('tests_error_lint/*.hurl'))]
|
||||
[test_format.test('json', f) for f in sorted(glob.glob('tests/*.hurl'))]
|
||||
[test_format.test('html', f) for f in sorted(glob.glob('tests/*.hurl'))]
|
||||
[test_lint.test(f) for f in sorted(glob.glob('tests_error_lint/*.hurl'))]
|
||||
[test_hurl.test(f) for f in sorted(glob.glob('tests_error_parser/*.hurl'))]
|
||||
[test_echo.test(f) for f in get_files('tests/*.hurl') + get_files('tests_error_lint/*.hurl')]
|
||||
[test_format.test('json', f) for f in get_files('tests/*.hurl')]
|
||||
[test_format.test('html', f) for f in get_files('tests/*.hurl')]
|
||||
[test_lint.test(f) for f in get_files('tests_error_lint/*.hurl')]
|
||||
[test_hurl.test(f) for f in get_files('tests_error_parser/*.hurl')]
|
||||
|
||||
# Dynamic run (with server)
|
||||
[test_hurl.test(f) for f in sorted(glob.glob('tests/*.hurl')) + sorted(glob.glob('ssl/*.hurl'))]
|
||||
[test_hurl.test(f) for f in get_files('tests/*.hurl') + get_files('ssl/*.hurl')]
|
||||
|
||||
print('test integration ok!')
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
error: SSL Certificate
|
||||
--> ssl/error_self_signed_certificate.hurl:1:5
|
||||
|
|
||||
1 | GET https://localhost:8001/hello
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ schannel: SEC_E_UNTRUSTED_ROOT (0x80090325)
|
||||
|
|
@ -6,12 +6,22 @@ import sys
|
||||
import subprocess
|
||||
import codecs
|
||||
|
||||
def decode_string(encoded):
|
||||
if encoded.startswith(codecs.BOM_UTF8):
|
||||
return encoded.decode('utf-8-sig')
|
||||
elif encoded.startswith(codecs.BOM_UTF16):
|
||||
encoded = encoded[len(codecs.BOM_UTF16):]
|
||||
return encoded.decode('utf-16')
|
||||
else:
|
||||
return encoded.decode()
|
||||
|
||||
|
||||
def test(hurl_file):
|
||||
cmd = ['hurlfmt', '--no-format', hurl_file]
|
||||
print(' '.join(cmd))
|
||||
result = subprocess.run(cmd, stdout=subprocess.PIPE)
|
||||
expected = codecs.open(hurl_file, encoding='utf-8-sig').read() # Input file can be saved with a BOM
|
||||
actual = result.stdout.decode("utf-8")
|
||||
actual = decode_string(result.stdout)
|
||||
if actual != expected:
|
||||
print('>>> error in stdout')
|
||||
print(f'actual: <{actual}>\nexpected: <{expected}>')
|
||||
|
@ -2,16 +2,27 @@
|
||||
# echo hurl file
|
||||
# The file is parsed and output exactly as the input
|
||||
#
|
||||
import codecs
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
def decode_string(encoded):
|
||||
if encoded.startswith(codecs.BOM_UTF8):
|
||||
return encoded.decode('utf-8-sig')
|
||||
elif encoded.startswith(codecs.BOM_UTF16):
|
||||
encoded = encoded[len(codecs.BOM_UTF16):]
|
||||
return encoded.decode('utf-16')
|
||||
else:
|
||||
return encoded.decode()
|
||||
|
||||
|
||||
def test(format_type, hurl_file):
|
||||
cmd = ['hurlfmt', '--format', format_type, hurl_file]
|
||||
print(' '.join(cmd))
|
||||
result = subprocess.run(cmd, stdout=subprocess.PIPE)
|
||||
json_file = hurl_file.replace('.hurl','.' + format_type)
|
||||
expected = open(json_file).read().strip()
|
||||
actual = result.stdout.decode("utf-8").strip()
|
||||
expected = open(json_file, encoding='utf-8').read().strip()
|
||||
actual = decode_string(result.stdout)
|
||||
if actual != expected:
|
||||
print('>>> error in stdout')
|
||||
print(f'actual: <{actual}>\nexpected: <{expected}>')
|
||||
|
@ -1,9 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
# test hurl file
|
||||
#
|
||||
import codecs
|
||||
import sys
|
||||
import subprocess
|
||||
import os
|
||||
import platform
|
||||
|
||||
|
||||
def decode_string(encoded):
|
||||
if encoded.startswith(codecs.BOM_UTF8):
|
||||
return encoded.decode('utf-8-sig')
|
||||
elif encoded.startswith(codecs.BOM_UTF16):
|
||||
encoded = encoded[len(codecs.BOM_UTF16):]
|
||||
return encoded.decode('utf-16')
|
||||
else:
|
||||
return encoded.decode()
|
||||
|
||||
|
||||
# return linux, osx or windows
|
||||
def get_os():
|
||||
if platform.system() == 'Linux':
|
||||
return 'linux'
|
||||
elif platform.system() == 'Darwin':
|
||||
return 'osx'
|
||||
elif platform.system() == 'Windows':
|
||||
return 'windows'
|
||||
else:
|
||||
raise Error('Invalid Platform ' + platform.system())
|
||||
|
||||
|
||||
def test(hurl_file):
|
||||
|
||||
@ -21,29 +46,37 @@ def test(hurl_file):
|
||||
expected = int(open(f).read().strip())
|
||||
if result.returncode != expected:
|
||||
print('>>> error in return code')
|
||||
print('expected: {expected} actual:{result.returncode}')
|
||||
print(f'expected: {expected} actual:{result.returncode}')
|
||||
sys.exit(1)
|
||||
|
||||
# stdout
|
||||
f = hurl_file.replace('.hurl','.out')
|
||||
if os.path.exists(f):
|
||||
expected = open(f, 'rb').read()
|
||||
actual = result.stdout
|
||||
actual = result.stdout
|
||||
if expected != actual:
|
||||
print('>>> error in stdout')
|
||||
print(f'actual: <{actual}>\nexpected: <{expected}>')
|
||||
sys.exit(1)
|
||||
|
||||
# stderr
|
||||
f = hurl_file.replace('.hurl','.err')
|
||||
if os.path.exists(f):
|
||||
expected = open(f).read().strip()
|
||||
actual = result.stderr.decode("utf-8").strip()
|
||||
if expected != actual:
|
||||
print('>>> error in stderr')
|
||||
print(f'actual: <{actual}>\nexpected: <{expected}>')
|
||||
sys.exit(1)
|
||||
|
||||
# stderr
|
||||
f = hurl_file.replace('.hurl', '.' + get_os() + '.err')
|
||||
if os.path.exists(f):
|
||||
expected = open(f).read().strip()
|
||||
actual = decode_string(result.stderr).strip()
|
||||
if expected != actual:
|
||||
print('>>> error in stderr')
|
||||
print(f'actual: <{actual}>\nexpected: <{expected}>')
|
||||
sys.exit(1)
|
||||
else:
|
||||
f = hurl_file.replace('.hurl', '.err')
|
||||
if os.path.exists(f):
|
||||
expected = open(f).read().strip()
|
||||
actual = decode_string(result.stderr).strip()
|
||||
if expected != actual:
|
||||
print('>>> error in stderr')
|
||||
print(f'actual: <{actual}>\nexpected: <{expected}>')
|
||||
sys.exit(1)
|
||||
|
||||
def main():
|
||||
for hurl_file in sys.argv[1:]:
|
||||
|
@ -1,9 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
# lint hurl file
|
||||
#
|
||||
import codecs
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
def decode_string(encoded):
|
||||
if encoded.startswith(codecs.BOM_UTF8):
|
||||
return encoded.decode('utf-8-sig')
|
||||
elif encoded.startswith(codecs.BOM_UTF16):
|
||||
encoded = encoded[len(codecs.BOM_UTF16):]
|
||||
return encoded.decode('utf-16')
|
||||
else:
|
||||
return encoded.decode()
|
||||
|
||||
|
||||
def test(hurl_file):
|
||||
cmd = ['hurlfmt', '--check', hurl_file]
|
||||
print(' '.join(cmd))
|
||||
@ -14,7 +25,7 @@ def test(hurl_file):
|
||||
|
||||
err_file = hurl_file.replace('.hurl','.err')
|
||||
expected = open(err_file).read().strip()
|
||||
actual = result.stderr.decode("utf-8").strip()
|
||||
actual = decode_string(result.stderr).strip()
|
||||
if actual != expected:
|
||||
print('>>> error in stderr')
|
||||
print(f'actual: <{actual}>\nexpected: <{expected}>')
|
||||
@ -25,7 +36,7 @@ def test(hurl_file):
|
||||
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
err_file = hurl_file.replace('.hurl','.hurl.lint')
|
||||
expected = open(err_file).read().strip()
|
||||
actual = result.stdout.decode("utf-8").strip()
|
||||
actual = decode_string(result.stdout).strip()
|
||||
if actual != expected:
|
||||
print('>>> error in stdout')
|
||||
print(f'actual: <{actual}>\nexpected: <{expected}>')
|
||||
|
@ -1 +1 @@
|
||||
--color
|
||||
--color
|
||||
|
7
integration/tests/error_file_read_access.windows.err
Normal file
7
integration/tests/error_file_read_access.windows.err
Normal file
@ -0,0 +1,7 @@
|
||||
error: File ReadAccess
|
||||
--> tests/error_file_read_access.hurl:2:6
|
||||
|
|
||||
2 | file,does_not_exist;
|
||||
| ^^^^^^^^^^^^^^ File tests\does_not_exist can not be read
|
||||
|
|
||||
|
7
integration/tests/error_multipart_form_data.windows.err
Normal file
7
integration/tests/error_multipart_form_data.windows.err
Normal file
@ -0,0 +1,7 @@
|
||||
error: File ReadAccess
|
||||
--> tests/error_multipart_form_data.hurl:4:15
|
||||
|
|
||||
4 | upload1: file,unknown;
|
||||
| ^^^^^^^ File tests\unknown can not be read
|
||||
|
|
||||
|
@ -537,12 +537,12 @@ fn test_error_ssl() {
|
||||
let mut client = Client::init(options);
|
||||
let request = default_get_request("https://localhost:8001/hello".to_string());
|
||||
let error = client.execute(&request, 0).err().unwrap();
|
||||
assert_eq!(
|
||||
error,
|
||||
HttpError::SSLCertificate(Some(
|
||||
"SSL certificate problem: self signed certificate".to_string()
|
||||
))
|
||||
);
|
||||
let message = if cfg!(windows) {
|
||||
"schannel: SEC_E_UNTRUSTED_ROOT (0x80090325)".to_string()
|
||||
} else {
|
||||
"SSL certificate problem: self signed certificate".to_string()
|
||||
};
|
||||
assert_eq!(error, HttpError::SSLCertificate(Some(message)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user