Skip to content

Commit

Permalink
[DO NOT MERGE] testing Windows CI failures
Browse files Browse the repository at this point in the history
  • Loading branch information
aykevl committed Nov 19, 2024
1 parent e12da15 commit 5109fe9
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
goarch: arm64
runs-on: ${{ matrix.os }}
steps:
- name: exit early
run: command-does-not-exist
- name: Install Dependencies
run: |
HOMEBREW_NO_AUTO_UPDATE=1 brew install qemu binaryen
Expand Down Expand Up @@ -128,6 +130,8 @@ jobs:
matrix:
version: [16, 17, 18]
steps:
- name: exit early
run: command-does-not-exist
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Fix Python symlinks
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: exit early
run: command-does-not-exist
- name: Install apk dependencies
# tar: needed for actions/cache@v4
# git+openssh: needed for checkout (I think?)
Expand Down Expand Up @@ -171,6 +173,8 @@ jobs:
# potential bugs.
runs-on: ubuntu-latest
steps:
- name: exit early
run: command-does-not-exist
- name: Checkout
uses: actions/checkout@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
nix-test:
runs-on: ubuntu-latest
steps:
- name: exit early
run: command-does-not-exist
- name: Uninstall system LLVM
# Hack to work around issue where we still include system headers for
# some reason.
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/sizediff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
permissions:
pull-requests: write
steps:
- name: exit early
run: command-does-not-exist
# Prepare, install tools
- name: Add GOBIN to $PATH
run: |
Expand Down
37 changes: 20 additions & 17 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,27 @@ jobs:
minimum-size: 8GB
maximum-size: 24GB
disk-root: "C:"
- uses: brechtm/setup-scoop@v2
with:
scoop_update: 'false'
- name: Install Dependencies
shell: bash
run: |
scoop install ninja binaryen
#- uses: brechtm/setup-scoop@v2
# with:
# scoop_update: 'false'
#- name: Install Dependencies
# shell: bash
# run: |
# scoop install ninja binaryen
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: submodules
shell: bash
run: git submodule update --init lib/mingw-w64
- name: Extract TinyGo version
id: version
shell: bash
run: ./.github/workflows/tinygo-extract-version.sh | tee -a "$GITHUB_OUTPUT"
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
#- name: Install Go
# uses: actions/setup-go@v5
# with:
# go-version: '1.23'
# cache: true
- name: Restore cached LLVM source
uses: actions/cache/restore@v4
id: cache-llvm-source
Expand Down Expand Up @@ -91,6 +92,11 @@ jobs:
with:
key: ${{ steps.cache-llvm-build.outputs.cache-primary-key }}
path: llvm-build
- name: Test TinyGo
shell: bash
run: make test GOTESTFLAGS="-short -run=TestBuild -v"
- name: exit
run: command-does-not-exist
- name: Cache wasi-libc sysroot
uses: actions/cache@v4
id: cache-wasi-libc
Expand All @@ -105,9 +111,6 @@ jobs:
scoop install [email protected]
- name: make gen-device
run: make -j3 gen-device
- name: Test TinyGo
shell: bash
run: make test GOTESTFLAGS="-short"
- name: Build TinyGo release tarball
shell: bash
run: make build/release -j4
Expand Down
8 changes: 4 additions & 4 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ gen-device: gen-device-stm32
endif

gen-device-avr:
@if [ ! -e lib/avr/README.md ]; then echo "Submodules have not been downloaded. Please download them using:\n git submodule update --init"; exit 1; fi
#@if [ ! -e lib/avr/README.md ]; then echo "Submodules have not been downloaded. Please download them using:\n git submodule update --init"; exit 1; fi
$(GO) build -o ./build/gen-device-avr ./tools/gen-device-avr/
./build/gen-device-avr lib/avr/packs/atmega src/device/avr/
./build/gen-device-avr lib/avr/packs/tiny src/device/avr/
Expand Down Expand Up @@ -263,7 +263,7 @@ endif
.PHONY: wasi-libc
wasi-libc: lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a
lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a:
@if [ ! -e lib/wasi-libc/Makefile ]; then echo "Submodules have not been downloaded. Please download them using:\n git submodule update --init"; exit 1; fi
#@if [ ! -e lib/wasi-libc/Makefile ]; then echo "Submodules have not been downloaded. Please download them using:\n git submodule update --init"; exit 1; fi
cd lib/wasi-libc && $(MAKE) -j4 EXTRA_CFLAGS="-O2 -g -DNDEBUG -mnontrapping-fptoint -msign-ext" MALLOC_IMPL=none CC="$(CLANG)" AR=$(LLVM_AR) NM=$(LLVM_NM)

# Generate WASI syscall bindings
Expand Down Expand Up @@ -292,8 +292,8 @@ endif
tinygo: ## Build the TinyGo compiler
@if [ ! -f "$(LLVM_BUILDDIR)/bin/llvm-config" ]; then echo "Fetch and build LLVM first by running:"; echo " $(MAKE) llvm-source"; echo " $(MAKE) $(LLVM_BUILDDIR)"; exit 1; fi
CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOENVFLAGS) $(GO) build -buildmode exe -o build/tinygo$(EXE) -tags "byollvm osusergo" .
test: wasi-libc check-nodejs-version
CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) test $(GOTESTFLAGS) -timeout=1h -buildmode exe -tags "byollvm osusergo" $(GOTESTPKGS)
test: #wasi-libc check-nodejs-version
CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) test $(GOTESTFLAGS) -timeout=1h -buildmode exe -tags "byollvm osusergo" .

# Standard library packages that pass tests on darwin, linux, wasi, and windows, but take over a minute in wasi
TEST_PACKAGES_SLOW = \
Expand Down
43 changes: 38 additions & 5 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"bufio"
"bytes"
"context"
"crypto/sha256"
"errors"
"flag"
"io"
Expand All @@ -15,6 +16,7 @@ import (
"reflect"
"regexp"
"runtime"
"strconv"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -114,10 +116,12 @@ func TestBuild(t *testing.T) {
return
}

t.Run("Host", func(t *testing.T) {
t.Run("Debugging", func(t *testing.T) {
t.Parallel()
runPlatTests(optionsFromTarget("", sema), tests, t)
options := optionsFromTarget("", sema)
runTest("alias.go", options, t, nil, nil)
})
return

// Test a few build options.
t.Run("build-options", func(t *testing.T) {
Expand Down Expand Up @@ -420,9 +424,38 @@ func runTestWithConfig(name string, t *testing.T, options compileopts.Options, c

// Build the test binary.
stdout := &bytes.Buffer{}
_, err = buildAndRun(pkgName, config, stdout, cmdArgs, environmentVars, time.Minute, func(cmd *exec.Cmd, result builder.BuildResult) error {
return cmd.Run()
})
tmpdir := t.TempDir()
_, fileExt := config.EmulatorFormat()
result, err := builder.Build(pkgName, fileExt, tmpdir, config)
if err != nil {
t.Fatal("could not compile:", err)
}
data, err := os.ReadFile(result.Executable)
if err != nil {
t.Fatal("failed to read executable:", err)
}
hash := sha256.Sum256(data)
t.Logf("executable hash and size: %d %x", len(data), hash)

for i := 0; i < 100; i++ {
t.Run(strconv.Itoa(i), func(t *testing.T) {
cmd := exec.Command(result.Executable)
t.Log("command:", cmd)
stdout := &bytes.Buffer{}
cmd.Stdout = stdout
cmd.Stderr = stdout
err = cmd.Run()
if err == nil {
t.Log(" no cmd.Run() error")
} else {
t.Log(" error:", err)
}
actual := stdout.Bytes()
checkOutput(t, expectedOutputPath, actual)
})
}
return

if err != nil {
w := &bytes.Buffer{}
diagnostics.CreateDiagnostics(err).WriteTo(w, "")
Expand Down
4 changes: 3 additions & 1 deletion src/runtime/runtime_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ func os_runtime_args() []string {
}

func putchar(c byte) {
libc_putchar(int(c))
if libc_putchar(int(c)) < 0 {
libc_exit(42)
}
}

var heapSize uintptr = 128 * 1024 // small amount to start
Expand Down

0 comments on commit 5109fe9

Please sign in to comment.