How do I fix material-yew use declaration? - rust

I tried to do a hello world with material-yew.
I tried to add this use declaration according to Material Yew's home page.
use material_yew::MatButton;
I've also tried this version that I've also seen in the docs:
use material_yew::button::MatButton;
But both of them give a similar error:
error[E0432]: unresolved import material_yew::MatButton
I have these in my Cargo.toml:
[dependencies]
yew = "0.19.3"
material-yew = "0.2.0"
And I'm using trunk serve to run the app.

You need to enable the button feature (or the full feature that implies it):
material-yew = { version = "0.2.0", features = ["button"] }

Related

could not find yew in stylist

I'm new to rust and yew and trying to use stylist crate with yew but when I try to import styled_components, I am getting following error.
error[E0432]: unresolved import `stylist::yew`
--> src\lib.rs:2:14
|
2 | use stylist::yew::styled_component;
| ^^^ could not find `yew` in `stylist`
For more information about this error, try `rustc --explain E0432`.
error: could not compile `hello-yew` due to previous error
2022-11-22T16:30:53.476368Z ERROR error
error from HTML pipeline
Has anyone seen this issue before?
I tried to delete previous stylist crates and tried to re-install the crate again but faced same issue.
From the docs:
Yew Integration
To enable yew integration. Enable feature yew_integration in Cargo.toml.
You can create a style and use it with yew like this:
use yew::prelude::*;
use stylist::yew::styled_component;
#[styled_component(MyStyledComponent)]
fn my_styled_component() -> Html {
html! {<div class={css!("color: red;")}>{"Hello World!"}</div>}
}

Pitest is failing showing: No mutations found due to the supplied classpath or filters + Gradle

I'm trying to run a pitest report on a gradle + kotlin project, but I get the following error:
Exception in thread "main" org.pitest.help.PitHelpError: No mutations found. This probably means there is an issue with either the supplied classpath or filters.
See http://pitest.org for more details.
at org.pitest.mutationtest.tooling.MutationCoverage.checkMutationsFound(MutationCoverage.java:352)
at org.pitest.mutationtest.tooling.MutationCoverage.runReport(MutationCoverage.java:132)
at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:123)
at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:54)
at org.pitest.mutationtest.commandline.MutationCoverageReport.runReport(MutationCoverageReport.java:98)
at org.pitest.mutationtest.commandline.MutationCoverageReport.main(MutationCoverageReport.java:45)
I tried everything that I found on google but still not working for me:
This is my build.gradle config
plugins {
id 'groovy-gradle-plugin'
id 'info.solidsoft.pitest' version '1.7.4'
}
repositories {
maven { url "https://plugins.gradle.org/m2/" }
gradlePluginPortal()
}
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20'
implementation 'com.github.jengelman.gradle.plugins:shadow:6.1.0'
}
pitest {
targetClasses = ['com.project.root.to.test.with.pitest.src*'] //by default
"${project.group}.*"
pitestVersion = '1.7.4' //not needed when a default PIT version should be used
threads = 4
outputFormats = ['XML', 'HTML']
timestampedReports = false
}
I tried this targetClasses in a different ways:
targetClasses = ['com.project.root.to.test.with.pitest.src.*'] //by default
targetClasses = ['com/project/root/to/test/with/pitest/src*'] //by default
Can someone help me, please?
You look to be trying to supply pitest with a source folder
com.project.root.to.test.with.pitest.src.
Pitest works against the compiled bytecode, not the source files. It expects
a glob that matches against the package.
com.example.*
I've experienced this same issue today. You'll need to make sure all references to pitest use the same version 1.7.4. This includes
plugin: id 'info.solidsoft.pitest' version '1.7.4'
pitestVersion: pitestVersion.set('1.7.4')
dependency: testCompile
'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.7.4'
Which out changing all references, then it will break.

found a virtual manifest at <path> instead of a package manifest

