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

ci: add Windows builds + tests #249

Merged
merged 1 commit into from
Nov 14, 2023
Merged
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
56 changes: 56 additions & 0 deletions .github/workflows/curl-for-win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright (C) Viktor Szakats. See LICENSE.md
# SPDX-License-Identifier: curl
---
name: curl-for-win

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

permissions: {}

env:
CW_GET: 'curl'
CW_MAP: '0'
CW_JOBS: '3'
CW_PKG_NODELETE: '1'
CW_PKG_FLATTEN: '1'
DOCKER_CONTENT_TRUST: '1'

jobs:
win-llvm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: 'trurl'
fetch-depth: 8
- name: 'build'
env:
CW_LLVM_MINGW_DL: '1'
CW_LLVM_MINGW_ONLY: '0'
CW_TURL_TEST: '1'
run: |
git clone --depth 1 https://github.com/curl/curl-for-win
mv curl-for-win/* .
export CW_CONFIG='-dev-zero-imap-osnotls-osnoidn-nocurltool-win'
export CW_REVISION='${{ github.sha }}'
. ./_versions.sh
docker trust inspect --pretty "${DOCKER_IMAGE}"
time docker pull "${DOCKER_IMAGE}"
docker images --digests
time docker run --volume "$(pwd):$(pwd)" --workdir "$(pwd)" \
--env-file <(env | grep -a -E \
'^(CW_|GITHUB_)') \
"${DOCKER_IMAGE}" \
sh -c ./_ci-linux-debian.sh

- name: 'list dependencies'
run: cat urls.txt
- uses: actions/upload-artifact@v3
with:
name: 'trurl-windows'
retention-days: 5
path: curl-*-*-*/trurl*
79 changes: 50 additions & 29 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ def testComponent(value, exp):


class TestCase:
def __init__(self, testIndex, baseCmd, **testCase):
def __init__(self, testIndex, runnerCmd, baseCmd, **testCase):
self.testIndex = testIndex
self.runnerCmd = runnerCmd
self.baseCmd = baseCmd
self.arguments = testCase["input"]["arguments"]
self.expected = testCase["expected"]
Expand All @@ -74,7 +75,10 @@ def runCommand(self, cmdfilter: Optional[str], runWithValgrind: bool):

cmd = [self.baseCmd]
args = self.arguments
if runWithValgrind:
if self.runnerCmd != "":
cmd = [self.runnerCmd]
args = [self.baseCmd] + self.arguments
elif runWithValgrind:
cmd = [VALGRINDTEST]
args = VALGRINDARGS + [self.baseCmd] + self.arguments

Expand All @@ -96,6 +100,11 @@ def runCommand(self, cmdfilter: Optional[str], runWithValgrind: bool):
# assume stderr is always going to be string
stderr = output.stderr

# runners (e.g. wine) spill their own output into stderr,
# ignore stderr tests when using a runner.
if self.runnerCmd != "" and "stderr" in self.expected:
stderr = self.expected["stderr"]

self.commandOutput = CommandOutput(stdout, output.returncode, stderr)
return True

Expand Down Expand Up @@ -161,41 +170,53 @@ def main(argc, argv):
# the .exe on the end is necessary when using absolute paths
if sys.platform == "win32" or sys.platform == "cygwin":
baseCmd += ".exe"

with open(path.join(baseDir, TESTFILE), "r") as file:
allTests = json.load(file)
testIndexesToRun = []

# if argv[1] exists and starts with int
cmdfilter = ""
testIndexesToRun = list(range(len(allTests)))
runWithValgrind = False
verboseDetail = False
runnerCmd = ""

if argc > 1:
for arg in argv[1:]:
if arg[0].isnumeric():
# run only test cases separated by ","
testIndexesToRun = []

for caseIndex in arg.split(","):
testIndexesToRun.append(int(caseIndex))
elif arg == "--with-valgrind":
runWithValgrind = True
elif arg == "--verbose":
verboseDetail = True
elif arg.startswith("--trurl="):
baseCmd = arg[len("--trurl="):]
elif arg.startswith("--runner="):
runnerCmd = arg[len("--runner="):]
else:
cmdfilter = argv[1]

# check if the trurl executable exists
if path.isfile(baseCmd):
# get the version info for the feature list
args = ["--version"]
if runnerCmd != "":
cmd = [runnerCmd]
args = [baseCmd] + args
else:
cmd = [baseCmd]
output = run(
[baseCmd, "--version"],
cmd + args,
stdout=PIPE, stderr=PIPE,
encoding="utf-8"
)
features = output.stdout.split('\n')[1].split()[1:]

with open(path.join(baseDir, TESTFILE), "r") as file:
allTests = json.load(file)
testIndexesToRun = []

# if argv[1] exists and starts with int
cmdfilter = ""
testIndexesToRun = list(range(len(allTests)))
runWithValgrind = False
verboseDetail = False

if argc > 1:
for arg in argv[1:]:
if arg[0].isnumeric():
# run only test cases separated by ","
testIndexesToRun = []

