-
Notifications
You must be signed in to change notification settings - Fork 104
added examples and py utils #159
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
97ee211
added examples and py utils
41984ce
readme tweaks
835e6b0
embedding example now also a test
cdf3d5b
Update examples/embedding/mylib.module.go
drew-512 3dff766
Update examples/embedding/main_test.go
drew-512 249e14e
Update examples/embedding/main_test.go
drew-512 76c8b51
Update examples/embedding/main_test.go
drew-512 17f2690
Update examples/embedding/main_test.go
drew-512 e0f7a11
Update examples/embedding/main_test.go
drew-512 4a49a6d
CI-friendly golden testing fixes
16ebe64
golden test output no longer platform specific
3d37384
Update examples/embedding/main_test.go
drew-512 ba0f3da
Update examples/embedding/main_test.go
drew-512 c67547f
Update examples/embedding/lib/mylib.py
drew-512 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
embedding example now also a test
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,4 @@ cover.out | |
|
|
||
| # tests | ||
| builtin/testfile | ||
| examples/embedding/embedding | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
|
|
||
| Welcome to a gpython embedded example, | ||
| where your wildest Go-based python dreams come true! | ||
|
|
||
| ========================================================== | ||
| Python 3.4 (github.com/go-python/gpython) | ||
| go1.17.6 on darwin amd64 | ||
| ========================================================== | ||
|
|
||
| Spring Break itinerary: | ||
| Stop 1: Miami, Florida | 7 nights | ||
| Stop 2: Mallorca, Spain | 3 nights | ||
| Stop 3: Ibiza, Spain | 14 nights | ||
| Stop 4: Monaco | 12 nights | ||
| ### Made with Vacaton 1.0 by Fletch F. Fletcher | ||
|
|
||
| I bet Monaco will be the best! | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "os" | ||
| "os/exec" | ||
| "testing" | ||
| ) | ||
|
|
||
| const embeddingTestOutput = "embedding-test-output.txt" | ||
|
|
||
| func TestEmbeddedExample(t *testing.T) { | ||
|
|
||
| cmd := exec.Command("go", "build", ".") | ||
|
drew-512 marked this conversation as resolved.
Outdated
|
||
| err := cmd.Run() | ||
| if err != nil { | ||
| t.Fatalf("failed to compile embedding example: %v", err) | ||
| } | ||
|
|
||
| out := new(bytes.Buffer) | ||
| cmd = exec.Command("./embedding", "mylib-demo.py") | ||
|
drew-512 marked this conversation as resolved.
Outdated
|
||
| cmd.Stdout = out | ||
|
|
||
| err = cmd.Run() | ||
| if err != nil { | ||
| t.Fatalf("failed to run embedding binary: %v", err) | ||
| } | ||
|
|
||
| resetTest := false // true | ||
| testOutput := out.Bytes() | ||
| if resetTest { | ||
| err = os.WriteFile(embeddingTestOutput, testOutput, 0644) | ||
| if err != nil { | ||
| t.Fatalf("failed to write test output: %v", err) | ||
| } | ||
| } else { | ||
|
drew-512 marked this conversation as resolved.
Outdated
|
||
| mustMatch, err := os.ReadFile(embeddingTestOutput) | ||
| if err != nil { | ||
| t.Fatalf("failed read %q", embeddingTestOutput) | ||
| } | ||
| if !bytes.Equal(testOutput, mustMatch) { | ||
| t.Fatalf("embedded test output did not match accepted output from %q", embeddingTestOutput) | ||
| } | ||
| } | ||
|
drew-512 marked this conversation as resolved.
|
||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.