I searched for [rust] "instead of a package manifest" on this site before asking and found no hits. I also read about virtual manifests here but did not resolve my question.
My goal is to make changes to azul.
To achieve this I read about patching dependencies here, and now I have this Cargo.toml
[package]
name = "my_first_azul_app"
version = "0.1.0"
authors = ["Name <Email>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
azul = { git = "https://github.com/maps4print/azul" }
[patch."https://github.com/maps4print/azul"]
azul = { path = "../azul" }
In path ../azul I have checked out the azul project with git clone. In main.rs I have followed this to get,
extern crate azul;
fn main() {
println!("Hello world!");
}
Then I try to test
$ cargo run
error: failed to resolve patches for `https://github.com/maps4print/azul`
Caused by:
failed to load source for a dependency on `azul`
Caused by:
Unable to update /home/name/projects/azul
Caused by:
found a virtual manifest at `/home/name/projects/azul/Cargo.toml` instead of a package manifest
I do not understand the final caused by line.
If I remove the [patch] configuration, it "works".
Quoting because it fails to compile, but that is why I am trying to check it out and attempt a fix. What charges do I need to make to develop the azul dependency?
TIA,
looks like azul is using workspaces so if you want to refer to it via path you must point to the exact member(s) of that workspace.
azul's Cargo.toml contains
[workspace]
members = [
"cargo/azul",
"cargo/azul-css",
"cargo/azul-core",
"cargo/azul-layout",
"cargo/azul-text-layout",
"cargo/azul-widgets",
"cargo/azul-css-parser",
"cargo/azul-native-style",
]
so I believe you should be able to do something like:
[dependencies]
azul = { path = "../azul/cargo/azul"
azul-css = { path = "../azul/cargo/azul-css" }
you may need all/some of the members there.

Unable to build Hyper - invalid character `-` in crate name

I am trying to run the hyper example listed on the Github readme.
extern crate hyper;
use std::io::Write;
use hyper::Server;
use hyper::server::Request;
use hyper::server::Response;
use hyper::net::Fresh;
fn hello(_: Request, res: Response<Fresh>) {
let mut res = res.start().unwrap();
res.write_all(b"Hello World!").unwrap();
res.end().unwrap();
}
fn main() {
Server::http(hello).listen("127.0.0.1:3000").unwrap();
}
And the Cargo.toml looks like this:
[package]
name = <crate_name>
version = <version>
authors = <authors>
[dependencies]
hyper = "0.3"
However, when I attempt to build it using Cargo run I get the following error:
error: invalid character `-` in crate name: `build-script-build`
error: invalid character `-` in crate name: `pkg-config`
error: invalid character `-` in crate name: `rustc-serialize`
I looked through these different crates trying to see if maybe I could just change a "rustc-serialize" to "rustc_serialize" because I think that crate names can no longer have hyphens. However, I couldn't find anything of the sort. I would really like to be able to solve this problem because I have a feeling that I am going to run into this error a few more times while Rust is still being polished.
Edit: The versions are as follows:
Rust: 1.0.0-beta.2
Hyper: 0.3.14
Cargo: 0.0.1-pre-nightly (built 2015-03-09)
Your version of Hyper seems to require a newer version of Rust, which automatically converts hyphens to underscores in crate names.
See RFC 940 and Issue #23533.

cucumber jvm CucumberException: No features found at []

In my cucumber -jvm, Maven, junit Setup I have my testRunner file as
package com.lebara.testrunner;
import cucumber.junit.Cucumber;
import org.junit.runner.RunWith;
#RunWith(Cucumber.class)
#Cucumber.Options(
glue = {"com.lebara.stepdefs","com.lebara.framework.main", "com.lebara.testrunner"},
features = "C:/Users/sarthak.dayanand/Documents/WebRefreshTest/CukeAutomation/LebaraWebAutomationTest1/src/main/resources",
format = {"pretty", "html:target/cucumber-html-report", "json-pretty:target/cucumber-report.json"},
tags = {"#UserJourney"}
)
public class RunCukesTest {
}
I have my feature file in the above mentioned directory.
If I run it, I get the following exception:
cucumber.runtime.CucumberException: No features found at [C:/Users/sarthak.dayanand/Documents/WebRefreshTest/CukeAutomation/LebaraWebAutomationTest1/src/main/resources/cucumber]...
If I remove the "features" option in the testrunner, it tries to look for feature files in the same directory as my testrunner.java
cucumber.runtime.CucumberException: No features found at [com/lebara/testrunner]
And if I put the feature files there, it works.
My question is why is my feature file not being picked up from my previous location, which I thought to be the default file structure for cucumber - maven setup.
How do I make it pick up from there? Help appreciated.
Where exactly are your test runner and feature files? I've got the following setup which works perfectly:
src/test/
java/
com/mypackage/
TestRunner.java
StepDefinition.java
resources
com/mypackage/
fancy.feature
The Maven/Cuke conventions will have the tests executed from the tests/java directory and the feature files found in the test/resources directory. My test runner is basically the same as yours but with less options:
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
#RunWith(Cucumber.class)
#Cucumber.Options(format = {"pretty"})
public class TestRunner { }
Hope this helps if you hadn't already found an answer.
I have a setup similar to yours (not using the Maven/Cucumber conventions). In my options, I don't specify the path from root, but from the project's source folder where the features are held. It makes sense, since otherwise the tests would only be runnable from your machine.
In your case, I think it should be:
features = "src/main/resources"
Just add features = { "classpath:features/feature.feature"}, and the feature must under test/resources/features/feature.feature.
#CucumberOptions(
format = {"pretty", "html:target/html"},
features = {"classpath:features/feature.feature"},
snippets = SnippetType.CAMELCASE
Note classpath.
When you compile your code if you are using maven open up target/test-classes/features and you will see feature.feature
//Removing the space between "**classpath**" and "**:com/**" helped.
#RunWith(Cucumber.class)
#CucumberOptions(
features = {"classpath:com/tk/feature/"}, //NOTE: NO SPACE
glue = {"classpath: com.tk.cucumber"},
plugin = {
"pretty",
"html:build/reports/cucumber"
,"json:build/reports/cucumber-tests/test.json"}
)
public class RunAPITests {}
If you are providing the complete path of the feature file i.e.
"C:/Users/sarthak.dayanand/Documents/WebRefreshTest/CukeAutomation/LebaraWebAutomationTest1/src/main/resources" as in your query, try again by replacing the '/' character with '\\'(double back slash) as below.
"C:\\Users\\sarthak.dayanand\\Documents\\WebRefreshTest\\CukeAutomation\\LebaraWebAutomationTest1\\src\main\\resources\\abc.feature"
This is a git repo which uses the latest cucumber version : Cucumber- Example
Clone this repo and run it in your local machine. The #Given is defined and it should pass. The #Then and #When should be shown as undefined.
This is how the output for it should look :
Output for the Belly feature
Use the structure mentioned :
src / test / java/ io /cucumber / {Step definitions java and run cucumber test files here}
src /test / resources/ io/ cucumber / {feature files here}
You can run the gradle build using ./gradlew clean build
and the cucumber test using ./gradlew clean test --info
If this works, then use the same format in your project.
Just changing .Feature to .feature the problem got resolved for me.
Also make sure the path for feature is righly mention in CucumberOptions as per your feature folder
Some of the online tutorial have mentioned .Feature which brings this problem
so changing the case will solve this problem
There is another instance in which 'Feature Not Found' error occurs. I am posting the solution under this answer as there is no similar question.
I got this error when trying to run the Runner file first time after setting up Cucumber project in Maven. The solution i found was as follows: Go to the folder in which the 'feature' file is present in Windows Explorer. Check the size of the feature file you are trying to run. If the size is '0' KB, it will show the 'Feature Not Found' error. Make some changes to file until a value greater than zero is displayed. Run again after making changes.
#RunWith(Cucumber.class)
#CucumberOptions(
features = {"src/main/resources/cucumber/features"},//your feature path
tags = "not #Wip",
glue = {"classpath:steps"},
plugin = {"pretty", "html:target/cucumber/html"})
You must set the feature directory correctly
By putting the feature file under src/test/java where the runner and steps file or
by putting it under src/main/java the problem will get resolved.

Resources