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

test: add Actions annotation output #34590

Closed
wants to merge 2 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-asan.yml
Expand Up @@ -33,4 +33,4 @@ jobs:
- name: Build
run: make build-ci -j2 V=1
- name: Test
run: make run-ci -j2 V=1 TEST_CI_ARGS="-p dots"
run: make run-ci -j2 V=1 TEST_CI_ARGS="-p actions"
4 changes: 2 additions & 2 deletions .github/workflows/test-linux.yml
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Build
run: make build-ci -j2 V=1 CONFIG_FLAGS="--error-on-warn"
- name: Test
run: make run-ci -j2 V=1 TEST_CI_ARGS="-p dots"
run: make run-ci -j2 V=1 TEST_CI_ARGS="-p actions"

test-linux-with-quic:
runs-on: ubuntu-latest
Expand All @@ -39,4 +39,4 @@ jobs:
- name: Build
run: make build-ci -j2 V=1 CONFIG_FLAGS="--error-on-warn --experimental-quic"
- name: Test
run: make run-ci -j2 V=1 TEST_CI_ARGS="-p dots"
run: make run-ci -j2 V=1 TEST_CI_ARGS="-p actions"
2 changes: 1 addition & 1 deletion .github/workflows/test-macos.yml
Expand Up @@ -24,4 +24,4 @@ jobs:
- name: Build
run: make build-ci -j8 V=1 CONFIG_FLAGS="--error-on-warn --experimental-quic"
- name: Test
run: make run-ci -j8 V=1 TEST_CI_ARGS="-p dots"
run: make run-ci -j8 V=1 TEST_CI_ARGS="-p actions"
2 changes: 1 addition & 1 deletion test/parallel/test-http-outgoing-finish-writable.js
Expand Up @@ -9,7 +9,7 @@ const http = require('http');
const server = http.createServer(common.mustCall(function(req, res) {
assert.strictEqual(res.writable, true);
assert.strictEqual(res.finished, false);
assert.strictEqual(res.writableEnded, false);
assert.strictEqual(res.writableEnded, true);
res.end();

// res.writable is set to false after it has finished sending
Expand Down
49 changes: 37 additions & 12 deletions tools/test.py
Expand Up @@ -116,6 +116,25 @@ def __init__(self, cases, flaky_tests_mode):
self.lock = threading.Lock()
self.shutdown_event = threading.Event()

def GetFailureOutput(self, failure):
output = []
if failure.output.stderr:
output += ["--- stderr ---" ]
output += [failure.output.stderr.strip()]
if failure.output.stdout:
output += ["--- stdout ---"]
output += [failure.output.stdout.strip()]
output += ["Command: %s" % EscapeCommand(failure.command)]
if failure.HasCrashed():
output += ["--- %s ---" % PrintCrashed(failure.output.exit_code)]
if failure.HasTimedOut():
output += ["--- TIMEOUT ---"]
output = "\n".join(output)
return output

def PrintFailureOutput(self, failure):
print(self.GetFailureOutput(failure))

def PrintFailureHeader(self, test):
if test.IsNegative():
negative_marker = '[negative] '
Expand Down Expand Up @@ -224,17 +243,7 @@ def Done(self):
print()
for failed in self.failed:
self.PrintFailureHeader(failed.test)
if failed.output.stderr:
print("--- stderr ---")
print(failed.output.stderr.strip())
if failed.output.stdout:
print("--- stdout ---")
print(failed.output.stdout.strip())
print("Command: %s" % EscapeCommand(failed.command))
if failed.HasCrashed():
print("--- %s ---" % PrintCrashed(failed.output.exit_code))
if failed.HasTimedOut():
print("--- TIMEOUT ---")
self.PrintFailureOutput(failed)
if len(self.failed) == 0:
print("===")
print("=== All tests succeeded")
Expand Down Expand Up @@ -288,6 +297,21 @@ def HasRun(self, output):
sys.stdout.write('.')
sys.stdout.flush()

class ActionsAnnotationProgressIndicator(DotsProgressIndicator):
def GetAnnotationInfo(self, test, output):
traceback = output.stdout + output.stderr
find_full_path = re.search(r' +at .*\(.*%s:([0-9]+):([0-9]+)' % test.file, traceback)
col = line = 0
if find_full_path:
line, col = map(int, find_full_path.groups())
root_path = abspath(join(dirname(__file__), '../')) + os.sep
filename = test.file.replace(root_path, "")
return filename, line, col

def PrintFailureOutput(self, failure):
output = self.GetFailureOutput(failure)
filename, line, column = self.GetAnnotationInfo(failure.test, failure.output)
print("::error file=%s,line=%d,col=%d::%s" % (filename, line, column, output.replace('\n', '%0A')))

class TapProgressIndicator(SimpleProgressIndicator):

Expand Down Expand Up @@ -496,6 +520,7 @@ def ClearLine(self, last_line_length):
PROGRESS_INDICATORS = {
'verbose': VerboseProgressIndicator,
'dots': DotsProgressIndicator,
'actions': ActionsAnnotationProgressIndicator,
'color': ColorProgressIndicator,
'tap': TapProgressIndicator,
'mono': MonochromeProgressIndicator,
Expand Down Expand Up @@ -1299,7 +1324,7 @@ def BuildOptions():
result.add_option('--logfile', dest='logfile',
help='write test output to file. NOTE: this only applies the tap progress indicator')
result.add_option("-p", "--progress",
help="The style of progress indicator (verbose, dots, color, mono, tap)",
help="The style of progress indicator (%s)" % ", ".join(PROGRESS_INDICATORS.keys()),
choices=list(PROGRESS_INDICATORS.keys()), default="mono")
result.add_option("--report", help="Print a summary of the tests to be run",
default=False, action="store_true")
Expand Down