Skip to content

Commit 953c2da

Browse files
committed
Use the provided crate type when running tests
Fixes #982
1 parent dccf0e8 commit 953c2da

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require 'spec_helper'
2+
require 'support/editor'
3+
require 'support/playground_actions'
4+
5+
RSpec.feature "Testing the code", type: :feature, js: true do
6+
include PlaygroundActions
7+
8+
before { visit '/' }
9+
10+
scenario "when a crate type is provided" do
11+
code = <<~EOF
12+
#![crate_type = "proc-macro"]
13+
14+
use proc_macro::TokenStream;
15+
16+
#[proc_macro]
17+
pub fn demo(input: TokenStream) -> TokenStream {
18+
input
19+
}
20+
EOF
21+
editor.set(code)
22+
23+
in_build_menu { click_on(build_button: "Test") }
24+
within(:output, :stdout) do
25+
expect(page).to have_content "running 0 tests"
26+
end
27+
end
28+
29+
def editor
30+
Editor.new(page)
31+
end
32+
end

ui/frontend/actions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,11 @@ function performAutoOnly(): ThunkAction {
263263

264264
const performExecuteOnly = (): ThunkAction => performCommonExecute('bin', false);
265265
const performCompileOnly = (): ThunkAction => performCommonExecute('lib', false);
266-
const performTestOnly = (): ThunkAction => performCommonExecute('lib', true);
266+
const performTestOnly = (): ThunkAction => (dispatch, getState) => {
267+
const state = getState();
268+
const crateType = getCrateType(state);
269+
return dispatch(performCommonExecute(crateType, true));
270+
};
267271

268272
interface GenericApiFailure {
269273
error: string;

0 commit comments

Comments
 (0)