Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
b6b5ab88
Unverified
Commit
b6b5ab88
authored
Nov 19, 2024
by
Niklas Mischkulnig
Committed by
GitHub
Nov 19, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turbopack: apply effects in tests (#72952)
https://github.com/vercel/next.js/pull/72847
missed this
parent
8856f49f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
21 deletions
+45
-21
execution.rs
turbopack/crates/turbopack-tests/tests/execution.rs
+21
-8
snapshot.rs
turbopack/crates/turbopack-tests/tests/snapshot.rs
+24
-13
No files found.
turbopack/crates/turbopack-tests/tests/execution.rs
View file @
b6b5ab88
...
@@ -12,7 +12,7 @@ use dunce::canonicalize;
...
@@ -12,7 +12,7 @@ use dunce::canonicalize;
use
serde
::{
Deserialize
,
Serialize
};
use
serde
::{
Deserialize
,
Serialize
};
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
use
turbo_tasks
::{
debug
::
ValueDebugFormat
,
fxindexmap
,
trace
::
TraceRawVcs
,
Completion
,
ResolvedVc
,
apply_effects
,
debug
::
ValueDebugFormat
,
fxindexmap
,
trace
::
TraceRawVcs
,
Completion
,
ResolvedVc
,
TryJoinIterExt
,
TurboTasks
,
Value
,
Vc
,
TryJoinIterExt
,
TurboTasks
,
Value
,
Vc
,
};
};
use
turbo_tasks_bytes
::
stream
::
SingleValue
;
use
turbo_tasks_bytes
::
stream
::
SingleValue
;
...
@@ -66,6 +66,8 @@ struct JsResult {
...
@@ -66,6 +66,8 @@ struct JsResult {
jest_result
:
JestRunResult
,
jest_result
:
JestRunResult
,
}
}
#[turbo_tasks
::
value]
#[derive(Copy,
Clone,
Debug,
Hash)]
enum
IssueSnapshotMode
{
enum
IssueSnapshotMode
{
Snapshots
,
Snapshots
,
NoSnapshots
,
NoSnapshots
,
...
@@ -168,16 +170,27 @@ async fn run(resource: PathBuf, snapshot_mode: IssueSnapshotMode) -> Result<JsRe
...
@@ -168,16 +170,27 @@ async fn run(resource: PathBuf, snapshot_mode: IssueSnapshotMode) -> Result<JsRe
let
tt
=
TurboTasks
::
new
(
MemoryBackend
::
default
());
let
tt
=
TurboTasks
::
new
(
MemoryBackend
::
default
());
tt
.run_once
(
async
move
{
tt
.run_once
(
async
move
{
let
resource_str
=
resource
.to_str
()
.unwrap
();
let
emit
=
run_inner
(
resource
.to_str
()
.unwrap
()
.into
(),
Value
::
new
(
snapshot_mode
));
let
prepared_test
=
prepare_test
(
resource_str
.into
());
let
result
=
emit
.strongly_consistent
()
.await
?
;
apply_effects
(
emit
)
.await
?
;
Ok
(
result
.clone_value
())
})
.await
}
#[turbo_tasks
::
function]
async
fn
run_inner
(
resource
:
RcStr
,
snapshot_mode
:
Value
<
IssueSnapshotMode
>
,
)
->
Result
<
Vc
<
JsResult
>>
{
let
prepared_test
=
prepare_test
(
resource
);
let
run_result
=
run_test
(
prepared_test
);
let
run_result
=
run_test
(
prepared_test
);
if
matches!
(
snapshot_mode
,
IssueSnapshotMode
::
Snapshots
)
{
if
*
snapshot_mode
==
IssueSnapshotMode
::
Snapshots
{
snapshot_issues
(
prepared_test
,
run_result
)
.await
?
;
snapshot_issues
(
prepared_test
,
run_result
)
.await
?
;
}
}
Ok
((
*
run_result
.await
.unwrap
()
.js_result.await
.unwrap
())
.clone
())
Ok
(
run_result
.await
?
.js_result
)
})
.await
}
}
#[derive(PartialEq,
Eq,
Debug,
Default,
Serialize,
Deserialize,
TraceRawVcs,
ValueDebugFormat)]
#[derive(PartialEq,
Eq,
Debug,
Default,
Serialize,
Deserialize,
TraceRawVcs,
ValueDebugFormat)]
...
...
turbopack/crates/turbopack-tests/tests/snapshot.rs
View file @
b6b5ab88
...
@@ -15,7 +15,8 @@ use serde::Deserialize;
...
@@ -15,7 +15,8 @@ use serde::Deserialize;
use
serde_json
::
json
;
use
serde_json
::
json
;
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
use
turbo_tasks
::{
ReadConsistency
,
ReadRef
,
ResolvedVc
,
TryJoinIterExt
,
TurboTasks
,
Value
,
ValueToString
,
Vc
,
apply_effects
,
ReadConsistency
,
ReadRef
,
ResolvedVc
,
TryJoinIterExt
,
TurboTasks
,
Value
,
ValueToString
,
Vc
,
};
};
use
turbo_tasks_env
::
DotenvProcessEnv
;
use
turbo_tasks_env
::
DotenvProcessEnv
;
use
turbo_tasks_fs
::{
use
turbo_tasks_fs
::{
...
@@ -156,7 +157,21 @@ async fn run(resource: PathBuf) -> Result<()> {
...
@@ -156,7 +157,21 @@ async fn run(resource: PathBuf) -> Result<()> {
let
tt
=
TurboTasks
::
new
(
MemoryBackend
::
default
());
let
tt
=
TurboTasks
::
new
(
MemoryBackend
::
default
());
let
task
=
tt
.spawn_once_task
(
async
move
{
let
task
=
tt
.spawn_once_task
(
async
move
{
let
out
=
run_test
(
resource
.to_str
()
.unwrap
()
.into
());
let
emit
=
run_inner
(
resource
.to_str
()
.unwrap
()
.into
());
emit
.strongly_consistent
()
.await
?
;
apply_effects
(
emit
)
.await
?
;
Ok
(
Vc
::
<
()
>
::
default
())
});
tt
.wait_task_completion
(
task
,
ReadConsistency
::
Strong
)
.await
?
;
Ok
(())
}
#[turbo_tasks
::
function]
async
fn
run_inner
(
resource
:
RcStr
)
->
Result
<
()
>
{
let
out
=
run_test
(
resource
);
let
_
=
out
.resolve_strongly_consistent
()
.await
?
;
let
_
=
out
.resolve_strongly_consistent
()
.await
?
;
let
captured_issues
=
out
.peek_issues_with_path
()
.await
?
;
let
captured_issues
=
out
.peek_issues_with_path
()
.await
?
;
...
@@ -169,10 +184,6 @@ async fn run(resource: PathBuf) -> Result<()> {
...
@@ -169,10 +184,6 @@ async fn run(resource: PathBuf) -> Result<()> {
snapshot_issues
(
plain_issues
,
out
.join
(
"issues"
.into
()),
&
REPO_ROOT
)
snapshot_issues
(
plain_issues
,
out
.join
(
"issues"
.into
()),
&
REPO_ROOT
)
.await
.await
.context
(
"Unable to handle issues"
)
?
;
.context
(
"Unable to handle issues"
)
?
;
Ok
(
Vc
::
<
()
>
::
default
())
});
tt
.wait_task_completion
(
task
,
ReadConsistency
::
Strong
)
.await
?
;
Ok
(())
Ok
(())
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment