Skip to content

Commit

Permalink
Allow tests to be run on macOS (#295)
Browse files Browse the repository at this point in the history
Requires #276 to be merged, as earlier versions of JavaScriptKit can't be depended on in macOS builds due to unsafe flags.

* Add Link View

* Add Publish support

* Remove #if checks

* Upgrade swift snapshot

* Try swiftwasm-action@main

* Remove Publish support from this repo

* Remove TokamakPublish target

* Allow tests to be run on macOS

* Update `ci.yml` to build and run the test product

* Trigger CI on all PRs without branch restrictions

* Rename linux_build to swiftwasm_build in ci.yml

Co-authored-by: Carson Katri <carson.katri@gmail.com>
  • Loading branch information
MaxDesiatov and carson-katri committed Nov 7, 2020
1 parent 348408e commit 9681b91
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: CI

on:
push:
branches: [main]
pull_request:
push:
branches: [main]

jobs:
linux_build:
swiftwasm_build:
runs-on: ubuntu-20.04

steps:
Expand All @@ -25,8 +24,11 @@ jobs:
shell: bash
run: |
set -ex
sudo xcode-select --switch /Applications/Xcode_12_beta.app/Contents/Developer/
# swift test
sudo xcode-select --switch /Applications/Xcode_12.1.app/Contents/Developer/
# avoid building unrelated products for testing by specifying the test product explicitly
swift build --product TokamakPackageTests
`xcrun --find xctest` .build/debug/TokamakPackageTests.xctest
xcodebuild -version
cd "NativeDemo"
xcodebuild -scheme iOS -destination 'generic/platform=iOS' \
Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/swiftwasm/JavaScriptKit.git",
"state": {
"branch": null,
"revision": "6e84a7003071ed3e9fa7f8d8266a272a36b84608",
"version": "0.7.2"
"revision": "8ba4135d5fd6a734c3771ef3fac66896bbcb0214",
"version": "0.8.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ let package = Package(
),
.testTarget(
name: "TokamakTests",
dependencies: ["TokamakDemo", "TokamakTestRenderer"]
dependencies: ["TokamakTestRenderer"]
),
]
)
2 changes: 2 additions & 0 deletions Sources/TokamakDemo/URLHashDemo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if os(WASI)
import JavaScriptKit
import TokamakDOM

Expand Down Expand Up @@ -50,3 +51,4 @@ struct URLHashDemo: View {
}
}
}
#endif
12 changes: 6 additions & 6 deletions Tests/TokamakTests/ColorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import TokamakCore
@testable import TokamakCore
import XCTest

final class ColorTests: XCTestCase {
func testHexColors() {
let env = EnvironmentValues()
guard let color = Color(hex: "#FF00FF")?._evaluate(env) else {
guard let color = Color(hex: "#FF00FF")?.provider.resolve(in: env) else {
XCTFail("Hexadecimal decoding failed")
return
}
Expand All @@ -29,11 +29,11 @@ final class ColorTests: XCTestCase {

XCTAssertEqual(
color,
Color(hex: "FF00FF")?._evaluate(env),
Color(hex: "FF00FF")?.provider.resolve(in: env),
"The '#' before a hex code produced a different output than without it"
)

guard let red = Color(hex: "#FF0000")?._evaluate(env) else {
guard let red = Color(hex: "#FF0000")?.provider.resolve(in: env) else {
XCTFail("Hexadecimal decoding failed")
return
}
Expand All @@ -42,7 +42,7 @@ final class ColorTests: XCTestCase {
XCTAssertEqual(red.green, 0)
XCTAssertEqual(red.blue, 0)

guard let green = Color(hex: "#00FF00")?._evaluate(env) else {
guard let green = Color(hex: "#00FF00")?.provider.resolve(in: env) else {
XCTFail("Hexadecimal decoding failed")
return
}
Expand All @@ -51,7 +51,7 @@ final class ColorTests: XCTestCase {
XCTAssertEqual(green.green, 1)
XCTAssertEqual(green.blue, 0)

guard let blue = Color(hex: "#0000FF")?._evaluate(env) else {
guard let blue = Color(hex: "#0000FF")?.provider.resolve(in: env) else {
XCTFail("Hexadecimal decoding failed")
return
}
Expand Down

0 comments on commit 9681b91

Please sign in to comment.