1

我设法让 Travis 和 PlatformIO 一起工作。源代码由 Travis 构建和检查,但我在 test_main.cpp 中找不到我的测试结果。当我更改测试必须失败的源代码时,Travis 也会返回成功。如何解决我的 Travis 检查 test_main.cpp 中的测试的问题,而不仅仅是它是否构建(我猜它现在正在这样做)

测试主程序.cpp

#include <Arduino.h>
#include <unity.h>

#define LED_BUILTIN 13

void setUp(void) {
// set stuff up here
}

void tearDown(void) {
// clean stuff up here
}

void test_led_builtin_pin_number(void) {
    TEST_ASSERT_EQUAL(13, LED_BUILTIN);
}

void test_led_state_high(void) {
    digitalWrite(LED_BUILTIN, HIGH);
    TEST_ASSERT_EQUAL(HIGH, digitalRead(LED_BUILTIN));
}

void test_led_state_low(void) {
    digitalWrite(LED_BUILTIN, LOW);
    TEST_ASSERT_EQUAL(HIGH, digitalRead(LED_BUILTIN));
}

void setup() {
    // NOTE!!! Wait for >2 secs
    // if board doesn't support software reset via Serial.DTR/RTS
    delay(2000);

    UNITY_BEGIN();    // IMPORTANT LINE!
    RUN_TEST(test_led_builtin_pin_number);

    pinMode(LED_BUILTIN, OUTPUT);
}

uint8_t i = 0;
uint8_t max_blinks = 5;

void loop() {
    if (i < max_blinks)
    {
        RUN_TEST(test_led_state_high);
        delay(500);
        RUN_TEST(test_led_state_low);
        delay(500);
        i++;
    }
    else if (i == max_blinks) {
      UNITY_END(); // stop unit testing
    }
}

.Travis.yml

language: python
python:
    - "2.7"

sudo: false
cache:
    directories:
        - "~/.platformio"

install:
     - pip install -U platformio
     - platformio lib -g install https://github.com/ThrowTheSwitch/Unity.git

env:
    - PLATFORMIO_CI_SRC=test/test_main.cpp

script:
    # - platformio ci --project-conf=platformio.ini
    - platformio ci --lib="." --board=esp32dev

Platformio.ini

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:MainBoard]
platform = espressif32
board = esp32dev
framework = arduino

travis 结果的最后一部分

Compiling .pioenvs/esp32dev/FrameworkArduino/esp32-hal-spi.c.o
Compiling .pioenvs/esp32dev/FrameworkArduino/esp32-hal-time.c.o
Compiling .pioenvs/esp32dev/FrameworkArduino/esp32-hal-timer.c.o
Compiling .pioenvs/esp32dev/FrameworkArduino/esp32-hal-touch.c.o
Compiling .pioenvs/esp32dev/FrameworkArduino/esp32-hal-uart.c.o
Compiling .pioenvs/esp32dev/FrameworkArduino/libb64/cdecode.c.o
Archiving .pioenvs/esp32dev/libe4e/libUnity.a
Compiling .pioenvs/esp32dev/FrameworkArduino/libb64/cencode.c.o
Compiling .pioenvs/esp32dev/FrameworkArduino/main.cpp.o
Indexing .pioenvs/esp32dev/libe4e/libUnity.a
Compiling .pioenvs/esp32dev/FrameworkArduino/stdlib_noniso.c.o
Compiling .pioenvs/esp32dev/FrameworkArduino/wiring_pulse.c.o
Compiling .pioenvs/esp32dev/FrameworkArduino/wiring_shift.c.o
Archiving .pioenvs/esp32dev/libFrameworkArduino.a
Indexing .pioenvs/esp32dev/libFrameworkArduino.a
Linking .pioenvs/esp32dev/firmware.elf
Building .pioenvs/esp32dev/firmware.bin
Retrieving maximum program size .pioenvs/esp32dev/firmware.elf
Checking size .pioenvs/esp32dev/firmware.elf
Memory Usage -> 
DATA:    [          ]   4.3% (used 14008 bytes from 327680 bytes)
PROGRAM: [=         ]  13.9% (used 182772 bytes from 1310720 bytes)
========================= [SUCCESS] Took 5.53 seconds =========================
The command "platformio ci --lib="." --board=esp32dev" exited with 0.
cache.2
store build cache
0.00s
1.65snothing changed, not updating cache
Done. Your build exited with 0.
4

0 回答 0