-
Notifications
You must be signed in to change notification settings - Fork 119
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
[WIP] E2E tests #218
Merged
Merged
[WIP] E2E tests #218
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2a2d8f0
add e2e tests
NyxCode fdeb8c8
split CI into multiple jobs
NyxCode 317eb9e
Merge branch 'main' into e2e
NyxCode 3fa1d4b
implement POC
NyxCode 3e2b8cf
fix missing import
NyxCode 2375fbf
remove old dependency implementation, fix warnings
NyxCode ab569e4
recursively export all dependencies
NyxCode 646ccd9
use stupidly large types in E2E test - maybe it fails on CI?
NyxCode 3de39ab
Separate recursive exporting into mod
escritorio-gustavo d9464e3
Merge branch 'typelist' of github.com:Aleph-Alpha/ts-rs into typelist
escritorio-gustavo dcec4d8
introduce mutex for file exports, change array tuple limit to 64
NyxCode 8eb28e5
Merge pull request #221 from Aleph-Alpha/typelist
escritorio-gustavo 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
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/target | ||
target/ | ||
Cargo.lock | ||
/.idea | ||
*.ts | ||
|
This file contains 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,8 @@ | ||
# e2e tests | ||
### [dependencies](./dependencies) | ||
A user creates the crate `consumer`, which depends on some crate `dependency1`, which possibly lives on [crates.io](https://crates.io). | ||
If a struct in `consumer` contains a type from `dependency1`, it should be exported as well. | ||
|
||
### [workspace](./workspace) | ||
A user creates a workspace, containing `crate1`, `crate2`, and `parent`. | ||
`crate1` and `crate2` are independent, but `parent` depends on both `crate1` and `crate2`. |
This file contains 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,10 @@ | ||
[package] | ||
name = "consumer" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[workspace] | ||
|
||
[dependencies] | ||
ts-rs = { path = "../../../ts-rs" } | ||
dependency1 = { path = "../dependency1" } |
This file contains 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,10 @@ | ||
use ts_rs::TS; | ||
use dependency1::LibraryType; | ||
|
||
#[derive(TS)] | ||
#[ts(export)] | ||
struct ConsumerType { | ||
pub ty: LibraryType | ||
} | ||
|
||
fn main() {} |
This file contains 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,9 @@ | ||
[package] | ||
name = "dependency1" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[workspace] | ||
|
||
[dependencies] | ||
ts-rs = { path = "../../../ts-rs" } |
This file contains 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,6 @@ | ||
use ts_rs::TS; | ||
|
||
#[derive(TS)] | ||
pub struct LibraryType { | ||
pub a: i32 | ||
} | ||
This file contains 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,2 @@ | ||
[workspace] | ||
members = ["crate1", "crate2", "parent"] |
This file contains 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,7 @@ | ||
[package] | ||
name = "crate1" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
ts-rs = { path = "../../../ts-rs" } |
This file contains 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,6 @@ | ||
use ts_rs::TS; | ||
|
||
#[derive(TS)] | ||
pub struct Crate1 { | ||
pub x: [[[i32; 128]; 128]; 128], | ||
} |
This file contains 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,7 @@ | ||
[package] | ||
name = "crate2" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
ts-rs = { path = "../../../ts-rs" } |
This file contains 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,6 @@ | ||
use ts_rs::TS; | ||
|
||
#[derive(TS)] | ||
pub struct Crate2 { | ||
pub x: [[[i32; 128]; 128]; 128], | ||
} |
This file contains 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,9 @@ | ||
[package] | ||
name = "parent" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
ts-rs = { path = "../../../ts-rs" } | ||
crate1 = { path = "../crate1" } | ||
crate2 = { path = "../crate2" } |
This file contains 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,98 @@ | ||
use ts_rs::TS; | ||
use crate1::Crate1; | ||
use crate2::Crate2; | ||
|
||
fn main() { | ||
println!("Hello, world!"); | ||
} | ||
|
||
#[derive(TS)] | ||
#[ts(export)] | ||
pub struct Parent { | ||
pub crate1: Crate1, | ||
pub crate2: Crate2, | ||
} | ||
#[derive(TS)] | ||
#[ts(export)] | ||
pub struct Parent2 { | ||
pub crate1: Crate1, | ||
pub crate2: Crate2, | ||
} | ||
#[derive(TS)] | ||
#[ts(export)] | ||
pub struct Parent3 { | ||
pub crate1: Crate1, | ||
pub crate2: Crate2, | ||
} | ||
#[derive(TS)] | ||
#[ts(export)] | ||
pub struct Parent4 { | ||
pub crate1: Crate1, | ||
pub crate2: Crate2, | ||
} | ||
#[derive(TS)] | ||
#[ts(export)] | ||
pub struct Parent5 { | ||
pub crate1: Crate1, | ||
pub crate2: Crate2, | ||
} | ||
#[derive(TS)] | ||
#[ts(export)] | ||
pub struct Parent6 { | ||
pub crate1: Crate1, | ||
pub crate2: Crate2, | ||
} | ||
#[derive(TS)] | ||
#[ts(export)] | ||
pub struct Parent7 { | ||
pub crate1: Crate1, | ||
pub crate2: Crate2, | ||
} | ||
#[derive(TS)] | ||
#[ts(export)] | ||
pub struct Parent8 { | ||
pub crate1: Crate1, | ||
pub crate2: Crate2, | ||
} | ||
#[derive(TS)] | ||
#[ts(export)] | ||
pub struct Parent9 { | ||
pub crate1: Crate1, | ||
pub crate2: Crate2, | ||
} | ||
#[derive(TS)] | ||
#[ts(export)] | ||
pub struct Parent10 { | ||
pub crate1: Crate1, | ||
pub crate2: Crate2, | ||
} | ||
#[derive(TS)] | ||
#[ts(export)] | ||
pub struct Parent11 { | ||
pub crate1: Crate1, | ||
pub crate2: Crate2, | ||
} | ||
#[derive(TS)] | ||
#[ts(export)] | ||
pub struct Parent12 { | ||
pub crate1: Crate1, | ||
pub crate2: Crate2, | ||
} | ||
#[derive(TS)] | ||
#[ts(export)] | ||
pub struct Parent13 { | ||
pub crate1: Crate1, | ||
pub crate2: Crate2, | ||
} | ||
#[derive(TS)] | ||
#[ts(export)] | ||
pub struct Parent14 { | ||
pub crate1: Crate1, | ||
pub crate2: Crate2, | ||
} | ||
#[derive(TS)] | ||
#[ts(export)] | ||
pub struct Parent15 { | ||
pub crate1: Crate1, | ||
pub crate2: Crate2, | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, since this type doesn't contain
#[export]
we'd have to come up with some other way to export it in the consumer crateThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right! I'm not sure about how to exactly solve this yet - maybe a
#[ts(export)]
type should cause all of its dependencies to be exported as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd have to make sure it's only exported once, even if the same type is used in a bunch of places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this might be confusing, as the user is not explicitly
#[ts(export)]
ing the typeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem in that scenario is that the user just cant explicitly export it, since it's in an other crate that may not be under his control.
That's true, this might be the biggest challenge here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is true, and it brings up the question I asked in #211:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(let's maybe have this discussion here then)
I think it'd be a good idea to support that, yeah! These libraries would probably never
#[ts(export)]
, but making their types implementTS
might be usefull in some cases, I think.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Speaking of which, this is getting hard to follow across two PRs, I opened a discussion (#219) to centralize this