-
Notifications
You must be signed in to change notification settings - Fork 27
Enhance Go testing support and add integration tests #332
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,11 +2,16 @@ subinclude("///e2e//build_defs:e2e") | |
|
|
||
| _please_repo_e2e_test = please_repo_e2e_test | ||
|
|
||
| def please_repo_e2e_test(name, expected_output=None, plz_command, repo, labels=[]): | ||
| def please_repo_e2e_test(name, expected_output=None, plz_command, repo, labels=[], expect_output_contains=None): | ||
|
||
| plz_cmd = plz_command.replace("plz ", "plz -o please.PluginRepo:file://$TMP_DIR/$DATA_PLUGIN_REPO -o plugin.go.gotool:$TOOLS_GO -o plugin.go.pleasegotool:$TOOLS_PLEASE_GO ") | ||
| # Persist command output so subsequent assertions can inspect it while keeping the original exit code. | ||
| wrapped_plz_command = f"( {plz_cmd} >output 2>&1 ); STATUS=$?; cat output; exit $STATUS" | ||
|
|
||
| return _please_repo_e2e_test( | ||
| name = name, | ||
| expected_output = expected_output, | ||
| plz_command = plz_command.replace("plz ", "plz -o please.PluginRepo:file://$TMP_DIR/$DATA_PLUGIN_REPO -o plugin.go.gotool:$TOOLS_GO -o plugin.go.pleasegotool:$TOOLS_PLEASE_GO "), | ||
| expect_output_contains = expect_output_contains, | ||
| plz_command = wrapped_plz_command, | ||
| repo = repo, | ||
| data = { | ||
| "PLUGIN_REPO": ["//test:export"], | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| [Parse] | ||
| BuildFileName = BUILD_FILE | ||
| BuildFileName = BUILD | ||
scyyx5 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| PreloadSubincludes = ///go//build_defs:go | ||
|
|
||
| [Plugin "go"] | ||
| Target = //plugins:go | ||
| Stdlib = //third_party/go:std | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| plugin_repo( | ||
| name = "go", | ||
| revision = "master", | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| go_test( | ||
| name = "testing_flag_test", | ||
| srcs = ["testing_flag_test.go"], | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package sample | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestTestingFlag(t *testing.T) { | ||
| fmt.Printf("testing.Testing() = %v\n", testing.Testing()) | ||
| if !testing.Testing() { | ||
| t.Fatalf("expected testing.Testing() to be true") | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| go_stdlib( | ||
| name = "std", | ||
| ) |
Uh oh!
There was an error while loading. Please reload this page.