GeezerVison is showing github.com — Compute the exit status of `tsc -b` for the whole build by unalivin · Pull Request #65719 · microsoft/TypeScript
Compute the exit status of tsc -b for the whole build
#65719
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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.go
(4)
.js
(150)
All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -46,6 +46,7 @@ type taskResult struct {
builder strings.Builder
reportStatus tsc.DiagnosticReporter
diagnosticReporter tsc.DiagnosticReporter
hasDiagnostics bool
exitStatus tsc.ExitStatus
statistics *tsc.Statistics
program *incremental.Program
Expand Down
Expand Up
@@ -120,6 +121,7 @@ func (t *BuildTask) unblockDownstream() {
func (t *BuildTask) reportDiagnostic(err *ast.Diagnostic) {
t.errors = append(t.errors, err)
t.result.hasDiagnostics = true
t.result.diagnosticReporter(err)
}
Expand All
@@ -134,6 +136,9 @@ func (t *BuildTask) report(orchestrator *Orchestrator, configPath tspath.PathKey
if t.result.statistics != nil {
buildResult.Statistics.Aggregate(t.result.statistics)
}
if t.result.buildKind != buildKindNone && !t.result.hasDiagnostics {
buildResult.successfulProjects++
}
// If we built the program, or updated timestamps, or had errors, we need to
// delete files that are no longer needed
switch t.result.buildKind {
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -30,10 +30,11 @@ type Options struct {
Testing tsc.CommandLineTesting
}
type OrchestratorResult struct {
Result tsc.CommandLineResult
Errors []*ast.Diagnostic
Statistics tsc.Statistics
FilesToDelete []tspath.RootedFilePath
Result tsc.CommandLineResult
Errors []*ast.Diagnostic
successfulProjects int
Statistics tsc.Statistics
FilesToDelete []tspath.RootedFilePath
}
func (b *OrchestratorResult) report(o *Orchestrator) {
Expand Down
Expand Up
@@ -1016,6 +1017,14 @@ func (o *Orchestrator) buildOrCleanOrder(ctx context.Context, order []*BuildTask
buildResult.Result.Status = tsc.ExitStatusCancelled
} else {
buildResult.report(o)
if buildResult.Result.Status == tsc.ExitStatusDiagnosticsPresent_OutputsSkipped ||
buildResult.Result.Status == tsc.ExitStatusDiagnosticsPresent_OutputsGenerated {
buildResult.Result.Status = core.IfElse(
buildResult.successfulProjects > 0,
tsc.ExitStatusDiagnosticsPresent_OutputsGenerated,
tsc.ExitStatusDiagnosticsPresent_OutputsSkipped,
)
}
}
return buildResult
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -10,6 +10,7 @@ import (
"testing/synctest"
"github.com/microsoft/TypeScript/tsc/internal/contentmapper"
"github.com/microsoft/TypeScript/tsc/internal/core"
"github.com/microsoft/TypeScript/tsc/internal/execute"
"github.com/microsoft/TypeScript/tsc/internal/execute/tsc"
"github.com/microsoft/TypeScript/tsc/internal/fswatch"
Expand Down
Expand Up
@@ -190,7 +191,7 @@ func TestContentMapperIncludeIncrementalEmit(t *testing.T) {
result := execute.CommandLine(t.Context(), sys, args, testSys)
expected := tsc.ExitStatusSuccess
if !runtimeMapping {
expected = tsc.ExitStatusDiagnosticsPresent_OutputsGenerated
expected = core.IfElse(build, tsc.ExitStatusDiagnosticsPresent_OutputsSkipped, tsc. ExitStatusDiagnosticsPresent_OutputsGenerated)
assert.Assert(t, strings.Contains(testSys.currentWrite.String(), "TS18133"), testSys.currentWrite.String())
}
assert.Equal(t, result.Status, expected, testSys.currentWrite.String())
Expand Down
Expand Up
@@ -258,7 +259,7 @@ func TestContentMapperBuildDetectsNewPhysicalSupplementalFile(t *testing.T) {
testSys.clearOutput()
testSys.writeFileNoError(supplementalFileName, "export {};\n")
result = execute.CommandLine(t.Context(), sys, args, testSys)
assert.Equal(t, result.Status, tsc.ExitStatusDiagnosticsPresent_OutputsGenerated )
assert.Equal(t, result.Status, tsc.ExitStatusDiagnosticsPresent_OutputsSkipped )
assert.Assert(t, strings.Contains(testSys.currentWrite.String(), "TS18069"), testSys.currentWrite.String())
assert.Assert(t, strings.Contains(testSys.currentWrite.String(), "conflicts with an existing file"), testSys.currentWrite.String())
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -555,6 +555,67 @@ func TestBuildContentMapperOptionDiagnostics(t *testing.T) {
}).run(t, "contentMapperOptionDiagnostics")
}
func TestBuildExitStatusForTypeErrors(t *testing.T) {
t.Parallel()
files := func(indexCode string) FileMap {
return FileMap{
"/home/src/workspaces/project/tsconfig.json": `{}`,
"/home/src/workspaces/project/index.ts": indexCode,
}
}
const typeError = `export const count: number = "zero";`
const cleanCode = `export const count: number = 1;`
t.Run("build reports diagnostics as outputs skipped", func(t *testing.T) {
t.Parallel()
sys := newTestSys(&tscInput{files: files(typeError)}, false)
result := execute.CommandLine(t.Context(), sys, []string{"--build"}, sys)
assert.Equal(t, result.Status, tsc.ExitStatusDiagnosticsPresent_OutputsSkipped)
})
t.Run("non-build reports diagnostics as outputs generated", func(t *testing.T) {
t.Parallel()
sys := newTestSys(&tscInput{files: files(typeError)}, false)
result := execute.CommandLine(t.Context(), sys, []string{"--project", "/home/src/workspaces/project"}, sys)
assert.Equal(t, result.Status, tsc.ExitStatusDiagnosticsPresent_OutputsGenerated)
})
t.Run("build without diagnostics succeeds", func(t *testing.T) {
t.Parallel()
sys := newTestSys(&tscInput{files: files(cleanCode)}, false)
result := execute.CommandLine(t.Context(), sys, []string{"--build"}, sys)
assert.Equal(t, result.Status, tsc.ExitStatusSuccess)
})
for _, noEmitOnError := range []bool{false, true} {
t.Run(fmt.Sprintf("build reports outputs generated if any project builds/noEmitOnError=%t", noEmitOnError), func(t *testing.T) {
t.Parallel()
sys := newTestSys(&tscInput{files: FileMap{
"/home/src/workspaces/project/tsconfig.json": `{ "files": [], "references": [{ "path": "./good" }, { "path": "./bad" }] }`,
"/home/src/workspaces/project/good/tsconfig.json": `{ "compilerOptions": { "composite": true } }`,
"/home/src/workspaces/project/good/index.ts": cleanCode,
"/home/src/workspaces/project/bad/tsconfig.json": fmt.Sprintf(`{ "compilerOptions": { "composite": true, "noEmitOnError": %t } }`, noEmitOnError),
"/home/src/workspaces/project/bad/index.ts": typeError,
}}, false)
result := execute.CommandLine(t.Context(), sys, []string{"--build"}, sys)
assert.Equal(t, result.Status, tsc.ExitStatusDiagnosticsPresent_OutputsGenerated)
})
}
t.Run("build reports outputs skipped if every project reports diagnostics", func(t *testing.T) {
t.Parallel()
sys := newTestSys(&tscInput{files: FileMap{
"/home/src/workspaces/project/tsconfig.json": `{ "files": [], "references": [{ "path": "./a" }, { "path": "./b" }] }`,
"/home/src/workspaces/project/a/tsconfig.json": `{ "compilerOptions": { "composite": true } }`,
"/home/src/workspaces/project/a/index.ts": typeError,
"/home/src/workspaces/project/b/tsconfig.json": `{ "compilerOptions": { "composite": true } }`,
"/home/src/workspaces/project/b/index.ts": typeError,
}}, false)
result := execute.CommandLine(t.Context(), sys, []string{"--build"}, sys)
assert.Equal(t, result.Status, tsc.ExitStatusDiagnosticsPresent_OutputsSkipped)
})
}
func TestBuildClean(t *testing.T) {
t.Parallel()
testCases := []*tscInput{
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -352,7 +352,7 @@ Signatures::
Edit [0]:: no change
tsc --b project2/src --verbose
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* project1/src/tsconfig.json
Expand Down
Expand Up
@@ -837,7 +837,7 @@ Signatures::
Edit [3]:: no change
tsc --b project2/src --verbose
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* project1/src/tsconfig.json
Expand Down
Expand Up
@@ -872,7 +872,7 @@ Signatures::
Edit [4]:: no change run with js emit
tsc --b project2/src --verbose --emitDeclarationOnly false
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* project1/src/tsconfig.json
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -177,7 +177,7 @@ Signatures::
Edit [0]:: no change
tsc --b project2/src --verbose
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* project1/src/tsconfig.json
Expand Down
Expand Up
@@ -361,7 +361,7 @@ Signatures::
Edit [3]:: no change
tsc --b project2/src --verbose
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* project1/src/tsconfig.json
Expand Down
Expand Up
@@ -401,7 +401,7 @@ Signatures::
Edit [4]:: no change run with js emit
tsc --b project2/src --verbose --emitDeclarationOnly false
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* project1/src/tsconfig.json
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -352,7 +352,7 @@ Signatures::
Edit [0]:: no change
tsc --b project2/src --verbose --emitDeclarationOnly
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* project1/src/tsconfig.json
Expand Down
Expand Up
@@ -1120,7 +1120,7 @@ Signatures::
Edit [4]:: no change
tsc --b project2/src --verbose --emitDeclarationOnly
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* project1/src/tsconfig.json
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -177,7 +177,7 @@ Signatures::
Edit [0]:: no change
tsc --b project2/src --verbose --emitDeclarationOnly
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* project1/src/tsconfig.json
Expand Down
Expand Up
@@ -424,7 +424,7 @@ Signatures::
Edit [4]:: no change
tsc --b project2/src --verbose --emitDeclarationOnly
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* project1/src/tsconfig.json
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -32,7 +32,7 @@ export declare const input: { value: string };
}
tsc --build producer --verbose
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* producer/tsconfig.json
Expand Down
Expand Up
@@ -184,7 +184,7 @@ Signatures::
Edit [0]:: no change
tsc --build producer --verbose
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* producer/tsconfig.json
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -195,7 +195,7 @@ Edit [1]:: change allowArbitraryExtensions without changing source files
}
tsc --build producer --verbose
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* producer/tsconfig.json
Expand Down
Expand Up
@@ -324,7 +324,7 @@ Signatures::
Edit [2]:: no change
tsc --build producer --verbose
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* producer/tsconfig.json
Expand All
@@ -350,7 +350,7 @@ Signatures::
Edit [3]:: force rebuild with the same compiler options
tsc --build producer --verbose --force
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* producer/tsconfig.json
Expand Down
Expand Up
@@ -383,7 +383,7 @@ Signatures::
Edit [4]:: no change
tsc --build producer --verbose
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* producer/tsconfig.json
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -181,7 +181,7 @@ Edit [1]:: change importHelpers without changing source files
}
tsc --build producer --verbose
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* producer/tsconfig.json
Expand Down
Expand Up
@@ -289,7 +289,7 @@ Signatures::
Edit [2]:: no change
tsc --build producer --verbose
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* producer/tsconfig.json
Expand All
@@ -315,7 +315,7 @@ Signatures::
Edit [3]:: force rebuild with the same compiler options
tsc --build producer --verbose --force
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* producer/tsconfig.json
Expand Down
Expand Up
@@ -348,7 +348,7 @@ Signatures::
Edit [4]:: no change
tsc --build producer --verbose
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* producer/tsconfig.json
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -52,7 +52,7 @@ export async function result() { return 1; }
}
tsc --build producer --verbose
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* producer/tsconfig.json
Expand Down
Expand Up
@@ -164,7 +164,7 @@ Signatures::
Edit [0]:: no change
tsc --build producer --verbose
ExitStatus:: DiagnosticsPresent_OutputsGenerated
ExitStatus:: DiagnosticsPresent_OutputsSkipped
Output::
[[90mHH:MM:SS AM[0m] Projects in this build:
* producer/tsconfig.json
Expand Down
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.