-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Check the output of wasm in dev subcommand test #473
Conversation
do { | ||
try openInSystemBrowser(url: localURL) | ||
} catch { | ||
terminal.write("open browser failed: \(error)", inColor: .red) |
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.
従来通り、起動しなくても処理は続ける
@@ -105,8 +117,8 @@ public actor Server { | |||
|
|||
private var serverChannel: (any Channel)! | |||
|
|||
/// Local URL of this server, `https://128.0.0.1:8080/` by default. | |||
private let localURL: String | |||
/// Local URL of this server, `https://127.0.0.1:8080/` by default. |
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.
localhostは127です
/// Local URL of this server, `https://128.0.0.1:8080/` by default. | ||
private let localURL: String | ||
/// Local URL of this server, `https://127.0.0.1:8080/` by default. | ||
private let localURL: URL |
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.
早めにURL型にします
/// - Returns: true if launching command returns successfully. | ||
@discardableResult | ||
public func openInSystemBrowser(url: String) -> Bool { | ||
public func openInSystemBrowser(url: URL) throws { |
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.
Stringを受け取ってBoolを返していましたが、
URLを受け取って失敗したら例外を投げるようにします。
引数については型を活用します。
エラーについてですが、例外の方が情報が多いです。
おそらく元々の実装はブラウザオープンに失敗しても動作を止めないことを想定していますが、
それは関数呼び出し側の都合で、必要ならcatchすれば良いです。
@@ -27,7 +27,7 @@ final class WebDriverClientTests: XCTestCase { | |||
let client = try await WebDriverClient.newSession( | |||
endpoint: checkRemoteURL(), httpClient: .shared | |||
) | |||
try await client.goto(url: "https://example.com") | |||
try await client.goto(url: URL(string: "https://github.com/swiftwasm/carton")!) |
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.
一応自分たちが管理してるURLの方が良いと思います。
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.
The example.com is managed by ICANN. It should be more reliable than GitHub IMO.
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.
なるほど、OKです。戻します。
@@ -84,6 +102,16 @@ final class FrontendDevServerTests: XCTestCase { | |||
let expected = try String(contentsOf: resourcesDir.appending(component: name).asURL) | |||
XCTAssertEqual(styleCss, expected) | |||
} | |||
|
|||
try openInSystemBrowser(url: host) |
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.
I don't think open
families work on CI. We should use WebDriver or something like headless solutions.
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.
そうですね。
$ carton test
で使われている実装を再利用するようにコードを組んでみます。
dev serverのテストではコンテンツの配送はテストされていたが、
それをブラウザ開いたらちゃんと動くかどうかは全くテストされていなかった。
dev serverがwasmから受け取った出力をコンソールに出すので、
frontendを起動するテスト側で出力を監視する。
Linux では xdg-open となってるけど CI はうまくいくんだろうか?#474 の成果を使って、
WebDriverを利用してテストする