Better testing infrastructure

andybalholm
Mar 29, 2023, 11:22 PM
CSP3ROTU3KQQBKKDKY7WYBTBHM5DY3QOVKYFHMDTLXVMAZG3IHQAC

Dependencies

  • [2] WQWRJHHF Handle Option<Hash> better
  • [3] 6GDPWAD2 Parse Unhashed and Contents of Change
  • [4] 7VEHGTEY Switch from reading text format to reading binary format.
  • [5] EVHNGDT7 parse FileAdd hunk
  • [6] PHRWK7NK Parse change headers
  • [7] FBQT4QEB Parse dependencies
  • [8] 4JWXOJIP Parse dependencies

Change contents

  • replacement in change_test.go at line 14
    [4.8822][4.8822:9091](),[4.4983][4.692:701](),[4.9091][4.692:701](),[4.692][4.692:701](),[4.701][4.429:699](),[4.699][4.4998:5092](),[4.5092][2.743:975](),[2.975][4.5304:5331](),[4.5304][4.5304:5331]()
    var CB7A3P_golden = Change{
    Version: 6,
    Message: "Say hello",
    Description: "a trivial change",
    Timestamp: time.Date(2023, 3, 27, 18, 51, 58, 26097601, time.UTC),
    Authors: []map[string]string{
    {
    "key": "BCEXYuKWaQ96btsk8UyBZWHLjn1Brhykv8tuZGPRjzFn",
    },
    },
    Dependencies: []Hash{Hash{0xe7, 0x82, 0xb1, 0xd7, 0xe4, 0x17, 0x64, 0xe4, 0xfe, 0x45, 0x2d, 0x6f, 0x24, 0x22, 0x40, 0x26, 0x16, 0x12, 0xb7, 0xf, 0x42, 0x70, 0xd9, 0xac, 0xd8, 0x4e, 0x5a, 0x82, 0xea, 0x85, 0xab, 0x57}},
    ExtraKnown: []Hash{},
    Metadata: []byte{},
    Changes: []Hunk{
    FileAdd{
    AddName: NewVertex{
    UpContext: []Position{
    Position{
    Change: OptionalHash{true, Hash{0xe7, 0x82, 0xb1, 0xd7, 0xe4, 0x17, 0x64, 0xe4, 0xfe, 0x45, 0x2d, 0x6f, 0x24, 0x22, 0x40, 0x26, 0x16, 0x12, 0xb7, 0x0f, 0x42, 0x70, 0xd9, 0xac, 0xd8, 0x4e, 0x5a, 0x82, 0xea, 0x85, 0xab, 0x57}},
    Pos: 0x1,
    },
    [4.8822]
    [4.5331]
    var changeTestCases = []struct {
    hash string
    data []byte
    parsed Change
    }{
    {
    hash: "CB7A3PP3XC6JY3QYUUNB4WCXGNFJMHTTH54MBAWBUVQL7TTHWBBQC",
    data: CB7A3P,
    parsed: Change{
    Version: 6,
    Message: "Say hello",
    Description: "a trivial change",
    Timestamp: time.Date(2023, 3, 27, 18, 51, 58, 26097601, time.UTC),
    Authors: []map[string]string{
    {
    "key": "BCEXYuKWaQ96btsk8UyBZWHLjn1Brhykv8tuZGPRjzFn",
  • edit in change_test.go at line 32
    [4.5338][4.5338:5458](),[4.5458][2.976:1017](),[2.1017][4.5479:5504](),[4.5479][4.5479:5504]()
    DownContext: []Position{},
    Flag: 0x11,
    Start: 0x0,
    End: 0x1d,
    Inode: Position{
    Change: OptionalHash{true, Hash{}},
    Pos: 0x0,
    },
  • replacement in change_test.go at line 33
    [4.5510][4.5510:5576](),[4.5576][2.1018:1048](),[2.1048][4.5598:5618](),[4.5598][4.5598:5618]()
    AddInode: NewVertex{
    UpContext: []Position{
    Position{
    Change: OptionalHash{},
    Pos: 0x1d,
    [4.5510]
    [4.5618]
    Dependencies: []Hash{Hash{0xe7, 0x82, 0xb1, 0xd7, 0xe4, 0x17, 0x64, 0xe4, 0xfe, 0x45, 0x2d, 0x6f, 0x24, 0x22, 0x40, 0x26, 0x16, 0x12, 0xb7, 0xf, 0x42, 0x70, 0xd9, 0xac, 0xd8, 0x4e, 0x5a, 0x82, 0xea, 0x85, 0xab, 0x57}},
    ExtraKnown: []Hash{},
    Metadata: []byte{},
    Changes: []Hunk{
    FileAdd{
    AddName: NewVertex{
    UpContext: []Position{
    Position{
    Change: OptionalHash{true, Hash{0xe7, 0x82, 0xb1, 0xd7, 0xe4, 0x17, 0x64, 0xe4, 0xfe, 0x45, 0x2d, 0x6f, 0x24, 0x22, 0x40, 0x26, 0x16, 0x12, 0xb7, 0x0f, 0x42, 0x70, 0xd9, 0xac, 0xd8, 0x4e, 0x5a, 0x82, 0xea, 0x85, 0xab, 0x57}},
    Pos: 0x1,
    },
    },
    DownContext: []Position{},
    Flag: 0x11,
    Start: 0x0,
    End: 0x1d,
    Inode: Position{
    Change: OptionalHash{true, Hash{}},
    Pos: 0x0,
    },
  • replacement in change_test.go at line 54
    [4.5626][4.5626:5754](),[4.5754][2.1049:1090](),[2.1090][4.5775:5872](),[4.5775][4.5775:5872](),[4.5872][2.1091:1121](),[2.1121][4.5894:5914](),[4.5894][4.5894:5914]()
    },
    DownContext: []Position{},
    Flag: 0x11,
    Start: 0x1e,
    End: 0x1e,
    Inode: Position{
    Change: OptionalHash{true, Hash{}},
    Pos: 0x0,
    },
    },
    Contents: NewVertex{
    UpContext: []Position{
    Position{
    Change: OptionalHash{},
    Pos: 0x1e,
    [4.5626]
    [4.5914]
    AddInode: NewVertex{
    UpContext: []Position{
    Position{
    Change: OptionalHash{},
    Pos: 0x1d,
    },
    },
    DownContext: []Position{},
    Flag: 0x11,
    Start: 0x1e,
    End: 0x1e,
    Inode: Position{
    Change: OptionalHash{true, Hash{}},
    Pos: 0x0,
    },
    },
    Contents: NewVertex{
    UpContext: []Position{
    Position{
    Change: OptionalHash{},
    Pos: 0x1e,
    },
    },
    DownContext: []Position{},
    Flag: 0x1,
    Start: 0x1f,
    End: 0x2c,
    Inode: Position{
    Change: OptionalHash{},
    Pos: 0x1e,
    },
  • edit in change_test.go at line 86
    [4.5922]
    [4.5922]
    Path: "hello",
    Encoding: "UTF-8",
  • replacement in change_test.go at line 89
    [4.5929][4.5929:6049](),[4.6049][2.1122:1151](),[2.1151][4.6070:6096](),[4.6070][4.6070:6096]()
    DownContext: []Position{},
    Flag: 0x1,
    Start: 0x1f,
    End: 0x2c,
    Inode: Position{
    Change: OptionalHash{},
    Pos: 0x1e,
    },
    [4.5929]
    [4.6096]
    },
    ContentsHash: Hash{0x9e, 0xb3, 0xf7, 0x5c, 0x66, 0x9f, 0x18, 0xec, 0x4f, 0xf7, 0x30, 0x51, 0x42, 0xfe, 0x79, 0xbd, 0x52, 0x87, 0x24, 0x1, 0x1a, 0xc5, 0x77, 0xe8, 0xf9, 0x5b, 0x14, 0xd9, 0xee, 0xf7, 0x21, 0x48},
    Unhashed: map[string]any{
    "signature": "4cKLG1A2wd3pp6hBMaceFCGo8ADhUaDNz31MJeZxNFYnBf8yPepXfgor9o78y88ComC3b1YzDccucDbPbez9Ppxe",
  • replacement in change_test.go at line 94
    [4.6102][4.6102:6146]()
    Path: "hello",
    Encoding: "UTF-8",
    [4.6102]
    [4.6146]
    Contents: []byte{
    0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x01,
    0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x54, 0x46, 0x2d, 0x38, 0x00, 0x00, 0x68,
    0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x0a, 0x00,
    },
  • edit in change_test.go at line 100
    [4.6151][4.6151:6367](),[4.6367][3.0:433]()
    },
    ContentsHash: Hash{0x9e, 0xb3, 0xf7, 0x5c, 0x66, 0x9f, 0x18, 0xec, 0x4f, 0xf7, 0x30, 0x51, 0x42, 0xfe, 0x79, 0xbd, 0x52, 0x87, 0x24, 0x1, 0x1a, 0xc5, 0x77, 0xe8, 0xf9, 0x5b, 0x14, 0xd9, 0xee, 0xf7, 0x21, 0x48},
    Unhashed: map[string]any{
    "signature": "4cKLG1A2wd3pp6hBMaceFCGo8ADhUaDNz31MJeZxNFYnBf8yPepXfgor9o78y88ComC3b1YzDccucDbPbez9Ppxe",
    },
    Contents: []byte{
    0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x01,
    0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x54, 0x46, 0x2d, 0x38, 0x00, 0x00, 0x68,
    0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x0a, 0x00,
  • replacement in change_test.go at line 104
    [4.9135][4.9135:9280](),[4.9280][2.1152:1224]()
    c, err := DeserializeChange(CB7A3P)
    if err != nil {
    t.Fatalf("deserialization error: %v", err)
    }
    if !reflect.DeepEqual(c, CB7A3P_golden) {
    t.Fatalf("got %s, want %s", spew.Sdump(c), spew.Sdump(CB7A3P_golden))
    [4.9135]
    [4.700]
    for _, testCase := range changeTestCases {
    c, err := DeserializeChange(testCase.data)
    if err != nil {
    t.Errorf("%s: deserialization error: %v", testCase.hash, err)
    continue
    }
    if !reflect.DeepEqual(c, testCase.parsed) {
    t.Errorf("%s: got %s, want %s", testCase.hash, spew.Sdump(c), spew.Sdump(testCase.parsed))
    }