for caseIndex in arg.split(","):
testIndexesToRun.append(int(caseIndex))
elif arg == "--with-valgrind":
runWithValgrind = True
elif arg == "--verbose":
verboseDetail = True
else:
cmdfilter = argv[1]

numTestsFailed = 0
numTestsPassed = 0
numTestsSkipped = 0
Expand All @@ -208,7 +229,7 @@ def main(argc, argv):
numTestsSkipped += 1
continue

test = TestCase(testIndex + 1, baseCmd, **allTests[testIndex])
test = TestCase(testIndex + 1, runnerCmd, baseCmd, **allTests[testIndex])

if test.runCommand(cmdfilter, runWithValgrind):
if test.test(): # passed
Expand Down
54 changes: 37 additions & 17 deletions tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -260,20 +260,36 @@
{
"input": {
"arguments": [
"http://curl.se:22/",
"-s",
"port=80"
]
},
"expected": {
"stdout": "http://curl.se/\n",
"stderr": "",
"returncode": 0
}
},
{
"input": {
"arguments": [
"--keep-port",
"https://curl.se:22/",
"-s",
"port=443"
]
},
"expected": {
"stdout": "https://curl.se/\n",
"stdout": "https://curl.se:443/\n",
"stderr": "",
"returncode": 0
}
},
{
"input": {
"arguments": [
"--keep-port",
"https://curl.se:22/",
"-s",
"port=443",
Expand All @@ -282,7 +298,7 @@
]
},
"expected": {
"stdout": "https://curl.se/\n",
"stdout": "https://curl.se:443/\n",
"stderr": "",
"returncode": 0
}
Expand All @@ -307,13 +323,13 @@
"arguments": [
"--default-port",
"--url",
"https://curl.se/we/are.html",
"http://curl.se/we/are.html",
"--get",
"{port}"
]
},
"expected": {
"stdout": "443\n",
"stdout": "80\n",
"stderr": "",
"returncode": 0
}
Expand Down Expand Up @@ -489,13 +505,13 @@
"input": {
"arguments": [
"--url",
"https://curl.se/we/are.html",
"http://curl.se/we/are.html",
"-g",
"{default:port}"
]
},
"expected": {
"stdout": "443\n",
"stdout": "80\n",
"stderr": "",
"returncode": 0
}
Expand Down Expand Up @@ -846,23 +862,25 @@
{
"input": {
"arguments": [
"--keep-port",
"https://hello:443/foo"
]
},
"expected": {
"stdout": "https://hello/foo\n",
"stdout": "https://hello:443/foo\n",
"stderr": "",
"returncode": 0
}
},
{
"input": {
"arguments": [
"--keep-port",
"ftp://hello:21/foo"
]
},
"expected": {
"stdout": "ftp://hello/foo\n",
"stdout": "ftp://hello:21/foo\n",
"stderr": "",
"returncode": 0
}
Expand All @@ -884,13 +902,14 @@
{
"input": {
"arguments": [
"--keep-port",
"ftp://hello:443/foo",
"-s",
"scheme=https"
]
},
"expected": {
"stdout": "https://hello/foo\n",
"stdout": "https://hello:443/foo\n",
"stderr": "",
"returncode": 0
}
Expand Down Expand Up @@ -1191,6 +1210,7 @@
{
"input": {
"arguments": [
"--keep-port",
"https://curl.se",
"--iterate",
"port=80 81 443"
Expand All @@ -1199,7 +1219,7 @@
"expected": {
"stderr": "",
"returncode": 0,
"stdout": "https://curl.se:80/\nhttps://curl.se:81/\nhttps://curl.se/\n"
"stdout": "https://curl.se:80/\nhttps://curl.se:81/\nhttps://curl.se:443/\n"
}
},
{
Expand Down Expand Up @@ -1656,17 +1676,17 @@
{
"input": {
"arguments": [
"imaps://user:password;crazy@[ff00::1234%hello]:1234/path?a=b&c=d#fragment",
"imap://user:password;crazy@[ff00::1234%hello]:1234/path?a=b&c=d#fragment",
"--json"
]
},
"expected": {
"returncode": 0,
"stdout": [
{
"url": "imaps://user:password;crazy@[ff00::1234%25hello]:1234/path?a=b&c=d#fragment",
"url": "imap://user:password;crazy@[ff00::1234%25hello]:1234/path?a=b&c=d#fragment",
"parts": {
"scheme": "imaps",
"scheme": "imap",
"user": "user",
"password": "password",
"options": "crazy",
Expand Down Expand Up @@ -2014,7 +2034,7 @@
"returncode": 0,
"stderr": ""
}
},
},
{
"input" : {
"arguments": [
Expand All @@ -2040,7 +2060,7 @@
}
]
}
]
]
}
},
{
Expand Down Expand Up @@ -2068,7 +2088,7 @@
}
]
}
]
]
}
},
{
Expand Down Expand Up @@ -2096,7 +2116,7 @@
}
]
}
]
]
}
},
{
Expand Down
Loading